예제 #1
0
        public void ServerPerformInteraction(InventoryApply interaction)
        {
            var text = interaction.UsedObject.GetComponent <Paper>().PaperString;

            AttachNote(interaction.Performer, text);
            Inventory.ServerDespawn(interaction.UsedObject);
        }
예제 #2
0
    private bool TryIF2InventoryApply()
    {
        //check IF2 InventoryApply interaction - apply the active hand item with this (only if
        //target slot is occupied, but it's okay if active hand slot is not occupied)
        if (Item != null)
        {
            var combine = InventoryApply.ByLocalPlayer(inventorySlot);
            //check interactables in the active hand (if active hand occupied)
            if (UIManager.Hands.CurrentSlot.Item != null)
            {
                var handInteractables = UIManager.Hands.CurrentSlot.Item.GetComponents <IInteractable <InventoryApply> >();
                foreach (var interactable in handInteractables)
                {
                    if (interactable.Interact(combine))
                    {
                        //something combined, don't do anything else
                        return(true);
                    }
                }
            }

            //check interactables in the target
            var targetInteractables = Item.GetComponents <IInteractable <InventoryApply> >();
            foreach (var interactable in targetInteractables)
            {
                if (interactable.Interact(combine))
                {
                    //something combined, don't do anything else
                    return(true);
                }
            }
        }

        return(false);
    }
예제 #3
0
    public override bool WillInteract(InventoryApply interaction, NetworkSide side)
    {
        if (DefaultWillInteract.Default(interaction, side) == false)
        {
            return(false);
        }
        if (side == NetworkSide.Server && DefaultWillInteract.Default(interaction, side))
        {
            return(true);
        }

        //only reload if the gun is the target and mag/clip is in hand slot
        if (interaction.TargetObject == gameObject && interaction.IsFromHandSlot && side == NetworkSide.Client)
        {
            if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Screwdriver) && allowScrewdriver ||
                Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Wirecutter) ||
                Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.FiringPin))
            {
                return(true);
            }
            else if (interaction.UsedObject != null)
            {
                MagazineBehaviour mag = interaction.UsedObject.GetComponent <MagazineBehaviour>();
                if (mag && Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.WeaponCell))
                {
                    return(true);
                }
            }
        }
        return(false);
    }
예제 #4
0
 public void ServerPerformInteraction(InventoryApply interaction)
 {
     if (interaction.TargetObject == gameObject && interaction.IsFromHandSlot)
     {
         if (interaction.UsedObject != null)
         {
             MagazineBehaviour mag = interaction.UsedObject.GetComponent <MagazineBehaviour>();
             if (mag)
             {
                 RequestReload(mag.gameObject);
             }
             else if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Suppressor) && !isSuppressed && isSuppressible)
             {
                 SyncIsSuppressed(isSuppressed, true);
                 // setting the suppressor var to the gameobject and then spawning that would be better,
                 // however the despawning sets the var to null
                 Despawn.ServerSingle(interaction.UsedObject);
             }
         }
         else if (isSuppressed && isSuppressible)
         {
             SyncIsSuppressed(isSuppressed, false);
             var result = Spawn.ServerPrefab(suppressor);
             if (result.Successful)
             {
                 var item = result.GameObject;
                 Inventory.ServerAdd(item, interaction.FromSlot);
             }
         }
     }
 }
예제 #5
0
파일: Gun.cs 프로젝트: ewy0/unitystation
 public virtual void ServerPerformInteraction(InventoryApply interaction)
 {
     if (interaction.TargetObject == gameObject && interaction.IsFromHandSlot)
     {
         if (interaction.UsedObject != null)
         {
             MagazineBehaviour mag = interaction.UsedObject.GetComponent <MagazineBehaviour>();
             if (mag)
             {
                 RequestReload(mag.gameObject);
             }
             else if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Suppressor) && !isSuppressed && isSuppressible)
             {
                 SyncIsSuppressed(isSuppressed, true);
                 Inventory.ServerTransfer(interaction.FromSlot, suppressorSlot);
             }
             else if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Wirecutter) && allowPinSwap)
             {
                 PinRemoval(interaction);
             }
             else if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.FiringPin) && allowPinSwap)
             {
                 PinAddition(interaction);
             }
         }
         else if (isSuppressed && isSuppressible && suppressorSlot.Item != null)
         {
             SyncIsSuppressed(isSuppressed, false);
             Inventory.ServerTransfer(suppressorSlot, interaction.FromSlot);
         }
     }
 }
