public void OnNetworkFieldBoolUpdate(FieldArgs args)
 {
     if (net.IsOwner())
     {
         return;
     }
     anim.SetBool(args.fieldName, args.GetValue <bool>());
     //Debug.Log("Field Updated... " + args.fieldName + " "+args.GetValue<bool>());
 }
        public void Initialize()
        {
            anim = GetComponent <Animator>();
            net  = GetComponent <NetworkObject>();
            sR   = GetComponent <SpriteRenderer>();
            if (anim == null)
            {
                Destroy(this);
            }

            if (sR == null)
            {
                manageSpriteFlips = false;
            }

            foreach (AnimatorControllerParameter parameter in anim.parameters)
            {
                if (parameter.type == AnimatorControllerParameterType.Bool)
                {
                    animationBools.Add(parameter);
                    animationBoolsLastValue.Add(anim.GetBool(parameter.name));

                    net.CreateField(parameter.name, anim.GetBool(parameter.name), NetworkField.valueInitializer.Boolean, false, false);
                    net.FieldAddOnChangeMethod(parameter.name, OnNetworkFieldBoolUpdate);
                    //net.FieldAddStringChangeMethod(parameter.name, "OnNetworkFieldBoolUpdate", "EntityNetworkingSystemsAnimationNetworker");
                }
            }

            if (manageSpriteFlips)
            {
                net.CreateField("SRFlipX", sR.flipX, init: NetworkField.valueInitializer.Boolean, true, false);
                net.CreateField("SRFlipY", sR.flipX, init: NetworkField.valueInitializer.Boolean, true, false);

                net.FieldAddOnChangeMethod("SRFlipX", OnNetworkFieldFlipX);
                net.FieldAddOnChangeMethod("SRFlipY", OnNetworkFieldFlipY);
            }


            if (net.IsOwner())
            {
                StartCoroutine(HandleAnimationBoolPackets());
            }

            initialized = true;
        }
            public bool[] CheckKey(NetworkObject myNet)
            {
                if (!isNetworked || myNet.IsOwner())
                {
                    bool newKeyDown    = Input.GetKeyDown(key);
                    bool newKeyPressed = Input.GetKey(key);
                    bool newKeyUp      = Input.GetKeyUp(key);

                    if (isNetworked && (newKeyDown != keyDown || newKeyPressed != keyPressed || newKeyUp != keyUp))
                    {
                        myNet.UpdateField("IW" + displayName, new KeyNetworkData(newKeyDown, newKeyPressed, newKeyUp), false);
                    }
                    keyDown    = newKeyDown;
                    keyPressed = newKeyPressed;
                    keyUp      = newKeyUp;
                }
                return(new bool[] { keyDown, keyPressed, keyUp });
            }