static void Outgoing() { foreach (NetConnection connection in Server.Connections) { if (connection.Tag == null) { continue; } Soul soul = (Soul)connection.Tag; if (soul.currentShip != null) { soul.currentShip.SendStatus(connection); soul.currentSector.SendUpdate(connection); } } }
public void HandleData(NetIncomingMessage msg) { NetMsgType datatype = (NetMsgType)msg.ReadByte(); if (datatype == NetMsgType.Control) { Soul soul = (Soul)msg.SenderConnection.Tag; var key = (ControlKey)msg.ReadByte(); var edge = msg.ReadBoolean(); //Console.WriteLine("Received Control Message: " + key + (edge ? "Pressed" : "Released")); soul.currentShip.Controls.ReceiveMessage(key, edge); } else if (datatype == NetMsgType.ControlUpdate) { Soul soul = (Soul)msg.SenderConnection.Tag; var Pitch = msg.ReadFloat(); var Yaw = msg.ReadFloat(); var Roll = msg.ReadFloat(); soul.currentShip.Controls.ReceiveMessage(Pitch, Yaw, Roll); } else if (datatype == NetMsgType.ShipDataOutput) { ShipDataOutputMessage data; data = new ShipDataOutputMessage(msg); Soul soul = new Soul(msg.SenderConnection); soul.currentSector = Sector.Redria; msg.SenderConnection.Tag = soul; soul.currentSector.Terrain.Load(msg.SenderConnection); soul.currentSector.Ships.Load(msg.SenderConnection); soul.currentSector.Objects.Load(msg.SenderConnection); var idRandomizer = new Random(); var NewShip = new ShipObj(new Vector3(0, 100, 2), Quaternion.Identity, data.GeneratedData); soul.currentShip = NewShip; NewShip.Client = soul; //Console.WriteLine(msg.SenderEndpoint.Address + "'s Ship ID: " + NewShip.ID); foreach (NetConnection c in Network.Server.Connections) { MessageWriter.ClientEntityCreationMessage(c, NewShip.ID, NewShip.Position, NewShip.Orientation, data.GeneratedData.NoseID, data.GeneratedData.CoreID, data.GeneratedData.EngineID, data.Weapons, msg.SenderConnection.RemoteUniqueIdentifier); } } }