예제 #1
0
        private static void ApplyAllHooks()
        {
            Debug.Log("Applying monkland");

            #region Entities
            AbstractPhysicalObjectHK.ApplyHook();
            CreatureHK.ApplyHook();
            PlayerGraphicsHK.ApplyHook();
            PlayerHK.ApplyHook();
            RockHK.ApplyHook();
            RoomHK.ApplyHook();
            SpearHK.ApplyHook();
            WeaponHK.ApplyHook();
            #endregion Entities

            #region Menus
            MainMenuHK.ApplyHook();
            HUDHK.ApplyHook();
            //RainMeterHK.ApplyHook();
            #endregion Menus

            #region OverWorld
            AbstractRoomHK.ApplyHook();
            OverWorldHK.ApplyHook();
            ShortcutHandlerHK.ApplyHook();
            #endregion OverWorld

            #region Others
            ProcessManagerHK.ApplyHook();
            RainWorldGameHK.ApplyHook();
            RainWorldHK.ApplyHook();
            #endregion Others
        }
예제 #2
0
 private static void SuckInCreatureHK(On.ShortcutHandler.orig_SuckInCreature orig, ShortcutHandler self, Creature creature, Room room, ShortcutData shortCut)
 {
     if (creature is Player)
     {
         room.PlaySound(SoundID.Player_Enter_Shortcut, creature.mainBodyChunk.pos);
         if (shortCut.shortCutType == ShortcutData.Type.RoomExit)
         {
             int cnt = room.abstractRoom.connections[shortCut.destNode];
             if (cnt > -1 && !AbstractPhysicalObjectHK.GetField(creature.abstractPhysicalObject).networkObject)
             {
                 room.world.ActivateRoom(room.world.GetAbstractRoom(cnt));
             }
         }
         if (shortCut.shortCutType == ShortcutData.Type.NPCTransportation && Array.IndexOf <IntVector2>(room.shortcutsIndex, creature.NPCTransportationDestination.Tile) > -1)
         {
             self.transportVessels.Add(new ShortcutHandler.ShortCutVessel(creature.NPCTransportationDestination.Tile, creature, room.abstractRoom, (int)Vector2.Distance(IntVector2.ToVector2(shortCut.DestTile), IntVector2.ToVector2(creature.NPCTransportationDestination.Tile))));
         }
         else
         {
             self.transportVessels.Add(new ShortcutHandler.ShortCutVessel(shortCut.StartTile, creature, room.abstractRoom, 0));
         }
         return;
     }
     orig(self, creature, room, shortCut);
 }
 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(AbstractPhysicalObjectHK.GetField(physicalObject).dist);
 }
예제 #4
0
        /*
         * public void PlayerKilled(ulong playerDead)
         * {
         *  MonklandSteamManager.DataPacket packet = MonklandSteamManager.instance.GetNewPacket(CHANNEL, UtilityHandler);
         *  BinaryWriter writer = MonklandSteamManager.instance.GetWriterForPacket(packet);
         *
         *  //Write message type
         *  writer.Write((byte)UtilMessageType.PlayerDead);
         *  writer.Write(playerDead);
         *
         *  MonklandSteamManager.instance.FinalizeWriterToPacket(writer, packet);
         *  MonklandSteamManager.instance.SendPacketToAll(packet, false, EP2PSend.k_EP2PSendReliable);
         *
         *  Debug.Log($"Writing packet: {packet.data}");
         * }
         */

        public void SendViolence(Creature self, BodyChunk source, Creature.DamageType type, float damage)
        {
            /*
             * Violence packet
             * packetType
             * damageType
             * sourceType (player/scav/lizard)
             * source ID
             */

            if (self == null || AbstractPhysicalObjectHK.GetField(self.abstractPhysicalObject).networkObject)
            {
                return;
            }

            // Source ID field
            MonklandSteamManager.DataPacket packet = MonklandSteamManager.instance.GetNewPacket(CHANNEL, UtilityHandler);
            BinaryWriter writer = MonklandSteamManager.instance.GetWriterForPacket(packet);

            // SourceTemplate
            byte sourceTemplate = byte.MaxValue - 1;

            try
            {
                sourceTemplate = (byte)(source.owner.abstractPhysicalObject as AbstractCreature).creatureTemplate.TopAncestor().type;
                //sourceTemplate = (byte)((source.owner as Creature).abstractCreature.creatureTemplate.type);
            }
            catch (Exception e) { Debug.Log("Error getting source type " + e.Message); }

            // SourceID
            ulong sourceID = 0;

            try
            {
                sourceID = (AbstractPhysicalObjectHK.GetField(source.owner.abstractPhysicalObject).owner);
            }
            catch { } //(Exception e) {/*Debug.Log()*/}

            // Message type
            writer.Write((byte)UtilMessageType.PlayerViolence);
            // Damage type
            writer.Write((byte)type);
            // Damage
            writer.Write((bool)(damage >= 1f));
            // Source Template
            writer.Write(sourceTemplate);
            // Source ID
            writer.Write(sourceID);

            MonklandSteamManager.Log($"[GameMNG] Sending Player Violence: Type {type}, damage {damage} Source Template {(CreatureTemplate.Type)sourceTemplate}, Source ID {sourceID}");
            MonklandSteamManager.instance.FinalizeWriterToPacket(writer, packet);
            MonklandSteamManager.instance.SendPacketToAll(packet, false, EP2PSend.k_EP2PSendReliable);
        }
