//syncvar hook invoked client side when the buckledTo changes
    private void SyncBuckledObjectNetId(uint oldBuckledTo, uint newBuckledTo)
    {
        //unsub if we are subbed
        if (IsBuckled)
        {
            var directionalObject = BuckledObject.GetComponent <Directional>();
            if (directionalObject != null)
            {
                directionalObject.OnDirectionChange.RemoveListener(OnBuckledObjectDirectionChange);
            }
        }

        if (PlayerManager.LocalPlayer == gameObject)
        {
            //have to do this with a lambda otherwise the Cmd will not fire
            UIManager.AlertUI.ToggleAlertBuckled(newBuckledTo != NetId.Empty, () => CmdUnbuckle());
        }

        buckledObjectNetId = newBuckledTo;
        buckledObject      = NetworkUtils.FindObjectOrNull(buckledObjectNetId);

        //sub
        if (buckledObject != null)
        {
            var directionalObject = buckledObject.GetComponent <Directional>();
            if (directionalObject != null)
            {
                directionalObject.OnDirectionChange.AddListener(OnBuckledObjectDirectionChange);
            }
        }

        //ensure we are in sync with server
        playerScript?.PlayerSync?.RollbackPrediction();
    }
Exemple #2
0
    //syncvar hook invoked client side when the buckledTo changes
    private void SyncBuckledObjectNetId(uint oldBuckledTo, uint newBuckledTo)
    {
        //unsub if we are subbed
        if (IsBuckled)
        {
            var directionalObject = BuckledObject.GetComponent <Directional>();
            if (directionalObject != null)
            {
                directionalObject.OnDirectionChange.RemoveListener(OnBuckledObjectDirectionChange);
            }
        }

        if (PlayerManager.LocalPlayer == gameObject)
        {
            UIActionManager.ToggleLocal(this, newBuckledTo != NetId.Empty);
        }

        buckledObjectNetId = newBuckledTo;
        buckledObject      = NetworkUtils.FindObjectOrNull(buckledObjectNetId);

        //sub
        if (buckledObject != null)
        {
            var directionalObject = buckledObject.GetComponent <Directional>();
            if (directionalObject != null)
            {
                directionalObject.OnDirectionChange.AddListener(OnBuckledObjectDirectionChange);
            }
        }

        //ensure we are in sync with server
        playerScript?.PlayerSync?.RollbackPrediction();
    }
Exemple #3
0
 public void CmdUnbuckle()
 {
     if (IsCuffed)
     {
         Chat.AddActionMsgToChat(
             PlayerScript.gameObject,
             "You're trying to unbuckle yourself from the chair! (this will take some time...)",
             PlayerScript.name + " is trying to unbuckle themself from the chair!"
             );
         StandardProgressAction.Create(
             new StandardProgressActionConfig(StandardProgressActionType.Unbuckle),
             Unbuckle
             ).ServerStartProgress(
             BuckledObject.RegisterTile(),
             BuckledObject.GetComponent <BuckleInteract>().ResistTime,
             PlayerScript.gameObject
             );
         return;
     }
     Unbuckle();
 }