예제 #6
0
파일: Gun.cs 프로젝트: ewy0/unitystation
        protected void PinRemoval(InventoryApply interaction)
        {
            void ProgressFinishAction()
            {
                Chat.AddActionMsgToChat(interaction.Performer,
                                        $"You remove the {FiringPin.gameObject.ExpensiveName()} from {gameObject.ExpensiveName()}",
                                        $"{interaction.Performer.ExpensiveName()} removes the {FiringPin.gameObject.ExpensiveName()} from {gameObject.ExpensiveName()}.");

                SyncPredictionCanFire(predictionCanFire, false);

                Inventory.ServerDrop(pinSlot);
            }

            var bar = StandardProgressAction.Create(ProgressConfig, ProgressFinishAction)
                      .ServerStartProgress(interaction.Performer.RegisterTile(), PinRemoveTime, interaction.Performer);

            if (bar != null)
            {
                Chat.AddActionMsgToChat(interaction.Performer,
                                        $"You begin removing the {FiringPin.gameObject.ExpensiveName()} from {gameObject.ExpensiveName()}",
                                        $"{interaction.Performer.ExpensiveName()} begins removing the {FiringPin.gameObject.ExpensiveName()} from {gameObject.ExpensiveName()}.");

                AudioSourceParameters audioSourceParameters = new AudioSourceParameters(UnityEngine.Random.Range(0.8f, 1.2f));
                SoundManager.PlayNetworkedAtPos(SingletonSOSounds.Instance.WireCutter, interaction.Performer.AssumedWorldPosServer(), audioSourceParameters, sourceObj: serverHolder);
            }
        }
예제 #7
0
        public void ServerPerformInteraction(InventoryApply interaction)
        {
            var needAmmo = magazineBehaviour.magazineSize - magazineBehaviour.ServerAmmoRemains;

            if (needAmmo <= 0)
            {
                return;
            }
            // check if what is trying to be used as fuel
            // can actually be used as fuel
            // and if it can, define a variable stating what
            // fuel is being used
            if (Validations.HasItemTrait(interaction.FromSlot.Item.gameObject, CommonTraits.Instance.SolidPlasma))
            {
                refilledAmmo = sheetEff;
            }
            else if (Validations.HasItemTrait(interaction.FromSlot.Item.gameObject, CommonTraits.Instance.OrePlasma))
            {
                refilledAmmo = oreEff;
            }
            else
            {
                return;
            }
            var stackable  = interaction.FromSlot.Item.GetComponent <Stackable>();
            var intbattery = interaction.FromSlot.Item.GetComponent <InternalBattery>();

            battery            = intbattery.GetBattery();
            electricalMagazine = battery.GetComponent <ElectricalMagazine>();
            Refill(stackable, needAmmo, refilledAmmo);
        }
예제 #8
0
    public bool Interact(InventoryApply interaction)
    {
        if (interaction.TargetObject != gameObject)
        {
            //backpack can't be "applied" to something else in inventory
            return(false);
        }
        if (interaction.HandObject != null)
        {
            //Put item in back without opening it
            //Check if it is a storage obj:
            if (storageObj.NextSpareSlot() != null)
            {
                UIManager.TryUpdateSlot(new UISlotObject(storageObj.NextSpareSlot().UUID, interaction.HandObject,
                                                         InventorySlotCache.GetSlotByItem(interaction.HandObject)?.inventorySlot.UUID));
                SoundManager.PlayAtPosition("Rustle0" + UnityEngine.Random.Range(1, 6).ToString(), PlayerManager.LocalPlayer.transform.position);
                ObjectBehaviour itemObj = interaction.HandObject.GetComponent <ObjectBehaviour>();
                itemObj.parentContainer = objectBehaviour;
            }
        }
        else
        {
            //nothing in hand, just open / close the backpack (note that this means backpack can only be moved in inventory
            //by dragging and dropping)
            return(Interact(HandActivate.ByLocalPlayer()));
        }


        return(false);
    }
