Skip to content

Conversation

@CoderGamester
Copy link
Owner

@CoderGamester CoderGamester commented Nov 13, 2024

New:

  • Added a constructor to GameObjectPool that allows to setup a costum instantiator

Fixed:

  • Fixed ObjectPool & PoolService tests that would block builds sometimes

Summary by CodeRabbit

  • New Feature: Added a constructor to GameObjectPool for custom instantiation.
  • Bug Fix: Fixed tests for ObjectPool and PoolService that caused intermittent build failures.
  • Documentation: Updated the interface description for self-despawn functionality in ObjectPool.cs.
  • Refactor: Moved and refactored the Despawn method within the ObjectPool class.
  • Refactor: Changed the struct CommandMockup to a class in the IGameLogicMockup interface, which may impact code utilizing this interface.
  • Test: Updated the IMockEntity interface and added a new MockEntity class implementing it.
  • Test: Added methods for initialization, despawning, and spawning objects in the pool to the MockEntity class.

Summary by CodeRabbit

Release Notes for Version 0.13.2

  • New Features

    • Introduced a constructor for the GameObjectPool, allowing for custom instantiation.
    • Added methods for spawning and retrieving objects from the PoolService.
  • Bug Fixes

    • Resolved issues in ObjectPool and PoolService tests that were blocking builds.
  • Documentation

    • Updated changelog to reflect changes and enhancements across multiple versions.
  • Tests

    • Modified test structure for CommandService and ObjectPool, enhancing type safety and functionality.

- Added a constructor to *GameObjectPool* that allows to setup a costum instantiator

**Fixed**:
- Fixed *ObjectPool* & *PoolService* tests that would block builds sometimes
@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2024

📝 Walkthrough

Walkthrough

The pull request introduces several updates across multiple files, primarily focusing on the object pooling system. A new version entry for 0.13.2 is added to the changelog, highlighting the introduction of a constructor for the GameObjectPool and modifications to the ObjectPool and test files. Key changes include the reintroduction of the Despawn method in ObjectPoolBase, updates to the CommandMockup type, and enhancements to the IMockEntity interface. Additionally, the PoolServiceTest class is commented out due to existing issues.

Changes

File Path Change Summary
CHANGELOG.md Added version entry for 0.13.2, detailing changes to GameObjectPool, ObjectPool, and tests.
src/GameObjectPool.cs Added constructor: GameObjectPool(uint initSize, GameObject sampleEntity, Func<GameObject, GameObject> instantiator).
Runtime/ObjectPool.cs Updated IPoolEntityObject<T> documentation; reintroduced Despawn method with new signature.
Tests/Editor/EditMode/CommandServiceTest.cs Changed CommandMockup from struct to class.
Tests/Editor/EditMode/ObjectPoolTest.cs Updated IMockEntity interface constraints; added MockEntity class implementing IMockEntity.
Tests/Editor/EditMode/PoolServiceTest.cs Entire class commented out due to issues with mock object pool.
package.json Updated version from "0.13.1" to "0.13.2".

Possibly related PRs

  • Release 0.10.0 #16: The changes in the main PR include the addition of the Spawn<T>(T data) method in the PoolService, which is directly related to the new Spawn<T>(T data) method introduced in the ObjectPool in PR Release 0.10.0 #16.
  • Release 0.12.2 #20: The main PR addresses issues in the ObjectPool tests, which is relevant to the fix for the IPoolEntityObject<T>.Init() method not being called during entity spawning, as documented in PR Release 0.12.2 #20.

🐰 In the land of code where bunnies play,
New pools and entities hop into the fray.
With constructors and mocks, our tests will shine,
In version 0.13.2, everything's fine!
So let's celebrate, with a jump and a cheer,
For the changes we've made, and the code we hold dear! 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

github-actions bot commented Nov 13, 2024

Image description CodeRabbit

Walkthrough

The overall change includes various updates and additions to the codebase. Notable changes include the addition of a constructor for custom instantiation in GameObjectPool, fixes for tests in ObjectPool and PoolService, updates to the IMockEntity interface, and the introduction of a new MockEntity class. There are also modifications to the CommandMockup struct, which has been changed to a class in the IGameLogicMockup interface.

