コード例 #1
0
ファイル: ECS.cs プロジェクト: PeteyChan/LudenDare_2021_April
 public static void Initialize()
 {
     if (initialized)
     {
         return;
     }
     initialized = true;
     components  = new ECSCollection <C>();
     archtype_components.Add(typeof(C));
     create_entity_components      += () => components.Add(default);
コード例 #2
0
            public static int GetTypeID(Type type)
            {
                if (!IDlookups.TryGetValue(type, out var value))
                {
                    ComponentTypes.Add(type);
                    IDlookups[type] = value = IDlookups.Count;
                    if (value == component_pools.Length)
                    {
                        Array.Resize(ref entity_pools, value * 2);
                        Array.Resize(ref component_pools, value * 2);
                    }

                    entity_pools[value] = new ECSCollection <Entity>();
                    var poolType = typeof(Components <>).MakeGenericType(new Type[] { type });
                    component_pools[value] = (Activator.CreateInstance(poolType) as Components);
                }
                return(value);
            }
コード例 #3
0
 public Iterator Init(ECSCollection <T> list)
 {
     this.list = list;
     position  = list.count;
     return(this);
 }