Exemple #1
0
        public override void OnAwake()
        {
            base.OnAwake();

            this.transform.EnsureRootComponentExists <ContactManager, NetObject>();

            if (netObj)
            {
                syncState = netObj.GetComponent <SyncState>();
            }

            vitalArray  = vitals.VitalArray;
            vitalsCount = vitals.vitalDefs.Count;
            rootVital   = vitalArray[0];

            /// subscribe to callbacks to Vitals changes
            vitals.OnVitalValueChangeCallbacks.Add(this);

            lastSentData = new VitalsData(vitals);
            for (int i = 0; i < vitalsCount; ++i)
            {
                vitalArray[i].ResetValues();
            }

            defaultMountingMask = 1 << (defaultMounting.id);
        }
Exemple #2
0
        public SerializationFlags Deserialize(VitalsData vdata, byte[] buffer, ref int bitposition, bool keyframe)
        {
            var datas = vdata.datas;

            bool isComplete = true;
            bool hasChanged = false;

            for (int i = 0; i < vitalCount; ++i)
            {
                datas[i] = vitalDefs[i].Deserialize(buffer, ref bitposition, keyframe);

                /// We are using NegativeInfinity to indicate null, rather than a nullable struct
                if (datas[i].Value == double.NegativeInfinity)
                {
                    isComplete = false;
                }
                else
                {
                    hasChanged |= true;
                }
            }

            return
                (isComplete ? SerializationFlags.IsComplete | SerializationFlags.HasContent :
                 hasChanged?SerializationFlags.HasContent:
                 SerializationFlags.None);
        }
Exemple #3
0
        public void Apply(VitalsData vdata)
        {
            var datas = vdata.datas;

            for (int i = 0; i < vitalCount; ++i)
            {
                vitalArray[i].Apply(datas[i]);
            }
        }
Exemple #4
0
        public SerializationFlags Serialize(VitalsData vdata, VitalsData lastVData, byte[] buffer, ref int bitposition, bool keyframe)
        {
            var currdatas = vdata.datas;
            var lastdatas = lastVData.datas;

            SerializationFlags flags = SerializationFlags.None;

            for (int i = 0, cnt = vitalCount; i < cnt; ++i)
            {
                flags |= vitalDefs[i].Serialize(currdatas[i], lastdatas[i], buffer, ref bitposition, keyframe);
            }

            return(flags);
        }
Exemple #5
0
 public Frame(int frameId, Vitals vitals) : base(frameId)
 {
     vitalsData = new VitalsData(vitals);
 }