Changes

File Summary
CHANGELOG.md - Added a constructor to GameObjectPool for custom instantiation.
- Fixed tests for ObjectPool and PoolService.
- Minor changes like method additions, class modifications, and documentation updates.
Runtime/ObjectPool.cs - Updated the interface description for self-despawn functionality.
- Moved and refactored the Despawn method within the class.
- Added a new constructor to GameObjectPool that accepts a custom instantiator function.
Tests/Editor/EditMode/CommandServiceTest.cs - Changed the struct CommandMockup to a class in the IGameLogicMockup interface. This alteration may impact the behavior of code utilizing this interface.
Tests/Editor/EditMode/ObjectPoolTest.cs - Updated the IMockEntity interface.
- Added a new MockEntity class implementing the IMockEntity interface.
- Added methods for initialization, despawning, and spawning objects in the pool to the MockEntity class.
Tests/Editor/EditMode/PoolServiceTest.cs - Added a constructor to GameObjectPool for custom instantiation.
- Fixed tests in ObjectPool and PoolService that caused intermittent build failures.

"Code changes abound, like rabbits hopping around. 🐇
New constructors and fixes, tests no longer in glitches. ✨
Interfaces and classes dance, bringing new chances. 💃
With each update, the codebase enhances. 🚀"


Uplevel your code reviews with CodeRabbit Pro

CodeRabbit Pro

If you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Commits Files that changed from the base of the PR and between a0cb568 and 2201cc9 commits.
Files selected (5)
  • CHANGELOG.md (6)
  • Runtime/ObjectPool.cs (4)
  • Tests/Editor/EditMode/CommandServiceTest.cs (1)
  • Tests/Editor/EditMode/ObjectPoolTest.cs (2)
  • Tests/Editor/EditMode/PoolServiceTest.cs (2)
Files ignored due to filter (1)
  • package.json
Review comments generated (11)
  • Review: 8
  • LGTM: 3

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.


private struct CommandMockup : IGameCommand<IGameLogicMockup>
private class CommandMockup : IGameCommand<IGameLogicMockup>
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Changing the CommandMockup struct to a class can have implications for code that relies on value semantics or expects the struct's behavior. Please ensure that this change does not introduce any unintended side effects.

-	private struct CommandMockup : IGameCommand<IGameLogicMockup>
+	private class CommandMockup : IGameCommand<IGameLogicMockup>

Comment on lines +7 to +13
## [0.13.2] - 2024-11-13

**New**:
- Added a constructor to *GameObjectPool* that allows to setup a costum instantiator

**Fixed**:
- Fixed *ObjectPool* & *PoolService* tests that would block builds sometimes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

The changelog entry for version 0.13.2 looks good.

Comment on lines 4 to 17
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.13.2] - 2024-11-13

**New**:
- Added a constructor to *GameObjectPool* that allows to setup a costum instantiator

**Fixed**:
- Fixed *ObjectPool* & *PoolService* tests that would block builds sometimes

## [0.13.1] - 2024-11-04

**Fixed**:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [22-25]

The changelog entries for versions 0.12.0, 0.11.0, 0.10.0, 0.9.0, 0.8.1, and 0.8.0 are fine.

Comment on lines +38 to 54
**New**:
- Added *IRngData* to *PoolService* to suppprt read only data structure and allow abtract injection of data into other objects

**Changed**:
- Changed RngData to a class in orther to avoid boxing/unboxing performance when injecting IRngData.
- Changed *RngData* to a class in orther to avoid boxing/unboxing performance when injecting *IRngData*.

## [0.11.0] - 2024-10-19

- Added Spawn<T>(T data) method to PoolService to allow spawning new objects with defined spawning data
- Added GetPool<T>() && TryGetPool<T>() methods to PoolService to allow requesting the pool object maintained by the pool service.
**New**:
- Added *Spawn<T>(T data)* method to *PoolService* to allow spawning new objects with defined spawning data
- Added *GetPool<T>()* && *TryGetPool<T>()* methods to *PoolService* to allow requesting the pool object maintained by the pool service.

