예제 #1
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 float.NegativeInfinity to indicate null, rather than a nullable struct
                if (datas[i].Value == float.NegativeInfinity)
                {
                    isComplete = false;
                }
                else
                {
                    hasChanged |= true;
                }
            }

            return
                (isComplete ? SerializationFlags.IsComplete | SerializationFlags.HasChanged :
                 hasChanged?SerializationFlags.HasChanged:
                 SerializationFlags.None);
        }
예제 #2
0
        public void Apply(VitalsData vdata)
        {
            var datas = vdata.datas;

            for (int i = 0; i < vitalCount; ++i)
            {
                vitalArray[i].Apply(datas[i]);
            }
        }
예제 #3
0
        public void CopyFrom(VitalsData source)
        {
            var srcdatas = source.datas;
            int cnt      = srcdatas.Length;

            for (int i = 0; i < cnt; ++i)
            {
                datas[i] = srcdatas[i];
            }
        }
예제 #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; i < vitalCount; ++i)
            {
                flags |= vitalDefs[i].Serialize(currdatas[i], lastdatas[i], buffer, ref bitposition, keyframe);
            }

            return(flags);
        }
예제 #5
0
        public override void OnAwake()
        {
            base.OnAwake();

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

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

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

            defaultMountingMask = 1 << (defaultMounting.id);
        }
예제 #6
0
 public Frame(int frameId, Vitals vitals) : base(frameId)
 {
     vitalsData = new VitalsData(vitals);
 }