コード例 #1
0
ファイル: Machine.cs プロジェクト: ewy0/unitystation
        public void WhenDestroyed(DestructionInfo info)
        {
            //drop all our contents
            ItemStorage itemStorage = null;

            // rare cases were gameObject is destroyed for some reason and then the method is called
            if (gameObject == null)
            {
                return;
            }

            itemStorage = GetComponent <ItemStorage>();

            if (itemStorage != null)
            {
                itemStorage.ServerDropAll();
            }

            SpawnResult frameSpawn = Spawn.ServerPrefab(CommonPrefabs.Instance.MachineFrame, SpawnDestination.At(gameObject));

            if (!frameSpawn.Successful)
            {
                Logger.LogError($"Failed to spawn frame! Is {this} missing references in the inspector?", Category.Construction);
                return;
            }

            GameObject frame = frameSpawn.GameObject;

            frame.GetComponent <MachineFrame>().ServerInitFromComputer(this);

            Despawn.ServerSingle(gameObject);

            integrity.OnWillDestroyServer.RemoveListener(WhenDestroyed);
        }
コード例 #2
0
ファイル: Machine.cs プロジェクト: CatimirPutin/unitystation
        public void WhenDestroyed(DestructionInfo info)
        {
            //drop all our contents
            ItemStorage itemStorage = null;

            // rare cases were gameObject is destroyed for some reason and then the method is called
            if (gameObject == null)
            {
                return;
            }

            itemStorage = GetComponent <ItemStorage>();

            if (itemStorage != null)
            {
                itemStorage.ServerDropAll();
            }

            var frame = Spawn.ServerPrefab(framePrefab, SpawnDestination.At(gameObject)).GameObject;

            frame.GetComponent <MachineFrame>().ServerInitFromComputer(this);

            Despawn.ServerSingle(gameObject);

            integrity.OnWillDestroyServer.RemoveListener(WhenDestroyed);
        }
コード例 #3
0
    public void ServerPerformInteraction(HandApply interaction)
    {
        var itemObject = interaction.HandSlot.ItemObject;

        if (Validations.HasItemTrait(itemObject, CommonTraits.Instance.Crowbar))
        {
            oreBoxItemStorage.ServerDropAll();
        }
        else if (Validations.HasItemTrait(itemObject, CommonTraits.Instance.OreGeneral))
        {
            TransferOre(interaction.HandSlot);
        }
        else
        {
            var itemStorage  = itemObject.GetComponent <ItemStorage>();
            var itemSlotList = itemStorage.GetItemSlots();
            foreach (var itemSlot in itemSlotList)
            {
                if (itemSlot.IsEmpty)
                {
                    continue;
                }
                TransferOre(itemSlot);
            }
        }
    }
コード例 #4
0
    public void ServerPerformInteraction(HandApply interaction)
    {
        //unscrew
        ToolUtils.ServerUseToolWithActionMessages(interaction, secondsToScrewdrive,
                                                  "You start to disconnect the monitor...",
                                                  $"{interaction.Performer.ExpensiveName()} starts to disconnect the monitor...",
                                                  "You disconnect the monitor.",
                                                  $"{interaction.Performer.ExpensiveName()} disconnects the monitor.",
                                                  () =>
        {
            //drop all our contents
            ItemStorage itemStorage = null;
            // rare cases were gameObject is destroyed for some reason and then the method is called
            if (gameObject != null)
            {
                itemStorage = GetComponent <ItemStorage>();
            }

            if (itemStorage != null)
            {
                itemStorage.ServerDropAll();
            }
            var frame = Spawn.ServerPrefab(framePrefab, SpawnDestination.At(gameObject)).GameObject;
            frame.GetComponent <ComputerFrame>().ServerInitFromComputer(this);
            Despawn.ServerSingle(gameObject);
        });
    }
コード例 #5
0
 /// <summary>
 /// Removes all limbs from the container and drops all items that they are holding
 /// </summary>
 public void RemoveLimbs()
 {
     if (ItemStorage == null)
     {
         ItemStorage = this.GetComponent <ItemStorage>();
     }
     ItemStorage.ServerDropAll();
     PlayerSprites.livingHealthMasterBase.RootBodyPartContainers.Remove(this);
 }
コード例 #6
0
 public void ServerPerformInteraction(HandActivate interaction)
 {
     if (ArmTrap(interaction.Performer) == false)
     {
         if (trapContent.GetNextFreeIndexedSlot() == null)
         {
             trapContent.ServerDropAll();
         }
     }
 }
コード例 #7
0
 public void OpenClose()
 {
     if (closed)
     {
         UpdateManager.Remove(CallbackType.UPDATE, UpdateMe);
         SoundManager.PlayNetworkedAtPos(openSound, WorldPosition, sourceObj: gameObject);
         barrelSpriteHandler.ChangeSprite(0);
         itemStorage.ServerDropAll();
         storedFermentables.Clear();
     }
     else
     {
         UpdateManager.Add(CallbackType.UPDATE, UpdateMe);
         SoundManager.PlayNetworkedAtPos(closeSound, WorldPosition, sourceObj: gameObject);
         barrelSpriteHandler.ChangeSprite(1);
     }
     closed = !closed;
 }
コード例 #8
0
 private void EjectContents()
 {
     storage.ServerDropAll();
 }