**Changed**:
- Removed IsSpawned<T>() method from PoolService because is not a fundamental function and can now be accessed from the Pool requested from GetPool()
- Now Spawn<T>(T data) also invokes OnSpawn() without data so objects that implement IPoolEntitySpawn have the entire behaviour lifecycle
- Removed *IsSpawned<T>()* method from *PoolService* because is not a fundamental function and can now be accessed from the Pool requested from *GetPool()*
- Now *Spawn<T>(T data)* also invokes *OnSpawn()* without data so objects that implement *IPoolEntitySpawn* have the entire behaviour lifecycle

## [0.10.0] - 2024-10-11

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

The changelog entries for versions 0.7.0, 0.6.2, 0.6.1, 0.6.0, 0.4.1, 0.4.0, 0.3.1, 0.3.0, 0.2.0, 0.1.1, and 0.1.0 are correct.

Overall, the changelog updates seem to accurately reflect the changes made in each version.

Runtime/ObjectPool.cs

No changes to review.

Tests/Editor/EditMode/CommandServiceTest.cs

No changes to review.

Tests/Editor/EditMode/ObjectPoolTest.cs

No changes to review.

Tests/Editor/EditMode/PoolServiceTest.cs

No changes to review.


/// <summary>
/// This interface allows to self despawn by maintaining the reference of the pool that created it
/// This interface allows to self despawn by maintaining the reference of the despawing call

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

The comment mentions "despawing call" instead of "pool that created it". Please update the comment to reflect the correct functionality.

- /// This interface allows to self despawn by maintaining the reference of the despawing call
+ /// This interface allows to self despawn by maintaining the reference of the pool that created it

Comment on lines 182 to 187
return false;
}

/// <inheritdoc />
public bool Despawn(bool onlyFirst, Func<T, bool> entityGetter)
{
var despawned = false;

for (var i = 0; i < SpawnedEntities.Count; i++)
{
if (!entityGetter(SpawnedEntities[i]))
{
continue;
}

despawned = Despawn(SpawnedEntities[i]);

if (onlyFirst)
{
break;
}
}

return despawned;
}

/// <inheritdoc />
public List<T> Clear()
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

The code has been simplified and refactored. It seems that the Despawn method has been moved to a different location in the class, and the logic for clearing the list of spawned entities has been extracted into a separate method called Clear. This change improves modularity and readability. No issues found.

- public bool Despawn(bool onlyFirst, Func<T, bool> entityGetter)
- {
-     var despawned = false;
-
-     for (var i = 0; i < SpawnedEntities.Count; i++)
-     {
-         if (!entityGetter(SpawnedEntities[i]))
-         {
-             continue;
-         }
-
-         despawned = Despawn(SpawnedEntities[i]);
-
-         if (onlyFirst)
-         {
-             break;
-         }
-     }
-
-     return despawned;
- }
 
+ /// <inheritdoc />
+ public List<T> Clear()
+ {
+     // implementation
+ }

