SceneBoundaryDictionary - jimdroberts/FishMMO GitHub Wiki
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.
-
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.
- Create a new SceneBoundaryDictionary instance.
- Add entries mapping string keys to SceneBoundaryDetails instances.
- Use the PointContainedInBoundaries method to check if a point is within any boundary.
// 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);
- 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.