示例#1
0
        public EntityComView(string comName, FieldInfo[] fieldInfos, BaseCom baseCom)
        {
            ComName = comName;
            ComAttribute comAttribute = LCReflect.GetTypeAttr <ComAttribute>(baseCom.GetType());

            if (comAttribute != null)
            {
                ComName = comAttribute.ViewName;
            }
            for (int i = 0; i < fieldInfos.Length; i++)
            {
                FieldInfo       info     = fieldInfos[i];
                ComKeyValueView keyValue = new ComKeyValueView(info.Name, info, baseCom);

                ComValueAttribute comValueAttribute = LCReflect.GetFieldAttr <ComValueAttribute>(info);
                if (comValueAttribute != null)
                {
                    if (comValueAttribute.ViewEditor)
                    {
                        EditorValueList.Add(keyValue);
                    }
                    else
                    {
                        if (comValueAttribute.ShowView)
                        {
                            ValueList.Add(keyValue);
                        }
                    }
                }
            }
        }
示例#2
0
 protected BaseProtocol(int slotNum, BaseCom com, DriverLog log)
 {
     SeatsCount = 16;
     BoardNum   = slotNum;
     Comm       = com;
     Log        = log;
 }
示例#3
0
 //添加实体全局单一组件
 private void AddEntityGlobalSingleCom(EntityJson conf, Entity entity)
 {
     for (int i = 0; i < conf.Coms.Count; i++)
     {
         BaseCom com = entity.GetCom(conf.Coms[i].ComName);
         if (ECSHelp.CheckComIsGlobal(com.GetType()))
         {
             if (globalSingleCom.ContainsKey(com.GetType()))
             {
                 ECSLocate.ECSLog.LogError("有多个全局单个组件>>>>>>", conf.EntityName, com.GetType());
                 entity.Disable();
                 return;
             }
             globalSingleCom.Add(com.GetType(), com);
         }
     }
 }
示例#4
0
        /// <summary>
        /// 处理实体组件
        /// </summary>
        private static List <EntityComView> HandleEntityComs(Entity entity)
        {
            List <EntityComView> comViews = new List <EntityComView>();
            //组件名
            HashSet <string> entityComs = entity.GetAllComStr();

            foreach (string comName in entityComs)
            {
                BaseCom     com    = entity.GetCom(comName);
                FieldInfo[] fields = LCReflect.GetTypeFieldInfos(com.GetType());

                EntityComView comView = new EntityComView(comName, fields, com);

                comViews.Add(comView);
            }

            return(comViews);
        }
示例#5
0
 public ProtocolTosa32G(int boardNum, BaseCom com, DriverLog log) : base(boardNum, com, log)
 {
     _delayTime = 10000;
 }
示例#6
0
        private void DrawCom(BaseCom baseCom)
        {
            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            List <FieldInfo> serFields   = new List <FieldInfo>();
            List <FieldInfo> noSerFields = new List <FieldInfo>();

            foreach (var item in ReflectionHelper.GetFieldInfos(baseCom.GetType()))
            {
                bool ignore = false;
                foreach (var ignoreName in IgnoreFieldName)
                {
                    if (item.Name.Contains(ignoreName))
                    {
                        ignore = true;
                        continue;
                    }
                }
                if (ignore)
                {
                    continue;
                }

                if (AttributeHelper.TryGetFieldAttribute(item, out NonSerializedAttribute attr))
                {
                    noSerFields.Add(item);
                }
                else
                {
                    serFields.Add(item);
                }
            }

            _serFoldout = EditorGUILayout.Foldout(_serFoldout, "Serialized:");
            if (_serFoldout)
            {
                foreach (var item in serFields)
                {
                    object newValue = GUILayoutExtension.DrawField(item.FieldType, item.GetValue(baseCom), GraphProcessorEditorUtility.GetDisplayName(item.Name), "");
                    if (newValue == null || !newValue.Equals(item.GetValue(baseCom)))
                    {
                        item.SetValue(baseCom, newValue);
                    }
                }
            }

            _noSerFoldout = EditorGUILayout.Foldout(_noSerFoldout, "NoSerialized:");
            if (_noSerFoldout)
            {
                EditorGUI.BeginDisabledGroup(true);
                foreach (var item in noSerFields)
                {
                    GUILayoutExtension.DrawField(item.FieldType, item.GetValue(baseCom), GraphProcessorEditorUtility.GetDisplayName(item.Name), "");
                }
                EditorGUI.EndDisabledGroup();
            }
        }
示例#7
0
 public ComKeyValueView(string name, FieldInfo info, BaseCom com)
 {
     KeyName = name;
     Info    = info;
     Com     = com;
 }
示例#8
0
 public ProtocolQsfp28G(int slotNum, BaseCom com, DriverLog log) : base(slotNum, com, log)
 {
     _delayTime = 10000;
 }
示例#9
0
        public Entity CreateProduct(Action <object[]> func, params object[] data)
        {
            //解析参数
            int        entityId   = int.Parse(data[0].ToString());
            string     entityName = data[1].ToString();
            GameObject entityGo   = data.Length > 2?data[2] as GameObject:null;

            //配置数据
            EntityJson entityData = ECSLayerLocate.Info.GetEntityConf(entityName);

            if (entityData == null)
            {
                ECSLocate.ECSLog.LogError("实体配置数据不存在>>>>>>>", entityName);
                return(null);
            }

            //创建实体节点
            if (entityGo == null)
            {
                entityGo = (GameObject)ECSLocate.Factory.GetProduct <Object>(FactoryType.Asset, null, entityData.PrefabPath);
                entityGo = Object.Instantiate(entityGo);
            }
            if (entityGo == null)
            {
                ECSLocate.ECSLog.LogR("有一个实体没有节点>>>>>>>>", entityId, entityName);
            }
            else
            {
#if UNITY_EDITOR
                EntityEditorViewHelp sceneHelp = entityGo.AddComponent <EntityEditorViewHelp>();
                sceneHelp.EntityId = entityId;
#endif
            }

            //创建实体
            Entity entity = new Entity();

            //添加组件
            for (int i = 0; i < entityData.Coms.Count; i++)
            {
                EntityComJson comJson = entityData.Coms[i];
                BaseCom       com     = LCReflect.CreateInstanceByType <BaseCom>(comJson.ComName);

                //赋值
                for (int j = 0; j < comJson.Values.Count; j++)
                {
                    EntityComValueJson valueJson = comJson.Values[j];

                    object value = LCConvert.StrChangeToObject(valueJson.Value, valueJson.Type);
                    LCReflect.SetTypeFieldValue(com, valueJson.Name, value);
                }

                com.Init(entityId, entityGo);
                entity.AddCom(com);
            }

            func?.Invoke(new object[] { entityGo });

            ECSLocate.ECSLog.LogR("创建实体成功>>>>>>>>", entityName);
            return(entity);
        }
示例#10
0
 public OvenControl(BaseCom com)
 {
     _com       = com;
     _delayTime = 5000;
 }