예제 #1
0
        public void askChat(CSteamID steamID, byte mode, string text)
        {
            // Set the variables
            bool           cancel = false;
            UnturnedPlayer player = UnturnedPlayer.Get(steamID);

            // Run methods
            ChatEvents.RunChatted(ref player, ref mode, ref text, ref cancel);

            // Do checks
            if (player?.SteamID == null || player.SteamID == CSteamID.Nil)
            {
                return;
            }
            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            if (cancel)
            {
                return;
            }

            // Restore original
            DetourManager.CallOriginal(typeof(CM).GetMethod("askChat", BindingFlags.Public | BindingFlags.Instance), CM.instance, player.SteamID, mode, text);
        }
예제 #2
0
        public static void askRepair(this Barricade barricade, ushort amount)
        {
            // Set the variables
            bool cancel = false;

            // Run the events
            BarricadeEvents.RunBarricadeRepair(UnturnedBarricade.FindBarricade(barricade), ref amount, ref cancel);

            // Run the original function
            if (!cancel)
            {
                DetourManager.CallOriginal(typeof(Barricade).GetMethod("askRepair", BindingFlags.Instance | BindingFlags.Public), barricade, amount);
            }
        }
        public static void askRepair(this InteractableVehicle Vehicle, ushort amount)
        {
            if (amount == 0 || Vehicle.isExploded)
            {
                return;
            }

            UnturnedVehicle vehicle = UnturnedServer.Vehicles.FirstOrDefault(v => v.InstanceID == Vehicle.instanceID);

            VehicleEvents.RunVehicleRepair(vehicle, amount);

            DetourManager.CallOriginal(typeof(InteractableVehicle).GetMethod("askRepair", BindingFlags.Public | BindingFlags.Instance),
                                       Vehicle, amount);
        }
예제 #4
0
        public static void askRepair(this Structure stru, ushort amount)
        {
            // Set the events
            bool cancel = false;

            // Run the events
            StructureEvents.RunRepairStructure(UnturnedStructure.FindStructure(stru), ref amount, ref cancel);

            // Run the original function
            if (!cancel)
            {
                DetourManager.CallOriginal(typeof(Structure).GetMethod("askRepair", BindingFlags.Instance | BindingFlags.Public), stru, amount);
            }
        }
예제 #5
0
        public void tellVehicleDestroy(CSteamID steamID, uint instanceID)
        {
            if (VehicleManager.instance.channel.checkServer(steamID))
            {
                InteractableVehicle vehicle = VehicleManager.vehicles.FirstOrDefault(a => a.instanceID == instanceID);

                if (vehicle == null)
                {
                    return;
                }

                ServerEvents.RunVehicleRemoved(vehicle);
            }

            DetourManager.CallOriginal(typeof(VehicleManager).GetMethod("tellVehicleDestroy", BindingFlags.Instance | BindingFlags.Public), VehicleManager.instance, steamID, instanceID);
        }
