public static Message Decode(UDPPacket p) { var m = new CoarseLocationUpdate(); uint cnt = p.ReadUInt8(); for (uint i = 0; i < cnt; ++i) { m.AgentData.Add(new AgentDataEntry { X = p.ReadUInt8(), Y = p.ReadUInt8(), Z = p.ReadUInt8() }); } m.You = p.ReadInt16(); m.Prey = p.ReadInt16(); cnt = p.ReadUInt8(); for (int i = 0; i < cnt; ++i) { var e = m.AgentData[i]; e.AgentID = p.ReadUUID(); m.AgentData[i] = e; } return(m); }
public static Message DeserializeEQG(IValue value) { var m = (MapType)value; var index = (MapType)((AnArray)m["Index"])[0]; var location = (AnArray)m["Location"]; var agentdata = (AnArray)m["AgentData"]; int n = Math.Min(agentdata.Count, location.Count); var res = new CoarseLocationUpdate { Prey = (short)index["Prey"].AsInt, You = (short)index["You"].AsInt }; for (int i = 0; i < n; ++i) { var l = (MapType)location[i]; var a = (MapType)agentdata[i]; res.AgentData.Add(new AgentDataEntry { X = l["X"].AsInt, Y = l["Y"].AsInt, Z = l["Z"].AsInt, AgentID = a["AgentID"].AsUUID }); } return(res); }