PPos[] ProjectedCells(Actor self) { var map = self.World.Map; var range = Range; if (range == WDist.Zero) { return(NoCells); } if (Info.Type == VisibilityType.Footprint) { // PERF: Reuse collection to avoid allocations. footprint.UnionWith(self.OccupiesSpace.OccupiedCells() .SelectMany(kv => Shroud.ProjectedCellsInRange(map, kv.First, range, Info.MaxHeightDelta))); var cells = footprint.ToArray(); footprint.Clear(); return(cells); } var pos = self.CenterPosition; if (Info.Type == VisibilityType.GroundPosition) { pos -= new WVec(WDist.Zero, WDist.Zero, self.World.Map.DistanceAboveTerrain(pos)); } return(Shroud.ProjectedCellsInRange(map, pos, range, Info.MaxHeightDelta) .ToArray()); }
PPos[] ProjectedCells(Actor self) { var map = self.World.Map; var range = IsIdleRange(self) ? Range : info.MovingRange; if (range == WDist.Zero) { return(NoCells); } if (Info.Type == VisibilityType.Footprint) { return(self.OccupiesSpace.OccupiedCells() .SelectMany(kv => Shroud.ProjectedCellsInRange(map, kv.First, range, Info.MaxHeightDelta)) .Distinct().ToArray()); } var pos = self.CenterPosition; if (Info.Type == VisibilityType.GroundPosition) { pos -= new WVec(WDist.Zero, WDist.Zero, self.World.Map.DistanceAboveTerrain(pos)); } return(Shroud.ProjectedCellsInRange(map, pos, range, Info.MaxHeightDelta) .ToArray()); }
public override void Activate(Actor self, Order order, SupportPowerManager manager) { base.Activate(self, order, manager); self.World.AddFrameEndTask(w => { Shroud shround = self.Owner.Shroud; WPos destPosition = order.Target.CenterPosition; var cells = Shroud.ProjectedCellsInRange(self.World.Map, self.World.Map.CellContaining(destPosition), WDist.FromCells(info.Radius)); try { shround.AddSource(this, type, cells.ToArray()); } catch { shround.RemoveSource(this); shround.AddSource(this, type, cells.ToArray()); } shround.ExploreProjectedCells(self.World, cells); if (!string.IsNullOrEmpty(info.Sequence)) { string palette = null; if (info.Platte == "player") { palette = "player" + self.Owner.InternalName; } else { palette = info.Platte; } self.World.Add(new SpriteEffect(destPosition, self.World, info.Image, info.Sequence, palette)); } }); }
void IWorldLoaded.WorldLoaded(World world, WorldRenderer wr) { foreach (var p in world.Players) { if (!p.Playable) { continue; } if (p == world.LocalPlayer) { wr.Viewport.Center(world.Map.CenterOfCell(p.HomeLocation)); } var cells = Shroud.ProjectedCellsInRange(world.Map, p.HomeLocation, info.InitialExploreRange) .ToList(); foreach (var q in world.Players) { if (p.IsAlliedWith(q)) { q.Shroud.ExploreProjectedCells(world, cells); } } } }
PPos[] ProjectedCells(World world) { var map = world.Map; var range = revealRadius; if (range == WDist.Zero) { return(NoCells); } return(Shroud.ProjectedCellsInRange(map, pos, WDist.Zero, range).ToArray()); }
public void WorldLoaded(World world, WorldRenderer wr) { var spawns = world.Actors.Where(a => a.Info.Name == "mpspawn") .Select(a => a.Location) .ToArray(); var taken = world.LobbyInfo.Clients.Where(c => c.SpawnPoint != 0 && c.Slot != null) .Select(c => spawns[c.SpawnPoint - 1]).ToList(); var available = spawns.Except(taken).ToList(); // Set spawn foreach (var kv in world.LobbyInfo.Slots) { var player = FindPlayerInSlot(world, kv.Key); if (player == null) { continue; } var client = world.LobbyInfo.ClientInSlot(kv.Key); var spid = (client == null || client.SpawnPoint == 0) ? ChooseSpawnPoint(world, available, taken) : spawns[client.SpawnPoint - 1]; Start.Add(player, spid); player.SpawnPoint = (client == null || client.SpawnPoint == 0) ? spawns.IndexOf(spid) + 1 : client.SpawnPoint; } // Explore allied shroud var map = world.Map; foreach (var p in Start.Keys) { var cells = Shroud.ProjectedCellsInRange(map, Start[p], info.InitialExploreRange); foreach (var q in world.Players) { if (p.IsAlliedWith(q)) { q.Shroud.ExploreProjectedCells(world, cells); } } } // Set viewport if (world.LocalPlayer != null && Start.ContainsKey(world.LocalPlayer)) { wr.Viewport.Center(map.CenterOfCell(Start[world.LocalPlayer])); } }
PPos[] ProjectedCells(Actor self) { var map = self.World.Map; var range = Range; if (range == WDist.Zero) { return(NoCells); } if (info.Type == VisibilityType.Footprint) { return(self.OccupiesSpace.OccupiedCells() .SelectMany(kv => Shroud.ProjectedCellsInRange(map, kv.First, range)) .Distinct().ToArray()); } return(Shroud.ProjectedCellsInRange(map, self.CenterPosition, range) .ToArray()); }