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);
 }
Exemplo n.º 2
0
 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 AbstractWorldEntity Read(AbstractWorldEntity entity, ref BinaryReader reader)
 {
     entity.ID            = EntityIDHandler.Read(ref reader);
     entity.pos           = WorldCoordinateHandler.Read(ref reader);
     entity.InDen         = reader.ReadBoolean();
     entity.timeSpentHere = reader.ReadInt32();
     return(entity);
 }
Exemplo n.º 4
0
 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 AbstractPhysicalObject Read(AbstractPhysicalObject physicalObject, ref BinaryReader reader)
         * {
         *  physicalObject.ID = EntityIDHandler.Read(ref reader);
         *  physicalObject.pos = WorldCoordinateHandler.Read(ref reader);
         *  physicalObject.InDen = reader.ReadBoolean();
         *  physicalObject.timeSpentHere = reader.ReadInt32();
         *  physicalObject.type = (AbstractPhysicalObject.AbstractObjectType)reader.ReadByte();
         *  physicalObject.ID.number = reader.ReadInt32();
         *  physicalObject.destroyOnAbstraction = true;
         *  return physicalObject;
         * } */

        public static void Read(AbstractPhysicalObject physicalObject, ref BinaryReader reader)
        {
            physicalObject.ID                   = EntityIDHandler.Read(ref reader);
            physicalObject.pos                  = WorldCoordinateHandler.Read(ref reader);
            physicalObject.InDen                = reader.ReadBoolean();
            physicalObject.timeSpentHere        = reader.ReadInt32();
            physicalObject.type                 = (AbstractPhysicalObject.AbstractObjectType)reader.ReadByte();
            physicalObject.ID.number            = reader.ReadInt32();
            physicalObject.destroyOnAbstraction = true;
        }
Exemplo n.º 6
0
            public static AbstractCreatureAI Read(AbstractCreatureAI abstractCreatureAI, ref BinaryReader reader)
            {
                int numberOfNodes = reader.ReadInt32();

                abstractCreatureAI.path.Clear();
                for (int a = 0; a < numberOfNodes; a++)
                {
                    abstractCreatureAI.path.Add(WorldCoordinateHandler.Read(ref reader));
                }
                return(abstractCreatureAI);
            }
Exemplo n.º 7
0
 public static AbstractPhysicalObject Read(AbstractPhysicalObject physicalObject, ref BinaryReader reader)
 {
     physicalObject.ID            = EntityIDHandler.Read(ref reader);
     physicalObject.pos           = WorldCoordinateHandler.Read(ref reader);
     physicalObject.InDen         = reader.ReadBoolean();
     physicalObject.timeSpentHere = reader.ReadInt32();
     physicalObject.type          = (AbstractPhysicalObject.AbstractObjectType)reader.ReadByte();
     (physicalObject as Patches.patch_AbstractPhysicalObject).dist = reader.ReadInt32();
     physicalObject.destroyOnAbstraction = true;
     return(physicalObject);
 }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
 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!!
 }
Exemplo n.º 10
0
 public static void Read(Creature creature, ref BinaryReader reader)
 {
     AbstractCreatureHandler.Read(creature, ref reader);
     PhysicalObjectHandler.Read(creature, ref reader);
     //creature.blind = reader.ReadInt32();
     CreatureHK.Sync(creature, reader.ReadBoolean());
     creature.enteringShortCut             = IntVector2NHandler.Read(ref reader);
     creature.lastCoord                    = WorldCoordinateHandler.Read(ref reader);
     creature.leechedOut                   = reader.ReadBoolean();
     creature.newToRoomInvinsibility       = reader.ReadInt32();
     creature.NPCTransportationDestination = WorldCoordinateHandler.Read(ref reader);
     creature.shortcutDelay                = reader.ReadInt32();
     // return creature;
 }
Exemplo n.º 11
0
 public static Creature Read(Creature creature, ref BinaryReader reader)
 {
     creature.abstractPhysicalObject = AbstractCreatureHandler.Read(creature.abstractCreature, ref reader);
     creature = PhysicalObjectHandler.Read(creature, ref reader);
     //creature.blind = reader.ReadInt32();
     (creature as Patches.patch_Player).Sync(reader.ReadBoolean());
     creature.enteringShortCut             = IntVector2NHandler.Read(ref reader);
     creature.lastCoord                    = WorldCoordinateHandler.Read(ref reader);
     creature.leechedOut                   = reader.ReadBoolean();
     creature.newToRoomInvinsibility       = reader.ReadInt32();
     creature.NPCTransportationDestination = WorldCoordinateHandler.Read(ref reader);
     creature.shortcutDelay                = reader.ReadInt32();
     return(creature);
 }
