IBoundary - jimdroberts/FishMMO GitHub Wiki

Description

IBoundary is an abstract MonoBehaviour for FishMMO that defines the contract for scene boundaries. It provides abstract methods to get the offset and size of the boundary, enabling custom implementations for different types of scene boundaries in the game world.


API Access

Methods

  • public abstract Vector3 GetBoundaryOffset()

    Gets the offset of the boundary from the object's position. Returns: Vector3. The offset vector for the boundary. No exceptions are thrown by default, but implementations may throw as needed.

  • public abstract Vector3 GetBoundarySize()

    Gets the size of the boundary. Returns: Vector3. The size vector of the boundary. No exceptions are thrown by default, but implementations may throw as needed.


Basic Usage

Setup

  1. Create a new class that derives from IBoundary and implement the GetBoundaryOffset and GetBoundarySize methods.
  2. Attach the derived component to a GameObject to define a custom scene boundary.

Example

// Example 1: Creating a custom boundary
public class BoxBoundary : IBoundary
{
    public override Vector3 GetBoundaryOffset() => new Vector3(0, 0, 0);
    public override Vector3 GetBoundarySize() => new Vector3(10, 1, 10);
}

// Example 2: Using the boundary in code
Vector3 offset = myBoundary.GetBoundaryOffset();
Vector3 size = myBoundary.GetBoundarySize();

Best Practices

  • Always implement both GetBoundaryOffset and GetBoundarySize for consistent boundary behavior.
  • Use derived classes to represent different types of scene boundaries (e.g., box, sphere, custom shapes).
  • Document the purpose and configuration of each boundary for maintainability.
⚠️ **GitHub.com Fallback** ⚠️