Beispiel #1
0
        public void WorldLoaded(World world, WorldRenderer wr)
        {
            var spawns = world.Map.SpawnPoints.Value;
            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.CellsInRange(map, Start[p], info.InitialExploreRange);
                foreach (var q in world.Players)
                {
                    if (p.IsAlliedWith(q))
                    {
                        q.Shroud.Explore(world, cells);
                    }
                }
            }

            // Set viewport
            if (world.LocalPlayer != null && Start.ContainsKey(world.LocalPlayer))
            {
                wr.Viewport.Center(map.CenterOfCell(Start[world.LocalPlayer]));
            }
        }
Beispiel #2
0
        CPos[] Cells(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.CellsInRange(map, kv.First, range))
                       .Distinct().ToArray());
            }

            return(Shroud.CellsInRange(map, self.CenterPosition, range)
                   .ToArray());
        }