예제 #5
0
 public static void Write(PhysicalObject target, ref BinaryWriter writer)
 {
     if (target == null)
     {
         writer.Write(false);
         return;
     }
     else
     {
         writer.Write(true);
     }
     writer.Write(AbstractPhysicalObjectHK.GetField(target.abstractPhysicalObject).dist);
 }
예제 #6
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!!
 }
예제 #7
0
        public static Creature ReadCreature(ref BinaryReader reader, Room room)
        {
            int      dist   = reader.ReadInt32();
            Creature target = null;

            foreach (AbstractCreature cr in room.abstractRoom.creatures)
            {
                if (AbstractPhysicalObjectHK.GetField(cr).dist == dist && cr.realizedCreature != null)
                {
                    target = cr.realizedCreature;
                }
            }
            return(target);
        }
예제 #8
0
 public void AddLabel(AbstractPhysicalObject player, string name, Color color)
 {
     try
     {
         if (!playerLabels.ContainsKey(AbstractPhysicalObjectHK.GetField(player).owner))
         {
             playerLabels.Add(AbstractPhysicalObjectHK.GetField(player).owner, new MUIPlayerTag(player, name, color, this));
         }
     }
     catch //(Exception e)
     {
         // Exception
         // Debug.Log("Playerlabel " + e);
     }
 }
예제 #9
0
        public static Creature ReadCreature(ref Creature creature, ref BinaryReader reader, Room room)
        {
            if (!reader.ReadBoolean())
            {
                return(null);
            }
            int dist = reader.ReadInt32();

            if (creature != null && creature.abstractPhysicalObject != null && AbstractPhysicalObjectHK.GetField(creature.abstractPhysicalObject).dist == dist)
            {
                return(creature);
            }
            Creature target = null;

            foreach (AbstractCreature cr in room.abstractRoom.creatures)
            {
                if (AbstractPhysicalObjectHK.GetField(cr).dist == dist && cr.realizedCreature != null)
                {
                    target = cr.realizedCreature;
                }
            }
            return(target);
        }
예제 #10
0
 private static void InGameClear()
 {
     AbstractPhysicalObjectHK.ClearFields();
     AbstractRoomHK.ClearField();
 }
예제 #11
0
 private void DisplayPlayerNames(RainWorldGame game)
 {
     if (trackedPlayer != null && currentRoom != null)
     {
         foreach (AbstractCreature cr in trackedPlayer.Room.creatures)
         {
             try
             {
                 // Player in the same room
                 if (cr.realizedCreature is Player p)
                 {
                     AbstractPhysicalObject player = cr.realizedCreature.abstractPhysicalObject;
                     string playerName             = SteamFriends.GetFriendPersonaName((CSteamID)AbstractPhysicalObjectHK.GetField(player).owner);
                     Color  color = MonklandSteamManager.GameManager.playerColors[MonklandSteamManager.connectedPlayers.IndexOf(AbstractPhysicalObjectHK.GetField(player).owner)];
                     (currentRoom.game.cameras[0].hud.parts.Find(x => x is MultiplayerHUD) as MultiplayerHUD).AddLabel(player, playerName, color);
                 }
             }
             catch (Exception e)
             {
                 // Throw exception
                 //Debug.LogException(e);
                 Debug.Log($"Error when trying to add label for Player" + e);
             }
         }
     }
 }
예제 #12
0
        public static PhysicalObject ReadPhysicalObject(ref BinaryReader reader, Room room)
        {
            int            dist   = reader.ReadInt32();
            PhysicalObject target = null;

            for (int i = 0; i < room.physicalObjects.Length; i++)
            {
                for (int j = 0; j < room.physicalObjects[i].Count; j++)
                {
                    if (room.physicalObjects[i][j] != null && room.physicalObjects[i][j].abstractPhysicalObject != null && AbstractPhysicalObjectHK.GetField(room.physicalObjects[i][j].abstractPhysicalObject).dist == dist)
                    {
                        target = room.physicalObjects[i][j];
                    }
                }
            }
            return(target);
        }