public static void Write(AbstractWorldEntity entity, ref BinaryWriter writer) { EntityIDHandler.Write(entity.ID, ref writer); WorldCoordinateHandler.Write(entity.pos, ref writer); writer.Write(entity.InDen); writer.Write(entity.timeSpentHere); }
public static void Write(AbstractCreatureAI abstractCreatureAI, ref BinaryWriter writer) { writer.Write(abstractCreatureAI.path.Count); for (int a = 0; a < abstractCreatureAI.path.Count; a++) { WorldCoordinateHandler.Write(abstractCreatureAI.path[a], ref writer); } }
public static void Write(AbstractPhysicalObject physicalObject, ref BinaryWriter writer) { EntityIDHandler.Write(physicalObject.ID, ref writer); WorldCoordinateHandler.Write(physicalObject.pos, ref writer); writer.Write(physicalObject.InDen); writer.Write(physicalObject.timeSpentHere); writer.Write((byte)physicalObject.type); writer.Write((physicalObject as Patches.patch_AbstractPhysicalObject).dist); }
public static void Write(Creature creature, ref BinaryWriter writer) { AbstractCreatureHandler.Write(creature.abstractCreature, ref writer); PhysicalObjectHandler.Write(creature, ref writer); //writer.Write(creature.blind); writer.Write(creature.dead); IntVector2NHandler.Write(creature.enteringShortCut, ref writer); WorldCoordinateHandler.Write(creature.lastCoord, ref writer); writer.Write(creature.leechedOut); writer.Write(creature.newToRoomInvinsibility); WorldCoordinateHandler.Write(creature.NPCTransportationDestination, ref writer); writer.Write(creature.shortcutDelay); }
public static void Write(AbstractCreature creature, ref BinaryWriter writer) { EntityIDHandler.Write(creature.ID, ref writer); WorldCoordinateHandler.Write(creature.pos, ref writer); writer.Write(creature.InDen); writer.Write(creature.timeSpentHere); //writer.Write((byte)creature.type); writer.Write(AbstractPhysicalObjectHK.GetField(creature).dist); //AbstractCreatureAIHandler.Write(creature.abstractAI, ref writer); //Additional personality and relationship traits should be synced here! writer.Write(creature.remainInDenCounter); WorldCoordinateHandler.Write(creature.spawnDen, ref writer); //creature state should also be synced here!! }
public void Send(PhysicalObject physicalObject, List <ulong> targets) { try { if (physicalObject == null || targets == null || targets.Count == 0 || physicalObject.room == null || physicalObject.room.abstractRoom == null) { return; } MonklandSteamManager.DataPacket packet = MonklandSteamManager.instance.GetNewPacket(CHANNEL, UtilityHandler); BinaryWriter writer = MonklandSteamManager.instance.GetWriterForPacket(packet); if ((physicalObject as PhysicalObject) is Player) { writer.Write((byte)PacketType.Player); writer.Write(physicalObject.room.abstractRoom.name); writer.Write((physicalObject.abstractPhysicalObject as patch_AbstractPhysicalObject).dist); WorldCoordinateHandler.Write(physicalObject.abstractPhysicalObject.pos, ref writer); PlayerHandler.Write(physicalObject as PhysicalObject as Player, ref writer); } else { return; } MonklandSteamManager.instance.FinalizeWriterToPacket(writer, packet); foreach (ulong target in targets) { if (MonklandSteamManager.WorldManager.ingamePlayers.Contains(target)) { if (target != playerID) { MonklandSteamManager.instance.SendPacket(packet, (CSteamID)target, EP2PSend.k_EP2PSendUnreliableNoDelay); } } } }catch (Exception e) { Debug.LogError(e); } }