SceneBoundaryDictionary - jimdroberts/FishMMO GitHub Wiki

Description

SceneBoundaryDictionary is a serializable dictionary for FishMMO that maps string keys to SceneBoundaryDetails. It provides logic to check if a point is contained in any boundary, enabling efficient management and lookup of multiple scene boundaries for gameplay and logic checks.


API Access

Methods

  • public bool PointContainedInBoundaries(Vector3 point)

    Checks if the given point is contained within any of the boundaries in the dictionary. Returns true if no boundaries are defined. Parameters: - Vector3 point: The point to check. Returns: bool. True if the point is inside any boundary, or if no boundaries exist; false otherwise. No exceptions are thrown.


Basic Usage

Setup

  1. Create a new SceneBoundaryDictionary instance.
  2. Add entries mapping string keys to SceneBoundaryDetails instances.
  3. Use the PointContainedInBoundaries method to check if a point is within any boundary.

Example

// Example 1: Adding boundaries to the dictionary
SceneBoundaryDictionary boundaryDict = new SceneBoundaryDictionary();
boundaryDict["Area1"] = new SceneBoundaryDetails { BoundaryOrigin = new Vector3(0, 0, 0), BoundarySize = new Vector3(10, 5, 10) };
boundaryDict["Area2"] = new SceneBoundaryDetails { BoundaryOrigin = new Vector3(20, 0, 0), BoundarySize = new Vector3(8, 5, 8) };

// Example 2: Checking if a point is inside any boundary
Vector3 point = new Vector3(2, 1, 3);
bool isInside = boundaryDict.PointContainedInBoundaries(point);

Best Practices

  • Use descriptive string keys for clarity and maintainability.
  • Store all relevant boundary data in SceneBoundaryDetails for each entry.
  • Use PointContainedInBoundaries for efficient area checks in gameplay logic.
  • Document the intended use and structure of the dictionary for future reference.
⚠️ **GitHub.com Fallback** ⚠️