private void ReadData(AttributeTypeID Type, NetIncomingMessage Message) { switch(Type) { case AttributeTypeID.Float: Data = Message.ReadFloat(); break; case AttributeTypeID.Int: Data = Message.ReadInt32(); break; case AttributeTypeID.List: Console.WriteLine("AttributeSystem: List<> Type not supported on network sync"); break; case AttributeTypeID.Long: Data = Message.ReadInt64(); break; case AttributeTypeID.Rectangle: Data = Message.ReadRectangle(); break; case AttributeTypeID.String: Data = Message.ReadString(); break; case AttributeTypeID.Vector2: Data = Message.ReadVector2(); break; case AttributeTypeID.Bool: Data = Message.ReadBoolean(); break; default: Console.WriteLine("Invalid Attribute Type: {0}", Type.ToString()); break; } }
public void WriteType(NetOutgoingMessage Message, AttributeTypeID Type, object Data) { switch (Type) { case AttributeTypeID.Float: Message.Write((float)Data); break; case AttributeTypeID.Int: Message.Write((int)Data); break; case AttributeTypeID.List: Console.WriteLine("Engine unable to serialize list objects"); break; case AttributeTypeID.Long: Message.Write((long)Data); break; case AttributeTypeID.Rectangle: Message.WriteRectangle((Rectangle)Data); break; case AttributeTypeID.String: Message.Write((string)Data); break; case AttributeTypeID.Vector2: Message.WriteVector2((Vector2)Data); break; case AttributeTypeID.Bool: Message.Write((bool)Data); break; default: Console.WriteLine("AttributeSystem Unrecognised Type In AttributeSystem Type: {0}", Type.ToString()); break; } }