Exemple #1
0
    //this is used to process the incomming data from the item
    public override void recieveNetworkData(CSteamID steamID, string[] dataSplit)
    {
        PlayerNetworkIndividualController playerNetworkIndividualController = GameReference.self.playerNetwork.getIndividualController(steamID);

        base.recieveNetworkData(steamID, dataSplit);
        if (dataSplit[1] == "InPlayerHand")
        {
            onEnterHandsNetwork(playerNetworkIndividualController);
        }
        else if (dataSplit[1] == "OutPlayerHand")
        {
            //print(rig.velocity);
            onExitHandsNetwork(playerNetworkIndividualController, false);
            transform.parent   = null;
            transform.position = new Vector3(float.Parse(dataSplit[2]), float.Parse(dataSplit[3]), float.Parse(dataSplit[4]));
            transform.rotation = new Quaternion(float.Parse(dataSplit[5]), float.Parse(dataSplit[6]), float.Parse(dataSplit[7]), float.Parse(dataSplit[8]));

            rig.velocity        = new Vector3(float.Parse(dataSplit[9]), float.Parse(dataSplit[10]), float.Parse(dataSplit[11]));
            rig.angularVelocity = new Vector3(float.Parse(dataSplit[12]), float.Parse(dataSplit[13]), float.Parse(dataSplit[14]));

            rig.isKinematic = false;
        }
        else if (dataSplit[1] == "Dropped")
        {
            onExitHandsNetwork(playerNetworkIndividualController, true);
            transform.parent   = null;
            transform.position = new Vector3(float.Parse(dataSplit[2]), float.Parse(dataSplit[3]), float.Parse(dataSplit[4]));
            transform.rotation = new Quaternion(float.Parse(dataSplit[5]), float.Parse(dataSplit[6]), float.Parse(dataSplit[7]), float.Parse(dataSplit[8]));

            rig.velocity        = new Vector3(float.Parse(dataSplit[9]), float.Parse(dataSplit[10]), float.Parse(dataSplit[11]));
            rig.angularVelocity = new Vector3(float.Parse(dataSplit[12]), float.Parse(dataSplit[13]), float.Parse(dataSplit[14]));

            rig.isKinematic = false;
        }
        else if (dataSplit[1] == "InInv")
        {
            onPutInContainerNetwork(Savable.findGameObjectByID((int)StringToFloat(dataSplit[2])).GetComponent <Container>(), playerNetworkIndividualController);
        }
        else if (dataSplit[1] == "OutInv")
        {
            onTakenOutOfContainerNetwork();
            transform.position = new Vector3(float.Parse(dataSplit[2]), float.Parse(dataSplit[3]), float.Parse(dataSplit[4]));
            transform.rotation = new Quaternion(float.Parse(dataSplit[5]), float.Parse(dataSplit[6]), float.Parse(dataSplit[7]), float.Parse(dataSplit[8]));

            rig.velocity        = new Vector3(float.Parse(dataSplit[9]), float.Parse(dataSplit[10]), float.Parse(dataSplit[11]));
            rig.angularVelocity = new Vector3(float.Parse(dataSplit[12]), float.Parse(dataSplit[13]), float.Parse(dataSplit[14]));
        }
        else if (dataSplit[1] == "Anim")
        {
            anim.SetBool(dataSplit[2], StringToBool(dataSplit[3]));
        }
        else if (dataSplit[1] == "InvRot")
        {
            rotatedItem = StringToBool(dataSplit[2]);
        }
    }
Exemple #2
0
    //network sync for exiting hands
    public virtual void onExitHandsNetwork(PlayerNetworkIndividualController playerNetworkIndividualController, bool dropped)
    {
        setController(Controller.Network);

        setLayerToWorld();

        itemInNetworkHands = false;

        disableAnimation();
        playerNetworkIndividualController.playerIK.resetHands();
        playerNetworkIndividualController.setHandObject(null);

        if (dropped)
        {
            showToWorld();
        }
        setAbleToPickup(true);
    }
Exemple #3
0
    //network sync for put in container
    public virtual void onPutInContainerNetwork(Container c, PlayerNetworkIndividualController playerNetworkIndividualController)
    {
        setController(Controller.Network);

        if (itemInInv != null)
        {
            //        itemInInv.Play();
        }
        isWithinContainer = c;

        if (itemInNetworkHands)
        {
            onExitHandsNetwork(playerNetworkIndividualController, false);
        }

        stopSyncingUntilRest();
        hideFromWorld();


        setAbleToPickup(true);
    }
Exemple #4
0
    //network sync for entering hands
    public virtual void onEnterHandsNetwork(PlayerNetworkIndividualController playerNetworkIndividualController)
    {
        setController(Controller.Local);

        showToWorld();
        disableAllColliders();

        itemInNetworkHands = true;

        if (itemAquireSound != null)
        {
            //   itemAquireSound.Play();
        }
        else
        {
            itemAquireSound = makeAudioSourceFromGenericSounds(GameReference.self.genericSounds.itemAquire);
        }



        rig             = GetComponent <Rigidbody>();
        rig.isKinematic = false;


        if (anim != null)
        {
            anim.enabled = true;
        }
        isWithinContainer = null;


        stopSyncingUntilRest();

        playerNetworkIndividualController.playerIK.setLeftHand(getLeftHand());
        playerNetworkIndividualController.playerIK.setRightHand(getRightHand());
        transform.parent = playerNetworkIndividualController.getHand();
        playerNetworkIndividualController.setHandObject(this);

        setAbleToPickup(false);
    }