void SendActiveZombieList(ViewServer sender, ViewServer.Client cl) { if (sender == null) { return; } lock (_activeZombies) { var list = new List <Viewer.DataZombie>(); foreach (var zombie in _activeZombies) { Vector2i p = WorldToBitmap(zombie.pos); list.Add(new Viewer.DataZombie { id = zombie.id, x = p.x, y = p.y, }); } var data = new Viewer.ZombieList(); data.list = list; sender.SendData(cl, Viewer.DataType.ActiveZombies, data); } }
void SendStaticState(ViewServer sender, ViewServer.Client cl) { lock (sender) { SendState(sender, cl); SendWorldZones(sender, cl); SendPOIZones(sender, cl); } }
void SendPlayerZones(ViewServer sender, ViewServer.Client cl) { if (sender == null) { return; } var data = new Viewer.PlayerZones(); data.zones = _playerZones.GetSerializable(this); sender.SendData(cl, Viewer.DataType.PlayerZones, data); }
void SendWorldZones(ViewServer sender, ViewServer.Client cl) { if (sender == null) { return; } var data = new Viewer.WorldZones() { zones = _worldZones.GetSerializable(this) }; sender.SendData(cl, Viewer.DataType.WorldZones, data); }
void SendPOIZones(ViewServer sender, ViewServer.Client cl) { if (sender == null) { return; } var zones = _pois.GetSerializable(this); if (zones.Count == 0) { return; } var data = new Viewer.POIZones(); data.zones = zones; sender.SendData(cl, Viewer.DataType.POIZones, data); }
void SendState(ViewServer sender, ViewServer.Client cl) { if (sender == null) { return; } var data = new Viewer.State(); data.w = 512; data.h = 512; data.mapW = Utils.Distance(_worldMins.x, _worldMaxs.x); data.mapH = Utils.Distance(_worldMins.z, _worldMaxs.z); data.density = Config.Instance.PopulationDensity; data.zombieSpeed = _state.ZombieSpeed; data.timescale = _state.Timescale; sender.SendData(cl, Viewer.DataType.Info, data); }
void OnClientConnected(ViewServer sender, ViewServer.Client cl) { SendStaticState(sender, cl); }