Ejemplo n.º 1
0
        private void Disconnected([NotNull] UnturnedPlayer player)
        {
            var playerId = player.CSteamID.m_SteamID;

            if (BarricadeManager.regions == null)
            {
                return;
            }

            var buildables = BarricadeManager.regions.Cast <BarricadeRegion>().Concat(BarricadeManager.vehicleRegions)
                             .SelectMany(k => k.drops)
                             .Select(k =>
                                     !Configuration.Instance.ItemsToDisable.Contains(k.asset.id) ||
                                     k.GetServersideData().owner != playerId
                        ? null
                        : k.interactable).Where(k => k != null).ToList();

            foreach (var interactable in buildables)
            {
                switch (interactable)
                {
                case InteractableSafezone saf:
                    BarricadeManager.ServerSetSafezonePowered(saf, false);
                    break;

                case InteractableOxygenator oxy:
                    BarricadeManager.ServerSetOxygenatorPowered(oxy, false);
                    break;

                case InteractableSpot spot:
                    BarricadeManager.ServerSetSpotPowered(spot, false);
                    break;

                case InteractableGenerator gen:
                    BarricadeManager.ServerSetGeneratorPowered(gen, false);
                    break;

                case InteractableFire fire:
                    BarricadeManager.ServerSetFireLit(fire, false);
                    break;

                case InteractableOven oven:
                    BarricadeManager.ServerSetOvenLit(oven, false);
                    break;

                case InteractableStereo stereo:
                    BarricadeManager.ServerSetStereoTrack(stereo, Guid.Empty);
                    break;
                }
            }

            Logger.Log($"Turned off {buildables.Count} barricades.");
        }
        public static void RunUtilityTool(UnturnedPlayer Player, RaycastResult Raycast)
        {
            if (Raycast.ParentHasComponent <InteractableCharge>())
            {
                Raycast.TryGetEntity <InteractableCharge>().detonate(Player.CSteamID);
            }

            if (Raycast.ParentHasComponent <InteractableFire>())
            {
                var f = Raycast.TryGetEntity <InteractableFire>();
                BarricadeManager.ServerSetFireLit(f, !f.isLit);
            }


            if (Raycast.ParentHasComponent <InteractableGenerator>())
            {
                var f = Raycast.TryGetEntity <InteractableGenerator>();
                BarricadeManager.ServerSetGeneratorPowered(f, !f.isPowered);
            }

            if (Raycast.ParentHasComponent <InteractableOven>())
            {
                var f = Raycast.TryGetEntity <InteractableOven>();
                BarricadeManager.ServerSetOvenLit(f, !f.isLit);
            }


            if (Raycast.ParentHasComponent <InteractableOxygenator>())
            {
                var f = Raycast.TryGetEntity <InteractableOxygenator>();
                BarricadeManager.ServerSetOxygenatorPowered(f, !f.isPowered);
            }



            if (Raycast.ParentHasComponent <InteractableSafezone>())
            {
                var f = Raycast.TryGetEntity <InteractableSafezone>();
                BarricadeManager.ServerSetSafezonePowered(f, !f.isPowered);
            }


            if (Raycast.ParentHasComponent <InteractableSpot>())
            {
                var f = Raycast.TryGetEntity <InteractableSpot>();
                BarricadeManager.ServerSetSpotPowered(f, !f.isPowered);
            }

            if (Raycast.ParentHasComponent <InteractableVehicle>())
            {
                var f = Raycast.TryGetEntity <InteractableVehicle>();
                VehicleManager.ServerForcePassengerIntoVehicle(Player.Player, f);
            }

            if (Raycast.ParentHasComponent <InteractableBed>())
            {
                var f = Raycast.TryGetEntity <InteractableBed>();
                if (f.owner.m_SteamID != 0)
                {
                    UnturnedChat.Say(Player, "PointTool_Utility_Bed_ShowOwner".Translate($"{AdminToolsPlugin.Instance.GetPlayerName(f.owner.m_SteamID, "Unknown Player")} ({f.owner})"));
                }
                else
                {
                    UnturnedChat.Say(Player, "PointTool_Utility_Bed_NotClaimed".Translate());;
                }
            }
            if (Raycast.ParentHasComponent <InteractableDoor>())
            {
                var f = Raycast.TryGetEntity <InteractableDoor>();
                SendOpenDoor(Raycast.BarricadePlant, Raycast.BarricadeX, Raycast.BarricadeY, Raycast.BarricadeIndex, f, Raycast.BarricadeRegion);
            }
            if (Raycast.ParentHasComponent <InteractableStorage>())
            {
                InteractableStorage Storage = Raycast.TryGetEntity <InteractableStorage>();
                Player.Player.inventory.updateItems(7, Storage.items);
                Player.Player.inventory.sendStorage();
            }
        }