예제 #1
0
        /// <summary>
        /// 数据记录
        /// </summary>
        /// <param name="evt"></param>
        public void Record(PropertyMessage evt)
        {
            if (!EnableRecord)
            {
                return;
            }
            RecordItem item = new RecordItem();

            item.ObjectId     = ((BaseDataModelEntity)evt.TargetObject).objectID;
            item.PropertyPath = evt.PropertyName;
            item.NewValue     = evt.NewValue;
            item.FrameCount   = Time.frameCount - StartRecordFrame;
            AddRecordItem(item);
        }
예제 #2
0
 /// <summary>
 /// 添加数据到对应列表中
 /// </summary>
 /// <param name="item"></param>
 public void AddRecordItem(RecordItem item)
 {
     if (_writeState == 1)
     {
         recordBufferA.Add(item);
         if (recordBufferA.Count == _bufferLength)
         {
             ChunkToString();
             recordBufferA.Clear();
             _writeState = 2;
         }
     }
     else if (_writeState == 2)
     {
         recordBufferB.Add(item);
         if (recordBufferB.Count == _bufferLength)
         {
             ChunkToString();
             recordBufferB.Clear();
             _writeState = 1;
         }
     }
 }
예제 #3
0
        /// <summary>
        /// 回放设置对应的属性值
        /// </summary>
        /// <param name="item"></param>
        public void UpdateEntityValue(RecordItem item)
        {
            //获取实体对象实例
            BaseDataModelEntity targetEntity = GetModelEntityByUuid(item.ObjectId);

            if (targetEntity == null)
            {
                targetEntity = RestoreSystem.GetEntity(item.ObjectId);
            }
            if (targetEntity == null)
            {
                return;
            }
            if (item.PropertyPath.Contains("#"))
            {
                UpdateWatchable(targetEntity, item.PropertyPath, item.NewValue);
            }
            //通过Property方式查找属性并设置属性值
            PropertyInfo propertyInfo = null;

            propertyInfo = targetEntity.GetType().GetProperty(item.PropertyPath);
            if (propertyInfo != null)
            {
                if (propertyInfo.PropertyType == typeof(System.Single))
                {
                    System.Single _value = System.Convert.ToSingle(item.NewValue);
                    propertyInfo.SetValue(targetEntity, _value);
                }
                else if (propertyInfo.PropertyType == typeof(System.Int32))
                {
                    System.Int32 _value = System.Convert.ToInt32(item.NewValue);
                    propertyInfo.SetValue(targetEntity, _value);
                }
                else
                {
                    propertyInfo.SetValue(targetEntity, item.NewValue, null);
                }

                return;
            }

            //通过Field方式查找属性并设置属性值
            FieldInfo fieldInfo = targetEntity.GetType().GetField(item.PropertyPath);

            if (fieldInfo != null)
            {
                if (fieldInfo.FieldType == typeof(System.Single))
                {
                    System.Single _value = System.Convert.ToSingle(item.NewValue);
                    fieldInfo.SetValue(targetEntity, _value);
                }
                else if (fieldInfo.FieldType == typeof(System.Int32))
                {
                    System.Int32 _value = System.Convert.ToInt32(item.NewValue);
                    fieldInfo.SetValue(targetEntity, _value);
                }
                else
                {
                    fieldInfo.SetValue(targetEntity, item.NewValue);
                }
            }
        }