Пример #1
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            Transform transform;

            transform = RaycastHelper.GetBarricadeTransform(player.Player, out _, out _);
            if (transform == null)
            {
                transform = RaycastHelper.GetStructureTransform(player.Player, out _);
            }

            if (transform == null)
            {
                MessageHelper.Send(caller, "DoorNotLooking");
                return;
            }

            Door door = pluginInstance.DoorService.GetDoorOrItem(transform);

            if (door == null)
            {
                MessageHelper.Send(caller, "DoorNotForSale");
                return;
            }

            MessageHelper.Send(caller, "CheckDoorSuccess", door.Id, door.PriceString, door.OwnerName);
        }
Пример #2
0
        private void LoadDoors(int i)
        {
            database.Reload();

            foreach (Door door in database.Doors)
            {
                Vector3 pos = door.Position.ToVector3();
                door.Transform = RaycastHelper.GetBarricadeTransform(pos);

                if (door.Transform == null)
                {
                    Logger.LogWarning($"Door #{door.Id} transform not found");
                }

                foreach (DoorItem item in door.Items)
                {
                    pos = item.Position.ToVector3();

                    if (item.IsBarricade)
                    {
                        item.Transform = RaycastHelper.GetBarricadeTransform(pos);
                    }
                    else
                    {
                        item.Transform = RaycastHelper.GetStructureTransform(pos);
                    }

                    if (item.Transform == null)
                    {
                        Logger.LogWarning($"Door #{door.Id} item transform not found");
                    }
                }
            }
        }
Пример #3
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            string    name      = string.Empty;
            Transform transform = RaycastHelper.GetBarricadeTransform(player.Player, out BarricadeData barricadeData, out BarricadeDrop drop);

            if (transform == null)
            {
                transform = RaycastHelper.GetStructureTransform(player.Player, out StructureData structureData);
                if (transform != null)
                {
                    name = structureData.structure.asset.itemName;
                }
            }
            else
            {
                name = barricadeData.barricade.asset.itemName;
            }

            if (transform == null)
            {
                MessageHelper.Send(caller, "DoorItemNotLooking");
                return;
            }

            Door door = pluginInstance.DoorService.GetDoorFromItem(transform);

            if (door == null)
            {
                MessageHelper.Send(caller, "NotDoorItem", name);
                return;
            }

            pluginInstance.DoorService.RemoveDoorItem(door, transform);
            MessageHelper.Send(caller, "UnlinkDoorSuccess", name, door.Id);
        }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (command.Length < 1)
            {
                MessageHelper.Send(caller, "LinkDoorFormat");
                return;
            }

            if (!int.TryParse(command[0], out int doorId))
            {
                MessageHelper.Send(caller, "LinkDoorWrongDoorId", command[0]);
                return;
            }

            DoorItem doorItem = new DoorItem();
            string   name     = string.Empty;
            ulong    ownerId  = 0;

            doorItem.Transform = RaycastHelper.GetBarricadeTransform(player.Player, out BarricadeData barricadeData, out BarricadeDrop drop);

            if (doorItem.Transform == null)
            {
                doorItem.Transform = RaycastHelper.GetStructureTransform(player.Player, out StructureData structureData);
                if (doorItem.Transform != null)
                {
                    ownerId = structureData.owner;
                    name    = structureData.structure.asset.itemName;
                    doorItem.IsBarricade = false;
                    doorItem.IsSign      = false;
                }
            }
            else
            {
                ownerId = barricadeData.owner;
                name    = barricadeData.barricade.asset.itemName;
                doorItem.IsBarricade = true;
                doorItem.IsSign      = drop.interactable is InteractableSign;
            }

            if (doorItem.Transform == null)
            {
                MessageHelper.Send(caller, "DoorItemNotLooking");
                return;
            }

            if (ownerId != player.CSteamID.m_SteamID)
            {
                MessageHelper.Send(caller, "DoorItemNotOwner", name);
                return;
            }

            if (pluginInstance.DoorService.IsDoor(doorItem.Transform))
            {
                MessageHelper.Send(caller, "DoorItemAlready", name);
                return;
            }

            Door door = pluginInstance.DoorService.GetDoor(doorId);

            if (door == null)
            {
                MessageHelper.Send(caller, "DoorNotFound", doorId);
                return;
            }

            pluginInstance.DoorService.AddDoorItem(door, doorItem);
            MessageHelper.Send(caller, "LinkDoorSuccess", name, doorId);
        }