4 namespace Entitas.CodeGenerator {
6 [Obsolete(
"Since 0.32.0. It's recommended to use the new PoolsGenerator. Use the OldPoolsGeneratorFor only for existing project.")]
9 const string CLASS_TEMPLATE =
@"using Entitas; 11 public static class Pools {{ 15 const string ALL_POOLS_GETTER =
@" 16 static Pool[] _allPools; 18 public static Pool[] allPools {{ 20 if(_allPools == null) {{ 21 _allPools = new [] {{ {0} }}; 27 const string GETTER =
@" 31 public static Pool {0} {{ 34 _{0} = new Pool({1}.TotalComponents, 0, new PoolMetaData(""{2}Pool"", {1}.componentNames, {1}.componentTypes)); 35 #if(!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR) 36 if(UnityEngine.Application.isPlaying) {{ 37 var poolObserver = new Entitas.Unity.VisualDebugging.PoolObserver(_{0}); 38 UnityEngine.Object.DontDestroyOnLoad(poolObserver.entitiesContainer); 47 var allPools =
string.Format(ALL_POOLS_GETTER,
48 string.Join(
", ", poolNames.Select(poolName => poolName.LowercaseFirst()).ToArray()));
50 var getters = poolNames.Aggregate(
string.Empty, (acc, poolName) =>
51 acc +
string.Format(GETTER, poolName.LowercaseFirst(), poolName.PoolPrefix() +
CodeGenerator.DEFAULT_COMPONENT_LOOKUP_TAG,
52 poolName.IsDefaultPoolName() ?
string.Empty : poolName.PoolPrefix() +
" "));
56 string.Format(CLASS_TEMPLATE, allPools, getters).ToUnixLineEndings(),