Exemplo n.º 12
0
 public static void Read(AbstractCreature creature, ref BinaryReader reader)
 {
     creature.ID            = EntityIDHandler.Read(ref reader);
     creature.pos           = WorldCoordinateHandler.Read(ref reader);
     creature.InDen         = reader.ReadBoolean();
     creature.timeSpentHere = reader.ReadInt32();
     //creature.type = (AbstractPhysicalObject.AbstractObjectType)reader.ReadByte();
     creature.ID.number            = reader.ReadInt32();
     creature.destroyOnAbstraction = true;
     //creature.abstractAI = AbstractCreatureAIHandler.Read(creature.abstractAI, ref reader);
     //Additional personality and relationship traits should be synced here!
     creature.remainInDenCounter = reader.ReadInt32();
     creature.spawnDen           = WorldCoordinateHandler.Read(ref reader);
     //creature state should also be synced here!!
     //return creature;
 }
Exemplo n.º 13
0
        public void ReadPlayer(BinaryReader br, CSteamID sentPlayer)
        {
            if (!MonklandSteamManager.WorldManager.gameRunning)
            {
                return;
            }
            string roomName = br.ReadString();//Read Room Name

            if (!MonklandSteamManager.WorldManager.commonRooms.ContainsKey(roomName))
            {
                return;
            }
            AbstractRoom abstractRoom = patch_RainWorldGame.mainGame.world.GetAbstractRoom(roomName);

            if (abstractRoom == null || abstractRoom.realizedRoom == null)
            {
                return;
            }
            int             dist     = br.ReadInt32();                      // Read Disinguisher
            WorldCoordinate startPos = WorldCoordinateHandler.Read(ref br); // Read World Coordinate

            foreach (AbstractCreature cr in abstractRoom.creatures)
            {
                if (((cr as AbstractPhysicalObject) as patch_AbstractPhysicalObject).dist == dist && cr.realizedCreature != null)
                {
                    cr.realizedCreature = PlayerHandler.Read((cr.realizedCreature as Player), ref br);// Read Player
                    cr.pos.room         = abstractRoom.index;
                    return;
                }
            }
            startPos.room         = abstractRoom.index;
            startPos.abstractNode = -1;
            AbstractCreature abstractCreature = new AbstractCreature(patch_RainWorldGame.mainGame.world, StaticWorld.GetCreatureTemplate("Slugcat"), null, startPos, new EntityID(-1, 1));

            abstractCreature.state = new PlayerState(abstractCreature, 1, 0, false);
            ((abstractCreature as AbstractPhysicalObject) as patch_AbstractPhysicalObject).dist  = dist;
            ((abstractCreature as AbstractPhysicalObject) as patch_AbstractPhysicalObject).owner = sentPlayer.m_SteamID;
            abstractCreature.pos.room = abstractRoom.index;
            patch_RainWorldGame.mainGame.world.GetAbstractRoom(abstractCreature.pos.room).AddEntity(abstractCreature);
            abstractCreature.RealizeInRoom();
            abstractCreature.realizedCreature = PlayerHandler.Read((abstractCreature.realizedCreature as Player), ref br);// Read Player
            abstractCreature.pos.room         = abstractRoom.index;
        }
Exemplo n.º 14
0
        public static Player Read(Player creature, ref BinaryReader reader)
        {
            creature.abstractPhysicalObject = AbstractCreatureHandler.Read(creature.abstractCreature, ref reader);
            creature = PhysicalObjectHandler.Read(creature, ref reader);
            //creature.blind = reader.ReadInt32();
            (creature as Patches.patch_Player).Sync(reader.ReadBoolean());
            creature.enteringShortCut             = IntVector2NHandler.Read(ref reader);
            creature.lastCoord                    = WorldCoordinateHandler.Read(ref reader);
            creature.leechedOut                   = reader.ReadBoolean();
            creature.newToRoomInvinsibility       = reader.ReadInt32();
            creature.NPCTransportationDestination = WorldCoordinateHandler.Read(ref reader);
            creature.shortcutDelay                = reader.ReadInt32();

            /*int len = reader.ReadInt32();
             * for (int i = 0; i < len; i++)
             * {
             *  if (i < creature.grasps.Length && creature.grasps[i] != null)
             *  {
             *      creature.grasps[i] = GraspHandler.Read(ref creature.grasps[i], creature, ref reader, creature.room);
             *  }
             *  else
             *  {
             *      Creature.Grasp grasp = GraspHandler.Read(creature, ref reader, creature.room);
             *      if (i < creature.grasps.Length && grasp != null && grasp.grabbed != null && grasp.grabber != null)
             *      {
             *          MonklandSteamManager.Log("Grabbed Rock!");
             *          (creature as Player).switchHandsCounter = 0;
             *          ((creature as Player) as patch_Player).setWantToPickUp(0);
             *          (creature as Player).noPickUpOnRelease = 20;
             *          if (creature.grasps[i] != null)
             *          {
             *              creature.ReleaseGrasp(i);
             *          }
             *          creature.grasps[i] = new Creature.Grasp(creature, grasp.grabbed, i, grasp.chunkGrabbed, grasp.shareability, grasp.dominance, grasp.pacifying);
             *          grasp.grabbed.Grabbed(creature.grasps[i]);
             *          new AbstractPhysicalObject.CreatureGripStick(creature.abstractCreature, grasp.grabbed.abstractPhysicalObject, i, grasp.pacifying);
             *      }
             *  }
             * }*/
            return(creature);
        }
Exemplo n.º 15
0
        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);
            }
        }