private bool CheckAimApply(MouseButtonState buttonState)
    {
        ChangeDirection();
        //currently there is nothing for ghosts to interact with, they only can change facing
        if (PlayerManager.LocalPlayerScript.IsGhost)
        {
            return(false);
        }

        //can't do anything if we have no item in hand
        var handObj = UIManager.Hands.CurrentSlot.Item;

        if (handObj == null)
        {
            triggeredAimApply = null;
            secondsSinceLastAimApplyTrigger = 0;
            return(false);
        }

        var aimApplyInfo = AimApply.ByLocalPlayer(buttonState);

        if (buttonState == MouseButtonState.PRESS)
        {
            //it's being clicked down
            triggeredAimApply = null;
            //Checks for aim apply interactions which can trigger
            var comps = handObj.GetComponents <IBaseInteractable <AimApply> >()
                        .Where(mb => mb != null && (mb as MonoBehaviour).enabled);
            var triggered = InteractionUtils.ClientCheckAndTrigger(comps, aimApplyInfo);
            if (triggered != null)
            {
                triggeredAimApply = triggered;
                secondsSinceLastAimApplyTrigger = 0;
                return(true);
            }
        }
        else
        {
            //it's being held
            //if we are already triggering an AimApply, keep triggering it based on the AimApplyInterval
            if (triggeredAimApply != null)
            {
                secondsSinceLastAimApplyTrigger += Time.deltaTime;
                if (secondsSinceLastAimApplyTrigger > AimApplyInterval)
                {
                    if (triggeredAimApply.CheckInteract(aimApplyInfo, NetworkSide.Client))
                    {
                        //only reset timer if it was actually triggered
                        secondsSinceLastAimApplyTrigger = 0;
                        InteractionUtils.RequestInteract(aimApplyInfo, triggeredAimApply);
                    }
                }

                //no matter what the result, we keep trying to trigger it until mouse is released.
                return(true);
            }
        }

        return(false);
    }
Пример #2
0
 private void ContextMenuOptionClicked(ContextMenuApply interaction)
 {
     if (!AccessRestrictions || AccessRestrictions.CheckAccess(interaction.Performer))
     {
         InteractionUtils.RequestInteract(interaction, this);
     }
     else
     {
         Chat.AddExamineMsg(interaction.Performer, $"Access Denied.");
         // Play sound
         SoundManager.PlayNetworkedAtPos(SingletonSOSounds.Instance.AccessDenied, gameObject.AssumedWorldPosServer(), sourceObj: gameObject);
     }
 }
Пример #3
0
        protected override IEnumerator CustomUpdateBenchmark(int sampleCount)
        {
            int disableGeneratorPoint = sampleCount / 3;
            int enableGeneratorPoint  = sampleCount * 2 / 3;

            yield return(new WaitWhile(LoopFunction));

            bool LoopFunction()
            {
                sampleCount--;
                if (sampleCount == disableGeneratorPoint || sampleCount == enableGeneratorPoint)
                {
                    var generator = GetAtRelative <PowerGenerator>(Orientation.Right);
                    InteractionUtils.RequestInteract(HandApply.ByLocalPlayer(generator.gameObject), generator);
                }
                return(sampleCount > 0);
            }
        }
Пример #4
0
 private void ContextMenuOptionClicked(ContextMenuApply interaction)
 {
     InteractionUtils.RequestInteract(interaction, this);
 }
Пример #5
0
 private void RightClickInteract()
 {
     InteractionUtils.RequestInteract(HandApply.ByLocalPlayer(gameObject), this);
 }
Пример #6
0
 private void RightClickInteract()
 {
     //trigger the interaction manually, triggered via the right click menu
     InteractionUtils.RequestInteract(HandApply.ByLocalPlayer(gameObject), this);
 }
    private bool CheckHandApply(GameObject target)
    {
        //call the used object's handapply interaction methods if it has any, for each object we are applying to
        var handApply    = HandApply.ByLocalPlayer(target);
        var posHandApply = PositionalHandApply.ByLocalPlayer(target);

        //if handobj is null, then its an empty hand apply so we only need to check the receiving object
        if (handApply.HandObject != null)
        {
            //get all components that can handapply or PositionalHandApply
            var handAppliables = handApply.HandObject.GetComponents <MonoBehaviour>()
                                 .Where(c => c != null && c.enabled && (c is IBaseInteractable <HandApply> || c is IBaseInteractable <PositionalHandApply>));
            Logger.LogTraceFormat("Checking HandApply / PositionalHandApply interactions from {0} targeting {1}",
                                  Category.Interaction, handApply.HandObject.name, target.name);

            foreach (var handAppliable in handAppliables.Reverse())
            {
                var interacted = false;
                if (handAppliable is IBaseInteractable <HandApply> )
                {
                    var hap = handAppliable as IBaseInteractable <HandApply>;
                    if (hap.CheckInteract(handApply, NetworkSide.Client))
                    {
                        InteractionUtils.RequestInteract(handApply, hap);
                        return(true);
                    }
                }
                else
                {
                    var hap = handAppliable as IBaseInteractable <PositionalHandApply>;
                    if (hap.CheckInteract(posHandApply, NetworkSide.Client))
                    {
                        InteractionUtils.RequestInteract(posHandApply, hap);
                        return(true);
                    }
                }
            }
        }

        //call the hand apply interaction methods on the target object if it has any
        var targetHandAppliables = handApply.TargetObject.GetComponents <MonoBehaviour>()
                                   .Where(c => c != null && c.enabled && (c is IBaseInteractable <HandApply> || c is IBaseInteractable <PositionalHandApply>));

        foreach (var targetHandAppliable in targetHandAppliables.Reverse())
        {
            var interacted = false;
            if (targetHandAppliable is IBaseInteractable <HandApply> )
            {
                var hap = targetHandAppliable as IBaseInteractable <HandApply>;
                if (hap.CheckInteract(handApply, NetworkSide.Client))
                {
                    InteractionUtils.RequestInteract(handApply, hap);
                    return(true);
                }
            }
            else
            {
                var hap = targetHandAppliable as IBaseInteractable <PositionalHandApply>;
                if (hap.CheckInteract(posHandApply, NetworkSide.Client))
                {
                    InteractionUtils.RequestInteract(posHandApply, hap);
                    return(true);
                }
            }
        }

        return(false);
    }
Пример #8
0
 private void RightClickInteract()
 {
     InteractionUtils.RequestInteract(MouseDrop.ByLocalPlayer(gameObject, PlayerManager.LocalPlayer), this);
 }