public override void WriteToBuffer(NetOutgoingMessage buffer) { buffer.Write((byte)Type); switch (Type) { case EntityMessage.SystemMessage: ISS14Serializer serializer = IoCManager.Resolve <ISS14Serializer>(); using (var stream = new MemoryStream()) { serializer.Serialize(stream, SystemMessage); buffer.Write((int)stream.Length); buffer.Write(stream.ToArray()); } break; case EntityMessage.ComponentMessage: buffer.Write(EntityId); buffer.Write(NetId); PackParams(buffer, Parameters); break; } }
public override void ReadFromBuffer(NetIncomingMessage buffer) { Type = (EntityMessage)buffer.ReadByte(); Sender = buffer.SenderConnection; switch (Type) { case EntityMessage.SystemMessage: ISS14Serializer serializer = IoCManager.Resolve <ISS14Serializer>(); int messageLength = buffer.ReadInt32(); using (var stream = new MemoryStream(buffer.ReadBytes(messageLength))) { SystemMessage = serializer.Deserialize <EntitySystemMessage>(stream); } break; case EntityMessage.ComponentMessage: EntityId = buffer.ReadInt32(); NetId = buffer.ReadUInt32(); Parameters = UnPackParams(buffer); break; } }
public void Startup() { LastUpdate = DateTime.Now; Now = DateTime.Now; _cleanupList = new List<RenderImage>(); _cleanupSpriteList = new List<Sprite>(); UserInterfaceManager.DisposeAllComponents(); //Init serializer serializer = IoCManager.Resolve<ISS14Serializer>(); _entityManager = new EntityManager(NetworkManager); IoCManager.Resolve<IEntityManagerContainer>().EntityManager = _entityManager; IoCManager.Resolve<IMapManager>().TileChanged += OnTileChanged; IoCManager.Resolve<IPlayerManager>().OnPlayerMove += OnPlayerMove; NetworkManager.MessageArrived += NetworkManagerMessageArrived; NetworkManager.RequestMap(); // TODO This should go somewhere else, there should be explicit session setup and teardown at some point. NetworkManager.SendClientName(ConfigurationManager.GetPlayerName()); // Create new _gaussianBlur = new GaussianBlur(ResourceManager); _realScreenWidthTiles = (float)CluwneLib.Screen.Size.X / MapManager.TileSize; _realScreenHeightTiles = (float)CluwneLib.Screen.Size.Y / MapManager.TileSize; InitializeRenderTargets(); InitializeSpriteBatches(); InitalizeLighting(); InitializeGUI(); }