private void OnDamageBarricadeRequested(CSteamID instigatorSteamId, Transform barricadeTransform,
                                                ref ushort pendingTotalDamage, ref bool shouldAllow, EDamageOrigin damageOrigin)
        {
            var drop = BarricadeManager.FindBarricadeByRootTransform(barricadeTransform);

            if (drop == null)
            {
                return;
            }

            var buildable = new UnturnedBarricadeBuildable(drop);

            var nativePlayer = PlayerTool.getPlayer(instigatorSteamId);
            var player       = GetUnturnedPlayer(nativePlayer);

            var @event = pendingTotalDamage >= buildable.State.Health
                ? (UnturnedBuildableDamagingEvent) new UnturnedBarricadeDestroyingEvent(buildable, pendingTotalDamage,
                                                                                        damageOrigin, player)
                : new UnturnedBarricadeDamagingEvent(buildable, pendingTotalDamage, damageOrigin, player);

            @event.IsCancelled = !shouldAllow;

            Emit(@event);

            pendingTotalDamage = @event.DamageAmount;
            shouldAllow        = [email protected];
        }
        private void OnModifySignRequested(CSteamID steamId, InteractableSign sign,  // lgtm [cs/too-many-ref-parameters]
                                           ref string text, ref bool shouldAllow)
        {
            var drop = BarricadeManager.FindBarricadeByRootTransform(sign.transform);

            if (drop == null)
            {
                return;
            }

            var buildable = new UnturnedBarricadeBuildable(drop);

            var nativePlayer = PlayerTool.getPlayer(steamId);
            var player       = GetUnturnedPlayer(nativePlayer);

            var @event = new UnturnedSignModifyingEvent(buildable, player, text)
            {
                IsCancelled = !shouldAllow
            };

            Emit(@event);

            text = @event.Text;

            shouldAllow = [email protected];
        }
        private void OnHarvestPlantRequested(InteractableFarm harvestable, SteamPlayer instigatorPlayer, ref bool shouldAllow)
        {
            var drop = BarricadeManager.FindBarricadeByRootTransform(harvestable.transform);

            if (drop == null)
            {
                return;
            }

            var player = GetUnturnedPlayer(instigatorPlayer);

            var @event = new UnturnedPlantHarvestingEvent(new UnturnedBarricadeBuildable(drop), player)
            {
                IsCancelled = !shouldAllow
            };

            Emit(@event);

            shouldAllow = [email protected];
        }
        private void OnOpenStorageRequested(CSteamID steamId, InteractableStorage storage, ref bool shouldAllow)
        {
            var drop = BarricadeManager.FindBarricadeByRootTransform(storage.transform);

            if (drop == null)
            {
                return;
            }

            var buildable = new UnturnedBarricadeBuildable(drop);

            var nativePlayer = PlayerTool.getPlayer(steamId);
            var player       = GetUnturnedPlayer(nativePlayer);

            var @event = new UnturnedStorageOpeningEvent(buildable, player)
            {
                IsCancelled = !shouldAllow
            };

            Emit(@event);

            shouldAllow = [email protected];
        }
Example #5
0
        private void OnBarricadeDamaged(CSteamID instigatorSteamID, Transform barricadeTransform, ref ushort pendingTotalDamage, ref bool shouldAllow, EDamageOrigin damageOrigin)
        {
            SteamPlayer steamPlayer;

            if (!Configuration.Instance.AllowRaid && (steamPlayer = PlayerTool.getSteamPlayer(instigatorSteamID)) != null)
            {
                BarricadeDrop drop = BarricadeManager.FindBarricadeByRootTransform(barricadeTransform);
                BarricadeData data = drop.GetServersideData();
                // return if barricade owner is instigator
                if (data.owner == instigatorSteamID.m_SteamID || data.group == steamPlayer.player.quests.groupID.m_SteamID)
                {
                    return;
                }

                // return if barricade owner is offline
                if (!Provider.clients.Exists(x => x.playerID.steamID.m_SteamID == data.owner || x.player.quests.groupID.m_SteamID == data.group))
                {
                    return;
                }

                this.StartPlayerRaid(instigatorSteamID);
            }
        }