public void CheckIfEntitiesStillExists() { if (RedTeamGoal != null && RedTeamGoal.IsLingering()) { RedTeamGoal = null; } if (BlueTeamGoal != null && BlueTeamGoal.IsLingering()) { BlueTeamGoal = null; } if (Center != null && Center.IsLingering()) { Center = null; } }
public void ScanSurroundings() { Console.WriteLine("Scanning area."); var facade = ServerContext.VillageDirector.UniverseFacade; var low = ScanCentre - Region; var high = ScanCentre + Region; var size = high - low + Vector3I.One; var tiles = Allocator.TileAllocator.Allocate(size.Volume()); if (facade.ReadTileRegion(low, size, tiles, TileAccessFlags.None)) { var i = 0; for (var y = ScanCentre.Y - Region.Y; y <= ScanCentre.Y + Region.Y; ++y) { for (var z = ScanCentre.Z - Region.Z; z <= ScanCentre.Z + Region.Z; ++z) { for (var x = ScanCentre.X - Region.X; x <= ScanCentre.X + Region.X; ++x) { var pos = new Vector3I(x, y, z); var t = tiles[i]; i++; if (t.Configuration.Open || t.Configuration.CompoundFiller) { continue; } if (t.Configuration.Code == "mods.Deamon.Soccer.tile.RedGoal") { TileStateEntityLogic tse; if (facade.TryFetchTileStateEntityLogic(pos, TileAccessFlags.None, out tse)) { Console.WriteLine("Claiming Red Goal."); var goal = tse as SoccerGoalTileStateEntityLogic; goal.Team = 0; goal.Totem = this; RedTeamGoal = goal; } } else if (t.Configuration.Code == "mods.Deamon.Soccer.tile.BlueGoal") { TileStateEntityLogic tse; if (facade.TryFetchTileStateEntityLogic(pos, TileAccessFlags.None, out tse)) { Console.WriteLine("Claiming Blue Goal."); var goal = tse as SoccerGoalTileStateEntityLogic; goal.Team = 1; goal.Totem = this; BlueTeamGoal = goal; } } else if (t.Configuration.Code == "mods.Deamon.Soccer.tile.Center") { TileStateEntityLogic tse; if (facade.TryFetchTileStateEntityLogic(pos, TileAccessFlags.None, out tse)) { Console.WriteLine("Claiming Center."); var center = tse as CenterTileStateEntityLogic; center.Totem = this; Center = center; } } if (IsReady()) { BlueTeamScore = 0; RedTeamScore = 0; _gameStarted = false; } } } } Allocator.TileAllocator.Release(ref tiles); } }