예제 #9
0
 public void ServerPerformInteraction(InventoryApply interaction)
 {
     SoundManager.PlayNetworkedAtPos("Wrench", interaction.Performer.WorldPosServer(), 1f);
     Spawn.ServerPrefab("Metal", interaction.Performer.WorldPosServer().CutToInt(), transform.parent, count: 1,
                        scatterRadius: Spawn.DefaultScatterRadius, cancelIfImpassable: true);
     Inventory.ServerDespawn(interaction.FromSlot);
 }
예제 #10
0
    private bool TryIF2InventoryApply()
    {
        //check IF2 InventoryApply interaction - apply the active hand item with this (only if
        //target slot is occupied, but it's okay if active hand slot is not occupied)
        if (Item != null)
        {
            var combine = InventoryApply.ByLocalPlayer(itemSlot, UIManager.Hands.CurrentSlot.itemSlot);
            //check interactables in the active hand (if active hand occupied)
            if (UIManager.Hands.CurrentSlot.Item != null)
            {
                var handInteractables = UIManager.Hands.CurrentSlot.Item.GetComponents <IBaseInteractable <InventoryApply> >()
                                        .Where(mb => mb != null && (mb as MonoBehaviour).enabled);
                if (InteractionUtils.ClientCheckAndTrigger(handInteractables, combine) != null)
                {
                    return(true);
                }
            }

            //check interactables in the target
            var targetInteractables = Item.GetComponents <IBaseInteractable <InventoryApply> >()
                                      .Where(mb => mb != null && (mb as MonoBehaviour).enabled);
            if (InteractionUtils.ClientCheckAndTrigger(targetInteractables, combine) != null)
            {
                return(true);
            }
        }

        return(false);
    }
예제 #11
0
 public void ServerPerformInteraction(InventoryApply interaction)
 {
     ToolUtils.ServerPlayToolSound(interaction);
     Spawn.ServerPrefab(CommonPrefabs.Instance.Metal, interaction.Performer.WorldPosServer().CutToInt(), transform.parent, count: 1,
                        scatterRadius: Spawn.DefaultScatterRadius, cancelIfImpassable: true);
     Inventory.ServerDespawn(interaction.FromSlot);
 }
예제 #12
0
    public bool WillInteract(InventoryApply interaction, NetworkSide side)
    {
        if (allowedToInteract == false)
        {
            return(false);
        }
        // we need to be the target - something is put inside us
        if (interaction.TargetObject != gameObject)
        {
            return(false);
        }
        if (DefaultWillInteract.Default(interaction, side) == false)
        {
            return(false);
        }
        // item must be able to fit
        // note: since this is in local player's inventory, we are safe to check this stuff on client side
        if (!Validations.CanPutItemToStorage(interaction.Performer.GetComponent <PlayerScript>(),
                                             itemStorage, interaction.UsedObject, side, examineRecipient: interaction.Performer))
        {
            return(false);
        }

        return(true);
    }
        public bool WillInteract(InventoryApply interaction, NetworkSide side)
        {
            if (DefaultWillInteract.Default(interaction, side) == false)
            {
                return(false);
            }

            if (interaction.TargetObject == null || interaction.UsedObject == null)
            {
                return(false);
            }

            //Dont target self
            if (interaction.TargetObject == gameObject)
            {
                return(false);
            }

            //Make sure used object is ourself
            if (interaction.UsedObject != gameObject)
            {
                return(false);
            }

            return(interaction.TargetObject.TryGetComponent <GasContainer>(out _));
        }
