public void Apply()
        {
            AvatarNPCCommander av = (AvatarNPCCommander)Commander.Find(n);

            av.transform.position = ((Vector3)p) / 1000;
            Vector3 ea = av.transform.eulerAngles;

            ea.y = y / 1000;
            av.transform.eulerAngles = ea;
            av.AnimatorSit           = s;
            av.animator.SetFloat("Forward", ((float)f) / 1000);
            av.animator.SetFloat("Turn", ((float)r) / 1000);
            av.animator.SetFloat("Variant", ((float)v) / 1000);
        }
        public static AvatarSyncMessage ToSyncMessage(AvatarNPCCommander av)
        {
            AvatarSyncMessage msg = new AvatarSyncMessage()
            {
                n = av.name,
                p = Vector3Int.RoundToInt(av.transform.position * 1000),
                y = Mathf.RoundToInt(av.transform.eulerAngles.y * 1000),
                s = av.AnimatorSit,
                f = Mathf.RoundToInt(av.animator.GetFloat("Forward") * 1000),
                r = Mathf.RoundToInt(av.animator.GetFloat("Turn") * 1000),
                v = Mathf.RoundToInt(av.animator.GetFloat("Variant") * 1000)
            };

            return(msg);
        }
Example #3
0
 private void Start()
 {
     if (IsServer)
     {
         List <Commander> cmdrs = new List <Commander>(Commander.RegisteredCommanders.Values);
         cmdrs.ForEach((cmdr) =>
         {
             if (cmdr is AvatarNPCCommander)
             {
                 AvatarNPCCommander acmdr = (AvatarNPCCommander)cmdr;
                 if (acmdr.syncer == null)
                 {
                     AvatarSyncer syncer = acmdr.gameObject.AddComponent <AvatarSyncer>();
                     syncer.avatarNPC    = acmdr;
                     acmdr.syncer        = syncer;
                 }
             }
         });
     }
 }