Exemple #1
0
 private void UninformHead(PushPull whoToInform, PushPull subject)
 {
     InformPullMessage.Send(whoToInform, subject, null);
     if (IsPullingSomethingServer)
     {
         PulledObjectServer.UninformHead(whoToInform, PulledObjectServer);
     }
 }
Exemple #2
0
 ///inform new master puller about who's pulling who in the train
 public void InformHead(PushPull whoToInform, PushPull subject = null)
 {
     if (subject == null)
     {
         subject = this;
     }
     InformPullMessage.Send(whoToInform, subject, subject.PulledBy);
     if (IsPullingSomethingServer)
     {
         PulledObjectServer.InformHead(whoToInform, PulledObjectServer);
     }
 }
Exemple #3
0
    public void CmdPullObject(GameObject pullableObject)
    {
        PushPull pullable = pullableObject.GetComponent <PushPull>();

        if (!pullable)
        {
            return;
        }
        if (IsPullingSomethingServer)
        {
            var alreadyPulling = PulledObjectServer;
            ReleaseControl();

            //Kill ex-pullable's impulses if we stop pulling it ourselves
            //todo: make it accept puller's impulse on release if he's flying
            alreadyPulling.Stop();

            //Just stopping pulling of object if we ctrl+click it again
            if (alreadyPulling == pullable)
            {
                return;
            }
        }
        ConnectedPlayer clientWhoAsked = PlayerList.Instance.Get(gameObject);

        if (clientWhoAsked.Script.canNotInteract())
        {
            return;
        }

        if (PlayerScript.IsInReach(pullable.registerTile, this.registerTile, true) &&
            !pullable.isNotPushable && pullable != this && !IsBeingPulled)
        {
            if (pullable.StartFollowing(this))
            {
                SoundManager.PlayNetworkedAtPos("Rustle0" + Random.Range(1, 4), pullable.transform.position);

                PulledObjectServer = pullable;

                //Kill its impulses if we grabbed it
                PulledObjectServer.Stop();

                // Update the UI
                UpdatePullingUI(this);
            }
        }
    }