예제 #14
0
파일: Gun.cs 프로젝트: ewy0/unitystation
        public virtual bool WillInteract(InventoryApply interaction, NetworkSide side)
        {
            if (DefaultWillInteract.Default(interaction, side) == false)
            {
                return(false);
            }
            if (side == NetworkSide.Server && DefaultWillInteract.Default(interaction, side))
            {
                return(true);
            }

            //only reload if the gun is the target and mag/clip is in hand slot
            if (interaction.TargetObject == gameObject && interaction.IsFromHandSlot && side == NetworkSide.Client)
            {
                if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Suppressor) ||
                    Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Wirecutter) ||
                    Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.FiringPin) ||
                    interaction.IsAltClick)
                {
                    return(true);
                }
                else if (interaction.UsedObject != null)
                {
                    MagazineBehaviour mag = interaction.UsedObject.GetComponent <MagazineBehaviour>();
                    if (mag)
                    {
                        return(TryReload(mag.gameObject));
                    }
                }
            }
            return(false);
        }
예제 #15
0
    public void ServerPerformInteraction(InventoryApply interaction)
    {
        if (activated)
        {
            Chat.AddExamineMsgFromServer(interaction.Performer, "You can't adjust the sword while it's on!");
            return;
        }

        if (color == (int)SwordColor.Rainbow)
        {
            Chat.AddExamineMsgFromServer(interaction.Performer, "It's already fabulous!");
            return;
        }

        if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Screwdriver))
        {
            Chat.AddExamineMsgFromServer(interaction.Performer, "You adjust the crystalline beam emitter...");
            var c = color + 1;
            if (c >= (int)SwordColor.Rainbow)
            {
                c = (int)SwordColor.Red;
            }

            ClientSyncColor(color, c);
        }
        else if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Multitool))
        {
            Chat.AddExamineMsgFromServer(interaction.Performer, "RNBW_ENGAGE");
            ClientSyncColor(color, (int)SwordColor.Rainbow);
        }
    }
예제 #16
0
 /// <summary>
 /// method that handles inserting a firing pin into a firearm
 /// </summary>
 private void PinAddition(InventoryApply interaction)
 {
     Chat.AddActionMsgToChat(interaction.Performer,
                             $"You insert the {interaction.UsedObject.gameObject.ExpensiveName()} into {gameObject.ExpensiveName()}.",
                             $"{interaction.Performer.ExpensiveName()} inserts the {interaction.UsedObject.gameObject.ExpensiveName()} into {gameObject.ExpensiveName()}.");
     Inventory.ServerTransfer(interaction.FromSlot, pinSlot);
     FiringPin.gunComp = this;
 }
예제 #17
0
파일: Gun.cs 프로젝트: ewy0/unitystation
 protected void PinAddition(InventoryApply interaction)
 {
     Chat.AddActionMsgToChat(interaction.Performer,
                             $"You insert the {interaction.UsedObject.gameObject.ExpensiveName()} into {gameObject.ExpensiveName()}.",
                             $"{interaction.Performer.ExpensiveName()} inserts the {interaction.UsedObject.gameObject.ExpensiveName()} into {gameObject.ExpensiveName()}.");
     UpdatePredictionCanFire(serverHolder);
     Inventory.ServerTransfer(interaction.FromSlot, pinSlot);
 }
        public void ServerPerformInteraction(InventoryApply interaction)
        {
            if (interaction.TargetObject.TryGetComponent <GasContainer>(out var container) == false)
            {
                return;
            }

            Chat.AddExamineMsgFromServer(interaction.Performer, GetGasMixInfo(container.GasMix));
        }
예제 #19
0
 public void ServerPerformInteraction(InventoryApply interaction)
 {
     if (allowedToInteract == false)
     {
         return;
     }
     Inventory.ServerTransfer(interaction.FromSlot,
                              itemStorage.GetBestSlotFor((interaction).UsedObject));
 }
예제 #20
0
    public void ServerPerformInteraction(InventoryApply interaction)
    {
        SoundManager.PlayNetworkedAtPos("Wrench", interaction.Performer.WorldPosServer(), 1f);
        ObjectFactory.SpawnMetal(1, interaction.Performer.WorldPosServer().To2Int(), parent: transform.parent);

        var rack = interaction.TargetObject;
        var slot = InventoryManager.GetSlotFromOriginatorHand(interaction.Performer, interaction.TargetSlot.equipSlot);

        rack.GetComponent <Pickupable>().DisappearObject(slot);
    }
