public virtual void SharedGetVehiclesOnPlatform( IStaticWorldObject vehicleAssemblyBay, ITempList <IDynamicWorldObject> result) { var noObstaclesBounds = this.BoundsNoObstaclesTest; noObstaclesBounds = new BoundsDouble( offset: noObstaclesBounds.Offset + vehicleAssemblyBay.PhysicsBody.Position, size: noObstaclesBounds.Size); // test with different collision zones (required to handle hoverboards which don't have physical colliders) var defaultCollisionGroup = CollisionGroups.Default; CollectVehicles(defaultCollisionGroup); CollectVehicles(CollisionGroups.HitboxMelee); void CollectVehicles(CollisionGroup collisionGroup) { foreach (var testResult in vehicleAssemblyBay.PhysicsBody.PhysicsSpace.TestRectangle( position: noObstaclesBounds.Offset, size: noObstaclesBounds.Size, collisionGroup: collisionGroup).EnumerateAndDispose()) { if (testResult.PhysicsBody.AssociatedWorldObject is IDynamicWorldObject dynamicWorldObject && dynamicWorldObject.ProtoGameObject is IProtoVehicle) { result.AddIfNotContains(dynamicWorldObject); } } } }
private static void SharedGatherOccupiedAndNeighborTiles(IStaticWorldObject structure, ITempList <Tile> tempList) { // gather the occupied tiles and theirs direct neighbors foreach (var tile in structure.OccupiedTiles) { if (!tile.IsValidTile) { continue; } tempList.AddIfNotContains(tile); foreach (var neighborTile in tile.EightNeighborTiles) { if (neighborTile.IsValidTile) { tempList.AddIfNotContains(neighborTile); } } } }