예제 #6
0
        public void askSalvageBarricade(CSteamID steamID, byte x, byte y, ushort plant, ushort index)
        {
            BarricadeRegion barricadeRegion;
            bool            cancel = false;

            if (BarricadeManager.tryGetRegion(x, y, plant, out barricadeRegion))
            {
                BarricadeData data = barricadeRegion.barricades[(int)index];

                BarricadeEvents.RunBarricadeSalvage(UnturnedBarricade.Create(data), ref cancel);
            }

            if (!cancel)
            {
                DetourManager.CallOriginal(typeof(BarricadeManager).GetMethod("askSalvageBarricade", BindingFlags.Public | BindingFlags.Instance), BarricadeManager.instance, steamID, x, y, plant, index);
            }
        }
        public void askSalvageStructure(CSteamID steamID, byte x, byte y, ushort index)
        {
            StructureRegion structureRegion;
            bool            cancel = false;

            if (StructureManager.tryGetRegion(x, y, out structureRegion))
            {
                StructureData data = structureRegion.structures[(int)index];

                StructureEvents.RunSalvageStructure(UnturnedStructure.Create(data), ref cancel);
            }

            if (!cancel)
            {
                DetourManager.CallOriginal(typeof(StructureManager).GetMethod("askSalvageStructure", BindingFlags.Instance | BindingFlags.Public), StructureManager.instance, steamID, x, y, index);
            }
        }
        public static void tellSkill(this PlayerSkills Skills, CSteamID steamID, byte speciality, byte index, byte level)
        {
            if (!Skills.channel.checkServer(steamID))
            {
                return;
            }
            if (index >= Skills.skills[speciality].Length)
            {
                return;
            }

            UnturnedPlayer Player = UnturnedPlayer.Get(Skills.player);

            PlayerEvents.RunPlayerSkillUpgrade(Player, speciality, index, level);

            DetourManager.CallOriginal(typeof(PlayerSkills).GetMethod("tellSkill", BindingFlags.Instance | BindingFlags.Public),
                                       Skills, steamID, speciality, index, level);
        }
        public static void askDamageTire(this InteractableVehicle Vehicle, int index)
        {
            if (index < 0)
            {
                return;
            }

            if (Vehicle.asset != null && !Vehicle.asset.canTiresBeDamaged)
            {
                return;
            }

            UnturnedVehicle UVehicle = UnturnedServer.Vehicles.FirstOrDefault(vehicle => vehicle.InstanceID == Vehicle.instanceID);

            VehicleEvents.RunVehicleTireDamage(UVehicle, index);

            DetourManager.CallOriginal(typeof(InteractableVehicle).GetMethod("askDamageTire", BindingFlags.Public | BindingFlags.Instance), Vehicle, index);
        }
예제 #10
0
        private static void doDamage(this PlayerLife life, byte amount, Vector3 newRagdoll, EDeathCause newCause, ELimb newLimb, CSteamID newKiller, out EPlayerKill kill)
        {
            UnturnedPlayer ply    = UnturnedPlayer.Get(newKiller);
            bool           cancel = false;

            kill = EPlayerKill.NONE;

            PlayerEvents.RunPlayerHurt(life.channel.owner, ref amount, ref newCause, ref newLimb, ref ply, ref cancel);

            if (cancel)
            {
                return;
            }

            object[] paramaters = new object[] { amount, newRagdoll, newCause, newLimb, newKiller, null };
            DetourManager.CallOriginal(typeof(PlayerLife).GetMethod("doDamage", BindingFlags.NonPublic | BindingFlags.Instance), life, paramaters);
            kill = (EPlayerKill)paramaters[5];
        }
예제 #11
0
        public void tellExitVehicle(CSteamID steamID, uint instanceID, byte seat, Vector3 point, byte angle, bool forceUpdate)
        {
            if (!VehicleManager.instance.channel.checkServer(steamID))
            {
                return;
            }

            for (int i = 0; i < VehicleManager.vehicles.Count; i++)
            {
                if (VehicleManager.vehicles[i].instanceID != instanceID)
                {
                    continue;
                }

                UnturnedVehicle Vehicle = UnturnedServer.Vehicles.FirstOrDefault(vehicle => vehicle.InstanceID == instanceID);

                VehicleEvents.RunVehicleExit(Vehicle, seat, point, angle, forceUpdate);

                break;
            }

            DetourManager.CallOriginal(typeof(VehicleManager).GetMethod("tellExitVehicle", BindingFlags.Public | BindingFlags.Instance),
                                       VehicleManager.instance, steamID, instanceID, seat, point, angle, forceUpdate);
        }
        public static void init(this InteractableVehicle vehicle)
        {
            ServerEvents.RunVehicleCreated(vehicle);

            DetourManager.CallOriginal(typeof(InteractableVehicle).GetMethod("init"), vehicle, new object[0]);
        }