public static void SetFlagPrefix(this ComponentData data, string prefix) { data[COMPONENT_FLAG_PREFIX] = prefix; }
public static string Event(this ComponentData data, string contextName, EventData eventData) { var optionalContextName = data.GetContextNames().Length > 1 ? contextName : string.Empty; return(optionalContextName + data.ComponentName() + GetEventTypeSuffix(eventData)); }
CodeGenFile[] generate(ComponentData data) { return(data.GetContextNames() .SelectMany(contextName => generate(contextName, data)) .ToArray()); }
CodeGenFile generateSystem(string contextName, ComponentData data) { var optionalContextName = data.GetContextNames().Length > 1 ? contextName : string.Empty; var componentName = data.GetTypeName().ToComponentName(_ignoreNamespacesConfig.ignoreNamespaces); var memberData = data.GetMemberData(); var methodArgs = ", " + (memberData.Length == 0 ? data.GetUniquePrefix() + componentName : getMethodArgs(memberData)); var eventTypeSuffix = string.Empty; var filter = string.Empty; if (data.GetMemberData().Length == 0) { switch (data.GetEventType()) { case EventType.Added: eventTypeSuffix = "Added"; methodArgs = string.Empty; filter = "entity." + data.GetUniquePrefix() + componentName; break; case EventType.Removed: eventTypeSuffix = "Removed"; methodArgs = string.Empty; filter = "!entity." + data.GetUniquePrefix() + componentName; break; case EventType.AddedOrRemoved: filter = "true"; break; } } else { switch (data.GetEventType()) { case EventType.Added: filter = "entity.has" + componentName; break; case EventType.Removed: eventTypeSuffix = "Removed"; methodArgs = string.Empty; filter = "!entity.has" + componentName; break; case EventType.AddedOrRemoved: eventTypeSuffix = "AddedOrRemoved"; filter = "true"; break; } } if (data.GetEventBindToEntity()) { if (filter == "true") { filter = "entity.has${OptionalContextName}${ComponentName}Listener"; } else { filter += " && entity.has${OptionalContextName}${ComponentName}Listener"; } } filter = filter .Replace("${OptionalContextName}", optionalContextName) .Replace("${ComponentName}", componentName); var cachedAccess = memberData.Length == 0 ? "var " + data.GetUniquePrefix() + componentName + " = e." + data.GetUniquePrefix() + componentName + ";" : "var component = e." + componentName.LowercaseFirst() + ";"; var template = data.GetEventBindToEntity() ? ENTITY_SYSTEM_TEMPLATE : SYSTEM_TEMPLATE; var fileContent = template .Replace("${ContextName}", contextName) .Replace("${contextName}", contextName.LowercaseFirst()) .Replace("${OptionalContextName}", optionalContextName) .Replace("${optionalContextName}", optionalContextName == string.Empty ? string.Empty : optionalContextName.LowercaseFirst()) .Replace("${ComponentName}", componentName) .Replace("${contextDependentComponentName}", optionalContextName == string.Empty ? componentName.LowercaseFirst() : componentName) .Replace("${GroupEvent}", data.GetEventType().ToString()) .Replace("${filter}", filter) .Replace("${cachedAccess}", cachedAccess) .Replace("${EventType}", eventTypeSuffix) .Replace("${methodArgs}", methodArgs); return(new CodeGenFile( "Events" + Path.DirectorySeparatorChar + "Systems" + Path.DirectorySeparatorChar + optionalContextName + componentName + "EventSystem.cs", fileContent, GetType().FullName )); }
public static string ComponentNameWithContext(this ComponentData data, string contextName) { return(contextName + data.ComponentName()); }
public static string GetTypeName(this ComponentData data) { return((string)data[COMPONENT_TYPE]); }
public void Provide(Type type, ComponentData data) { data.SetlTypeName(type.ToCompilableString()); }
public static void SetContextNames(this ComponentData data, string[] contextNames) { data[COMPONENT_CONTEXTS] = contextNames; }
public static string ComponentNameValidLowercaseFirst(this ComponentData data) { return(ComponentName(data).LowercaseFirst().AddPrefixIfIsKeyword()); }
public void Provide(Type type, ComponentData data) { var contextNames = GetContextNamesOrDefault(type); data.SetContextNames(contextNames); }
public static string[] GetContextNames(this ComponentData data) { return((string[])data[COMPONENT_CONTEXTS]); }
public static void IsUnique(this ComponentData data, bool isUnique) { data[COMPONENT_IS_UNIQUE] = isUnique; }
public static bool IsUnique(this ComponentData data) { return((bool)data[COMPONENT_IS_UNIQUE]); }
public void Provide(Type type, ComponentData data) { data.SetFlagPrefix(getFlagPrefix(type)); }
public static MemberData[] GetMemberData(this ComponentData data) { return((MemberData[])data[COMPONENT_MEMBER_INFOS]); }
public static string EventListener(this ComponentData data, string contextName, EventData eventData) { return(data.Event(contextName, eventData).AddListenerSuffix()); }
public static void SetMemberData(this ComponentData data, MemberData[] memberInfos) { data[COMPONENT_MEMBER_INFOS] = memberInfos; }
public static bool ShouldGenerateMethods(this ComponentData data) { return((bool)data[COMPONENT_GENERATE_METHODS]); }
public static void SetlTypeName(this ComponentData data, string fullTypeName) { data[COMPONENT_TYPE] = fullTypeName; }
public static void ShouldGenerateMethods(this ComponentData data, bool generate) { data[COMPONENT_GENERATE_METHODS] = generate; }
CodeGenFile[] generateExtensions(ComponentData data) { return(data.GetContextNames() .Select(contextName => generateExtension(contextName, data)) .ToArray()); }
public static bool ShouldGenerateIndex(this ComponentData data) { return((bool)data[COMPONENT_GENERATE_INDEX]); }
public static string ComponentName(this ComponentData data) { return(data.GetTypeName().ToComponentName(ignoreNamespaces)); }
public static void ShouldGenerateIndex(this ComponentData data, bool generate) { data[COMPONENT_GENERATE_INDEX] = generate; }
public static string PrefixedComponentName(this ComponentData data) { return(data.GetUniquePrefix().LowercaseFirst() + data.ComponentName()); }
public void Provide(Type type, ComponentData data) { data.ShouldGenerateIndex(getGenerateIndex(type)); }
public static string EventListener(this ComponentData data, string contextName, EventData eventData) { return(data.Event(contextName, eventData) + "Listener"); }
public ComponentData(ComponentData data) : base(data) { }
CodeGenFile[] generate(ComponentData data) { return(new[] { generateInterface(data) } .Concat(data.GetContextNames().Select(contextName => generateEntityInterface(contextName, data))) .ToArray()); }
public static string GetFlagPrefix(this ComponentData data) { return((string)data[COMPONENT_FLAG_PREFIX]); }