Comment on lines +242 to +263
/// <inheritdoc />
public bool Despawn(bool onlyFirst, Func<T, bool> entityGetter)
{
var despawned = false;

for (var i = 0; i < SpawnedEntities.Count; i++)
{
if (!entityGetter(SpawnedEntities[i]))
{
continue;
}

despawned = Despawn(SpawnedEntities[i]);

if (onlyFirst)
{
break;
}
}

return despawned;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

The Despawn method has been updated with a new implementation. It now takes an additional parameter onlyFirst, which indicates whether only the first matching entity should be despawned. The logic for despawning entities based on the provided condition has been refactored. This change improves flexibility and performance. No issues found.

- public bool Despawn(bool onlyFirst, Func<T, bool> entityGetter)
- {
-     var despawned = false;
-
-     for (var i = 0; i < SpawnedEntities.Count; i++)
-     {
-         if (!entityGetter(SpawnedEntities[i]))
-         {
-             continue;
-         }
-
-         despawned = Despawn(SpawnedEntities[i]);
-
-         if (onlyFirst)
-         {
-             break;
-         }
-     }
-
-     return despawned;
- }
 
+ /// <inheritdoc />
+ public bool Despawn(bool onlyFirst, Func<T, bool> entityGetter)
+ {
+     // updated implementation
+ }

Comment on lines +359 to +362
public GameObjectPool(uint initSize, GameObject sampleEntity, Func<GameObject, GameObject> instantiator) : base(initSize, sampleEntity, instantiator)
{
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

A new constructor has been added to the GameObjectPool class. It accepts three parameters: initSize, sampleEntity, and instantiator. This change allows customization of the instantiator function used by the pool. No issues found.

- public GameObjectPool(uint initSize, GameObject sampleEntity, Func<GameObject, GameObject> instantiator) : base(initSize, sampleEntity, instantiator)
- {
- }
 
+ public GameObjectPool(uint initSize, GameObject sampleEntity, Func<GameObject, GameObject> instantiator) : base(initSize, sampleEntity, instantiator)
+ {
+     // implementation
+ }

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (7)
Tests/Editor/EditMode/CommandServiceTest.cs (1)

Line range hint 21-29: LGTM! Consider adding a comment explaining the class choice.

The change from struct to class for CommandMockup aligns well with the service's support for non-struct commands. This is a good change as commands typically maintain state and are passed around, making reference types more appropriate.

Consider adding a brief comment explaining why CommandMockup is implemented as a class rather than a struct, to help future maintainers understand the design decision:

+// Implemented as a class to align with CommandService's support for non-struct commands
 private class CommandMockup : IGameCommand<IGameLogicMockup>
Tests/Editor/EditMode/ObjectPoolTest.cs (1)

80-91: Resolve interface issue to enable EntityDespawn test

The commented test case appears to be blocking important verification of the EntityDespawn functionality. The test structure looks correct, using proper mocking and assertions.

I can help investigate and fix the interface issue. Would you like me to:

  1. Analyze the interface compatibility issue?
  2. Propose potential fixes?
  3. Create a GitHub issue to track this?

Please let me know which option you prefer.

CHANGELOG.md (2)

7-14: Fix typos in the new version entry

There are spelling and grammar issues in the changelog entry:

-Added a constructor to *GameObjectPool* that allows to setup a costum instantiator
+Added a constructor to *GameObjectPool* that allows to set up a custom instantiator
🧰 Tools
🪛 LanguageTool

[grammar] ~10-~10: The word “setup” is a noun. The verb is spelled with a space.
Context: ...ctor to GameObjectPool that allows to setup a costum instantiator

Fixed:

  • ...

(NOUN_VERB_CONFUSION)


Line range hint 38-160: Fix typos and formatting in historical entries

There are several spelling issues in the historical entries:

-Added *IRngData* to *PoolService* to suppprt read only data structure and allow abtract injection of data into other objects
+Added *IRngData* to *PoolService* to support read only data structure and allow abstract injection of data into other objects

-Changed *RngData* to a class in orther to avoid boxing/unboxing performance when injecting *IRngData*.
+Changed *RngData* to a class in order to avoid boxing/unboxing performance when injecting *IRngData*.

Also, ensure consistent formatting of emphasis markers throughout the changelog (no spaces inside asterisks).

Runtime/ObjectPool.cs (3)

47-47: Fix typo in documentation

There's a typo in the interface documentation: "despawing" should be "despawning".

-	/// This interface allows to self despawn by maintaining the reference of the despawing call
+	/// This interface allows to self despawn by maintaining the reference of the despawning call

242-263: Add parameter documentation

The method implementation looks good, but the XML documentation is missing details about the entityGetter parameter.

Add parameter documentation:

 		/// <summary>
 		/// Despawns the entity that is valid with the given <paramref name="entityGetter"/> condition and returns it back to
 		/// the pool to be used again later.
 		/// If the given <paramref name="onlyFirst"/> is true then will only despawn one entity and not find more entities
 		/// that match the given <paramref name="entityGetter"/> condition.
 		/// This function does not reset the entity. For that, have the entity implement <see cref="IPoolEntityDespawn"/>
 		/// or do it externally.
 		/// Returns true if was able to despawn the entity back to the pool successfully, false otherwise
 		/// </summary>
+		/// <param name="onlyFirst">If true, only the first matching entity will be despawned</param>
+		/// <param name="entityGetter">A function that returns true for entities that should be despawned</param>
 		public bool Despawn(bool onlyFirst, Func<T, bool> entityGetter)

359-361: Add constructor documentation

The new constructor needs XML documentation to explain its purpose and parameters.

Add constructor documentation:

+		/// <summary>
+		/// Initializes a new instance of the GameObjectPool with a custom instantiator
+		/// </summary>
+		/// <param name="initSize">The initial size of the pool</param>
+		/// <param name="sampleEntity">The sample GameObject to use as a template</param>
+		/// <param name="instantiator">A custom function to instantiate new GameObjects</param>
 		public GameObjectPool(uint initSize, GameObject sampleEntity, Func<GameObject, GameObject> instantiator) : base(initSize, sampleEntity, instantiator)
 		{
 		}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a0cb568 and 2201cc9.

📒 Files selected for processing (6)
  • CHANGELOG.md (6 hunks)
  • Runtime/ObjectPool.cs (3 hunks)
  • Tests/Editor/EditMode/CommandServiceTest.cs (1 hunks)
  • Tests/Editor/EditMode/ObjectPoolTest.cs (2 hunks)
  • Tests/Editor/EditMode/PoolServiceTest.cs (2 hunks)
  • package.json (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • Tests/Editor/EditMode/PoolServiceTest.cs
  • package.json
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[grammar] ~10-~10: The word “setup” is a noun. The verb is spelled with a space.
Context: ...ctor to GameObjectPool that allows to setup a costum instantiator

Fixed:

  • ...

(NOUN_VERB_CONFUSION)

🪛 Markdownlint
CHANGELOG.md

104-104: null
Spaces inside emphasis markers

(MD037, no-space-in-emphasis)

🔇 Additional comments (2)
Tests/Editor/EditMode/ObjectPoolTest.cs (2)

18-18: LGTM! Improved type safety in IMockEntity interface

The change from IPoolEntityObject<object> to IPoolEntityObject<IMockEntity> enhances type safety while maintaining flexibility with IPoolEntitySpawn<object>.


80-91: Verify test coverage for MockEntity

While the EntityDespawn test is commented out, we should ensure the MockEntity implementation is covered by other tests.

Comment on lines +19 to +30
public class MockEntity : IMockEntity
{
private IObjectPool<IMockEntity> _pool;

public void Init(IObjectPool<IMockEntity> pool) => _pool = pool;

public bool Despawn() => _pool.Despawn(this);
public void OnDespawn() {}

public void OnSpawn() {}
public void OnSpawn(object data) {}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add null check for _pool in Despawn method

The MockEntity implementation looks good overall, but the Despawn method should validate that _pool has been initialized to prevent NullReferenceException.

Consider adding a null check:

 public class MockEntity : IMockEntity
 {
     private IObjectPool<IMockEntity> _pool;

     public void Init(IObjectPool<IMockEntity> pool) => _pool = pool;

-    public bool Despawn() => _pool.Despawn(this);
+    public bool Despawn()
+    {
+        if (_pool == null)
+        {
+            throw new InvalidOperationException("Pool not initialized. Call Init before Despawn.");
+        }
+        return _pool.Despawn(this);
+    }
     public void OnDespawn()  {}

     public void OnSpawn() {}
     public void OnSpawn(object data) {}
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public class MockEntity : IMockEntity
{
private IObjectPool<IMockEntity> _pool;
public void Init(IObjectPool<IMockEntity> pool) => _pool = pool;
public bool Despawn() => _pool.Despawn(this);
public void OnDespawn() {}
public void OnSpawn() {}
public void OnSpawn(object data) {}
}
public class MockEntity : IMockEntity
{
private IObjectPool<IMockEntity> _pool;
public void Init(IObjectPool<IMockEntity> pool) => _pool = pool;
public bool Despawn()
{
if (_pool == null)
{
throw new InvalidOperationException("Pool not initialized. Call Init before Despawn.");
}
return _pool.Despawn(this);
}
public void OnDespawn() {}
public void OnSpawn() {}
public void OnSpawn(object data) {}
}

@CoderGamester CoderGamester merged commit dd2399d into master Nov 13, 2024
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 15, 2024
@coderabbitai coderabbitai bot mentioned this pull request Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants