コード例 #1
0
ファイル: Gun.cs プロジェクト: ewy0/unitystation
 public virtual void ServerPerformInteraction(HandActivate interaction)
 {
     if (CurrentMagazine != null && allowMagazineRemoval && !MagInternal)
     {
         RequestUnload(CurrentMagazine);
     }
 }
コード例 #2
0
    /// <summary>
    /// Check if item has an interaction with a an item in a slot
    /// If not or if bool returned is true, swap items
    /// </summary>
    public void TryItemInteract(bool swapIfEmpty = true)
    {
        var slotName = itemSlot.SlotIdentifier.NamedSlot;

        // Clicked on another slot other than our own hands
        if (itemSlot != UIManager.Hands.LeftHand.ItemSlot && itemSlot != UIManager.Hands.RightHand.itemSlot)
        {
            // If full, attempt to interact the two, otherwise swap
            if (Item != null)
            {
                //check IF2 InventoryApply interaction - combine the active hand item with this (only if
                //both are occupied)
                if (TryIF2InventoryApply())
                {
                    return;
                }

                if (swapIfEmpty)
                {
                    UIManager.Hands.SwapItem(this);
                }
                return;
            }
            else
            {
                if (swapIfEmpty)
                {
                    UIManager.Hands.SwapItem(this);
                }
                return;
            }
        }
        // If there is an item and the hand is interacting in the same slot
        if (Item != null && UIManager.Hands.CurrentSlot.ItemSlot == itemSlot)
        {
            //check IF2 logic first
            var interactables = Item.GetComponents <IBaseInteractable <HandActivate> >()
                                .Where(mb => mb != null && (mb as MonoBehaviour).enabled);
            var activate = HandActivate.ByLocalPlayer();
            InteractionUtils.ClientCheckAndTrigger(interactables, activate);
        }
        else
        {
            if (UIManager.Hands.CurrentSlot.ItemSlot != itemSlot)
            {
                //Clicked on item with otherslot selected
                if (UIManager.Hands.OtherSlot.Item != null)
                {
                    if (TryIF2InventoryApply())
                    {
                        return;
                    }
                    if (swapIfEmpty)
                    {
                        UIManager.Hands.SwapItem(this);
                    }
                }
            }
        }
    }
コード例 #3
0
 public void ServerPerformInteraction(HandActivate interaction)
 {
     Chat.AddExamineMsgFromServer(interaction.Performer, "You Clear internal buffer");
     ListBuffer.Clear();
     MultiMaster         = false;
     ConfigurationBuffer = MultitoolConnectionType.Empty;
 }
コード例 #4
0
 public void ServerPerformInteraction(HandActivate interaction)
 {
     Chat.AddExamineMsgFromServer(interaction.Performer, "You clear the multitool's internal buffer.");
     buffers.Clear();
     isMultipleMaster    = false;
     configurationBuffer = MultitoolConnectionType.Empty;
 }
コード例 #5
0
    //For pressing Z to place the object on the tile you're on.
    public void ServerPerformInteraction(HandActivate interaction)
    {
        // Spawns object at player's position.
        Spawn.ServerPrefab(prefabVariant, interaction.PerformerPlayerScript.WorldPos);

        // Remove the used item from the player's inventory
        Inventory.ServerDespawn(interaction.HandSlot);
    }
コード例 #6
0
 public bool WillInteract(HandActivate interaction, NetworkSide side)
 {
     if (!DefaultWillInteract.Default(interaction, side))
     {
         return(false);
     }
     return(true);
 }
コード例 #7
0
ファイル: Metal.cs プロジェクト: ThoraninC/unitystation
    private void BuildGirder(HandActivate interaction, Vector3 position)
    {
        PoolManager.PoolNetworkInstantiate(girderPrefab, position);
        isBuilding = false;
        var slot = InventoryManager.GetSlotFromOriginatorHand(interaction.Performer, interaction.HandSlot.equipSlot);

        GetComponent <Pickupable>().DisappearObject(slot);
        GetComponent <CustomNetTransform>().DisappearFromWorldServer();
    }
コード例 #8
0
    /// <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="handActivate">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<Activate> 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(HandActivate handActivate, GameObject processorObject)
    {
        var msg = new RequestHandActivateMessage
        {
            ProcessorObject = processorObject.GetComponent <NetworkIdentity>().netId
        };

        msg.Send();
    }
コード例 #9
0
        public override bool WillInteract(HandActivate interaction, NetworkSide side)
        {
            if (base.WillInteract(interaction, side) == false)
            {
                return(false);
            }

            // If charges remain, return false to allow the HasNetworkTabItem component to take over.
            return(!HasCharges);
        }
コード例 #10
0
    /// <summary>
    /// Check if item has an interaction with a an item in a slot
    /// If not or if bool returned is true, swap items
    /// </summary>
    public void TryItemInteract()
    {
        // Clicked on another slot other than hands
        if (equipSlot != EquipSlot.leftHand && equipSlot != EquipSlot.rightHand)
        {
            // If full, attempt to interact the two, otherwise swap
            if (Item != null)
            {
                //check IF2 InventoryApply interaction - combine the active hand item with this (only if
                //both are occupied)
                if (TryIF2InventoryApply())
                {
                    return;
                }

                UIManager.Hands.SwapItem(this);
                return;
            }
            else
            {
                UIManager.Hands.SwapItem(this);
                return;
            }
        }
        // If there is an item and the hand is interacting in the same slot
        if (Item != null && UIManager.Hands.CurrentSlot.equipSlot == equipSlot)
        {
            //check IF2 logic first
            var interactables = Item.GetComponents <IInteractable <HandActivate> >()
                                .Where(mb => mb != null && (mb as MonoBehaviour).enabled);
            var activate = HandActivate.ByLocalPlayer();
            foreach (var interactable in interactables)
            {
                if (interactable.Interact(activate))
                {
                    return;
                }
            }
        }
        else
        {
            if (UIManager.Hands.CurrentSlot.equipSlot != equipSlot)
            {
                //Clicked on item with otherslot selected
                if (UIManager.Hands.OtherSlot.Item != null)
                {
                    if (TryIF2InventoryApply())
                    {
                        return;
                    }
                    UIManager.Hands.SwapItem(this);
                }
            }
        }
    }
コード例 #11
0
    public bool Interact(HandActivate interaction)
    {
        //try ejecting the mag if external
        if (CurrentMagazine != null && !MagInternal && CanRemovableMag)
        {
            RequestUnload(CurrentMagazine);
            return(true);
        }

        return(false);
    }
コード例 #12
0
ファイル: Gun.cs プロジェクト: Reavershark/unitystation
    public bool Interact(HandActivate interaction)
    {
        //try ejecting the mag
        if (CurrentMagazine != null)
        {
            RequestUnload(CurrentMagazine);
            return(true);
        }

        return(false);
    }
コード例 #13
0
ファイル: Gun.cs プロジェクト: jedi5218/unitystation
        public virtual bool Interact(HandActivate interaction)
        {
            //try ejecting the mag if external
            if (CurrentMagazine != null && allowMagazineRemoval && !MagInternal)
            {
                RequestUnload(CurrentMagazine);
                return(true);
            }

            return(false);
        }
コード例 #14
0
        public bool Interact(HandActivate interaction)
        {
            if (isCan && capRemoved == false)
            {
                Chat.AddExamineMsgToClient("Need to remove the cap first");
                return(false);
            }

            UIManager.Instance.CrayonUI.openingObject = gameObject;
            UIManager.Instance.CrayonUI.SetActive(true);
            return(true);
        }
コード例 #15
0
 public void ServerInteract(HandActivate interaction)
 {
     if (countFiremode - 1 == currentFiremode)
     {
         currentFiremode = 0;
     }
     else
     {
         currentFiremode += 1;
     }
     UpdateFiremode();
 }
コード例 #16
0
 protected override void ServerPerformInteraction(HandActivate interaction)
 {
     if (safety)
     {
         safety     = false;
         spriteSync = 1;
     }
     else
     {
         safety     = true;
         spriteSync = 0;
     }
 }
コード例 #17
0
    private void ProcessActivate(GameObject activatedObject, GameObject processorObj, GameObject performerObj, HandSlot handSlot)
    {
        //try to look up the components on the processor that can handle this interaction
        var processorComponents = InteractionMessageUtils.TryGetProcessors <HandActivate>(processorObj);
        //invoke each component that can handle this interaction
        var activate = HandActivate.ByClient(performerObj, activatedObject, handSlot);

        foreach (var processorComponent in processorComponents)
        {
            if (processorComponent.ServerProcessInteraction(activate))
            {
                //something happened, don't check further components
                return;
            }
        }
    }
コード例 #18
0
 public void ServerPerformInteraction(HandActivate interaction)
 {
     if (onCooldown)
     {
         Chat.AddExamineMsg(interaction.Performer, $"The {gameObject.ExpensiveName()} is still charging!");
         return;
     }
     if (isReady == false)
     {
         Chat.AddExamineMsg(interaction.Performer, $"You prepare the {gameObject.ExpensiveName()}");
         isReady = true;
         _       = SoundManager.PlayNetworkedAtPosAsync(soundReady, gameObject.AssumedWorldPosServer());
         return;
     }
     Chat.AddExamineMsg(interaction.Performer, $"<color=green>The {gameObject.ExpensiveName()} is charged and ready to be used.</color>");
 }
コード例 #19
0
 public override bool Interact(HandActivate interaction)
 {
     if (countFiremode == 1)
     {
         return(false);
     }
     if (countFiremode - 1 == currentFiremode)
     {
         currentFiremode = 0;
     }
     else
     {
         currentFiremode += 1;
     }
     UpdateFiremode();
     return(true);
 }
コード例 #20
0
ファイル: Gun.cs プロジェクト: ewy0/unitystation
        public virtual bool WillInteract(HandActivate interaction, NetworkSide side)
        {
            if (DefaultWillInteract.Default(interaction, side) == false)
            {
                return(false);
            }
            if (side == NetworkSide.Server && DefaultWillInteract.Default(interaction, side))
            {
                return(true);
            }

            //try ejecting the mag if external
            if (CurrentMagazine != null && allowMagazineRemoval && !MagInternal && side == NetworkSide.Client)
            {
                return(true);
            }
            return(false);
        }
コード例 #21
0
ファイル: Metal.cs プロジェクト: ThoraninC/unitystation
 private void startBuilding(HandActivate interaction)
 {
     if (!isBuilding)
     {
         var position             = interaction.Performer.transform.position;
         var progressFinishAction = new FinishProgressAction(
             reason =>
         {
             if (reason == FinishProgressAction.FinishReason.INTERRUPTED)
             {
                 CancelBuild();
             }
             else if (reason == FinishProgressAction.FinishReason.COMPLETED)
             {
                 BuildGirder(interaction, position);
             }
         }
             );
         isBuilding = true;
         UIManager.ProgressBar.StartProgress(position.RoundToInt(), 5f, progressFinishAction, interaction.Performer);
     }
 }
コード例 #22
0
 public virtual void ServerPerformInteraction(HandActivate interaction)
 {
     rotatable.Rotate();
 }
コード例 #23
0
ファイル: Grenade.cs プロジェクト: yamamushi/unitystation
 protected override void ServerPerformInteraction(HandActivate interaction)
 {
     StartCoroutine(TimeExplode(interaction.Performer));
 }
コード例 #24
0
 /// <summary>
 /// Default WillInteract logic for Activate
 /// </summary>
 public static bool HandActivate(HandActivate interaction, NetworkSide side)
 {
     return(Validations.CanInteract(interaction.Performer, side));
 }
コード例 #25
0
 public virtual bool WillInteract(HandActivate interaction, NetworkSide side)
 {
     return(DefaultWillInteract.Default(interaction, side));
 }
コード例 #26
0
ファイル: Metal.cs プロジェクト: ThoraninC/unitystation
 protected override void ServerPerformInteraction(HandActivate interaction)
 {
     startBuilding(interaction);
 }
コード例 #27
0
 public virtual void ServerPerformInteraction(HandActivate interaction)
 {
     RotatePipe();
 }
コード例 #28
0
 protected override void ServerPerformInteraction(HandActivate interaction)
 {
     SoundManager.PlayNetworkedAtPos(soundToggle, interaction.Performer.transform.position);
     ToggleState();
 }
コード例 #29
0
 protected override void ClientPredictInteraction(HandActivate interaction)
 {
     ToggleState();
 }
コード例 #30
0
    public override void Process()
    {
        var performer = SentByPlayer.GameObject;

        if (SentByPlayer == null || SentByPlayer.Script == null || SentByPlayer.Script.ItemStorage == null)
        {
            return;
        }



        if (InteractionType == typeof(PositionalHandApply))
        {
            //look up item in active hand slot
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            LoadMultipleObjects(new uint[] {
                TargetObject, ProcessorObject
            });
            var targetObj    = NetworkObjects[0];
            var processorObj = NetworkObjects[1];
            var interaction  = PositionalHandApply.ByClient(performer, usedObject, targetObj, TargetVector, usedSlot, Intent, TargetBodyPart);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(HandApply))
        {
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            LoadMultipleObjects(new uint[] {
                TargetObject, ProcessorObject
            });
            var targetObj    = NetworkObjects[0];
            var processorObj = NetworkObjects[1];
            var interaction  = HandApply.ByClient(performer, usedObject, targetObj, TargetBodyPart, usedSlot, Intent, IsAltUsed);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(AimApply))
        {
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            LoadNetworkObject(ProcessorObject);
            var processorObj = NetworkObject;
            var interaction  = AimApply.ByClient(performer, TargetVector, usedObject, usedSlot, MouseButtonState, Intent);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(MouseDrop))
        {
            LoadMultipleObjects(new uint[] { UsedObject,
                                             TargetObject, ProcessorObject });
            var usedObj      = NetworkObjects[0];
            var targetObj    = NetworkObjects[1];
            var processorObj = NetworkObjects[2];
            var interaction  = MouseDrop.ByClient(performer, usedObj, targetObj, Intent);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(HandActivate))
        {
            LoadNetworkObject(ProcessorObject);

            var processorObj = NetworkObject;
            var performerObj = SentByPlayer.GameObject;
            //look up item in active hand slot
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            var interaction   = HandActivate.ByClient(performer, usedObject, usedSlot, Intent);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(InventoryApply))
        {
            LoadMultipleObjects(new uint[] { ProcessorObject, UsedObject,
                                             Storage });
            var processorObj = NetworkObjects[0];
            var usedObj      = NetworkObjects[1];
            var storageObj   = NetworkObjects[2];

            ItemSlot targetSlot = null;
            if (SlotIndex == -1)
            {
                targetSlot = ItemSlot.GetNamed(storageObj.GetComponent <ItemStorage>(), NamedSlot);
            }
            else
            {
                targetSlot = ItemSlot.GetIndexed(storageObj.GetComponent <ItemStorage>(), SlotIndex);
            }

            //if used object is null, then empty hand was used
            ItemSlot fromSlot = null;
            if (usedObj == null)
            {
                fromSlot = SentByPlayer.Script.ItemStorage.GetActiveHandSlot();
            }
            else
            {
                fromSlot = usedObj.GetComponent <Pickupable>().ItemSlot;
            }
            var interaction = InventoryApply.ByClient(performer, targetSlot, fromSlot, Intent, IsAltUsed);
            ProcessInteraction(interaction, processorObj);
        }
        else if (InteractionType == typeof(TileApply))
        {
            var clientStorage = SentByPlayer.Script.ItemStorage;
            var usedSlot      = clientStorage.GetActiveHandSlot();
            var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
            LoadNetworkObject(ProcessorObject);
            var processorObj = NetworkObject;
            processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(TileInteractionIndex,
                                                                                     SentByPlayer.GameObject, TargetVector, processorObj, usedSlot, usedObject, Intent, TileApply.ApplyType.HandApply);
        }
        else if (InteractionType == typeof(TileMouseDrop))
        {
            LoadMultipleObjects(new uint[] { UsedObject,
                                             ProcessorObject });

            var usedObj      = NetworkObjects[0];
            var processorObj = NetworkObjects[1];
            processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(TileInteractionIndex,
                                                                                     SentByPlayer.GameObject, TargetVector, processorObj, null, usedObj, Intent, TileApply.ApplyType.MouseDrop);
        }
    }