예제 #21
0
    public bool WillInteract(InventoryApply interaction, NetworkSide side)
    {
        // standard validation for interaction
        if (!DefaultWillInteract.Default(interaction, side))
        {
            return(false);
        }

        return(CheckInteraction(interaction, side));
    }
    /// <summary>
    /// For most cases you should use InteractionMessageUtils.SendRequest() instead of this.
    ///
    /// Sends a request to the server to validate + perform the interaction.
    /// </summary>
    /// <param name="inventoryApply">info on the interaction being performed. Each object involved in the interaction
    /// must have a networkidentity.</param>
    /// <param name="processorObject">object who has a component implementing IInteractionProcessor<Combine> which
    /// will process the interaction on the server-side. This object must have a NetworkIdentity and there must only be one instance
    /// of this component on the object. For organization, we suggest that the component which is sending this message
    /// should be on the processorObject, as such this parameter should almost always be passed using "this.gameObject", and
    /// should almost always be either a component on the target object or a component on the used object</param>
    public static void Send(InventoryApply inventoryApply, GameObject processorObject)
    {
        var msg = new RequestInventoryApplyMessage
        {
            ProcessorObject = processorObject.GetComponent <NetworkIdentity>().netId,
            TargetSlotUUID  = inventoryApply.TargetSlot.UUID
        };

        msg.Send();
    }
예제 #23
0
 protected void PinInteraction(InventoryApply interaction)
 {
     if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Wirecutter) && allowPinSwap)
     {
         PinRemoval(interaction);
     }
     else if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.FiringPin) && allowPinSwap)
     {
         PinAddition(interaction);
     }
 }
예제 #24
0
    public bool Interact(InventoryApply interaction)
    {
        //only reload if the gun is the target
        if (interaction.TargetObject == gameObject)
        {
            TryReload(interaction.HandObject);
            return(true);
        }

        return(false);
    }
예제 #25
0
        public bool WillInteract(InventoryApply interaction, NetworkSide side)
        {
            // standard validation for interaction
            if (DefaultWillInteract.Default(interaction, side) == false || !interaction.TargetObject)
            {
                return(false);
            }

            ItemAttributesV2 attr = interaction.TargetObject.GetComponent <ItemAttributesV2>();

            return(attr.HasTrait(LightableSurface) && interaction.Intent == Intent.Harm);
        }
예제 #26
0
        public bool Interact(InventoryApply interaction)
        {
            //insert the headset key if this is used on a headset
            if (interaction.UsedObject == gameObject &&
                interaction.TargetObject.GetComponent <Headset>() != null)
            {
                UpdateHeadsetKeyMessage.Send(interaction.TargetObject, gameObject);
                return(true);
            }

            return(false);
        }
예제 #27
0
 public bool WillInteract(InventoryApply interaction, NetworkSide side)
 {
     if (!DefaultWillInteract.Default(interaction, side))
     {
         return(false);
     }
     //only pen can be used on this
     if (!Validations.HasComponent <Pen>(interaction.HandObject))
     {
         return(false);
     }
     return(true);
 }
예제 #28
0
        public void ServerPerformInteraction(InventoryApply interaction)
        {
            var needAmmo = magazineBehaviour.magazineSize - magazineBehaviour.ServerAmmoRemains;

            if (needAmmo <= 0)
            {
                return;
            }

            var stackable = interaction.FromSlot.Item.GetComponent <Stackable>();

            Refill(stackable, needAmmo);
        }
예제 #29
0
        //Used on shard in inventory
        public bool WillInteract(InventoryApply interaction, NetworkSide side)
        {
            if (Validations.CanInteract(interaction.PerformerPlayerScript, side) == false)
            {
                return(false);
            }

            if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Welder))
            {
                return(true);
            }

            return(false);
        }
예제 #30
0
        //Used on shard in inventory
        public bool WillInteract(InventoryApply interaction, NetworkSide side)
        {
            if (DefaultWillInteract.InventoryApply(interaction, side) == false)
            {
                return(false);
            }

            if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Welder))
            {
                return(true);
            }

            return(false);
        }