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); } } }
public void CmdPullObject(GameObject pullableObject) { PushPull pullable = pullableObject.GetComponent <PushPull>(); if (!pullable) { return; } if (IsPullingSomething) { var alreadyPulling = PulledObject; 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; } } if (PlayerScript.IsInReach(pullable.registerTile, this.registerTile) && !pullable.isNotPushable && pullable != this && !IsBeingPulled) { if (pullable.StartFollowing(this)) { PlayerManager.LocalPlayerScript.soundNetworkActions.RpcPlayNetworkSound("Rustle0" + Random.Range(1, 4), pullable.transform.position); PulledObject = pullable; //Kill its impulses if we grabbed it PulledObject.Stop(); // Update the UI UpdatePullingUI(this); } } }