/* Thor Server 2.0 Project - Codenamed "Stockholm" Copyright 2008 - 2009 Joe Hegarty This file is part of The Thor Server 2.0 Project - Codenamed "Stockholm". The Thor Server 2.0 Project - Codenamed "Stockholm" is free software: you can redistribute it and/or modify it under the terms of the Microsoft Public License The Thor Server Project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Microsoft Public License for more details. You should have received a copy of the Microsoft Public License along with The Thor Server Project. If not, see http://www.opensource.org/licenses/ms-pl.html */ using System; using System.Collections.Generic; using StockholmLibrary.Net; using StockholmLibrary.Util; namespace StockholmLibrary.Game.Packets.Server { //------------------------------------ public class CreatureObject { public int ID = 0; public string Name = null; public string Figure = null; public IsometricPoint Location = new IsometricPoint(); public string Sex = null; public string Motto = null; public string Badge = null; public string PoolFigure = null; } //------------------------------------ public class UsersPacket : ServerPacket { List _creatures; //********************************************** public UsersPacket() { _packetType = EServerPacket.USERS; } //********************************************** public UsersPacket(CreatureObject creature) { _packetType = EServerPacket.USERS; _creatures = new List(); _creatures.Add(creature); } //********************************************** public UsersPacket(List creatures) { _packetType = EServerPacket.USERS; _creatures = creatures; } //********************************************** protected override void SerialiseBody() { if (_creatures != null) { foreach (var creature in _creatures) { SerialiseCreature(creature); } } } //********************************************** private void SerialiseCreature(CreatureObject creature) { WriteStringSet("i", creature.ID); WriteStringSet("n", creature.Name); if (creature.Figure != null) WriteStringSet("f", creature.Figure); WriteStringSet("l", creature.Location.ToCreatureLocationString()); if (creature.Sex != null) WriteStringSet("s", creature.Sex); if (creature.Motto != null) WriteStringSet("c", creature.Motto); if (creature.Badge != null) WriteStringSet("b", creature.Badge); if (creature.PoolFigure != null) WriteStringSet("p", creature.PoolFigure); } } }