CodeGenFile generateInterface(ComponentData data)
        {
            var componentName = data.GetTypeName().ToComponentName(_ignoreNamespacesConfig.ignoreNamespaces);
            var memberData    = data.GetMemberData();
            var interfaceName = "I" + componentName.RemoveComponentSuffix();

            var template = memberData.Length == 0
                ? FLAG_INTERFACE_TEMPLATE
                : STANDARD_INTERFACE_TEMPLATE;

            var fileContent = template
                              .Replace("${InterfaceName}", interfaceName)
                              .Replace("${ComponentType}", data.GetTypeName())
                              .Replace("${ComponentName}", componentName)
                              .Replace("${componentName}", componentName.LowercaseFirst())
                              .Replace("${prefixedName}", data.GetUniquePrefix().LowercaseFirst() + componentName)
                              .Replace("${memberArgs}", getMemberArgs(memberData));

            return(new CodeGenFile(
                       "Components" + Path.DirectorySeparatorChar +
                       "Interfaces" + Path.DirectorySeparatorChar +
                       interfaceName + ".cs",
                       fileContent,
                       GetType().FullName
                       ));
        }
        CodeGenFile generateExtension(string contextName, ComponentData data)
        {
            var componentName = data.GetFullTypeName().ToComponentName(_ignoreNamespacesConfig.ignoreNamespaces);
            var index         = contextName + ComponentsLookupGenerator.COMPONENTS_LOOKUP + "." + componentName;
            var memberData    = data.GetMemberData();
            var template      = memberData.Length == 0
                                      ? FLAG_COMPONENT_TEMPLATE
                                      : STANDARD_COMPONENT_TEMPLATE;

            var fileContent = template
                              .Replace("${ContextName}", contextName)
                              .Replace("${ComponentType}", data.GetFullTypeName())
                              .Replace("${ComponentName}", componentName)
                              .Replace("${componentName}", componentName.LowercaseFirst())
                              .Replace("${prefixedName}", data.GetUniquePrefix().LowercaseFirst() + componentName)
                              .Replace("${Index}", index)
                              .Replace("${memberArgs}", getMemberArgs(memberData))
                              .Replace("${memberAssignment}", getMemberAssignment(memberData));

            return(new CodeGenFile(
                       contextName + Path.DirectorySeparatorChar +
                       "Components" + Path.DirectorySeparatorChar +
                       contextName + componentName.AddComponentSuffix() + ".cs",
                       fileContent,
                       GetType().FullName
                       ));
        }
        CodeGenFile generateInterface(string contextName, ComponentData data)
        {
            var optionalContextName = data.GetContextNames().Length > 1 ? contextName : string.Empty;
            var componentName       = data.GetTypeName().ToComponentName(_ignoreNamespacesConfig.ignoreNamespaces);
            var memberData          = data.GetMemberData();

            if (memberData.Length == 0)
            {
                memberData = new[] { new MemberData("bool", data.GetUniquePrefix().LowercaseFirst() + componentName) };
            }

            var eventTypeSuffix = string.Empty;
            var memberArgs      = ", " + getMemberArgs(memberData);

            if (data.GetMemberData().Length == 0)
            {
                switch (data.GetEventType())
                {
                case EventType.Added:
                    eventTypeSuffix = "Added";
                    memberArgs      = string.Empty;
                    break;

                case EventType.Removed:
                    eventTypeSuffix = "Removed";
                    memberArgs      = string.Empty;
                    break;
                }
            }
            else
            {
                switch (data.GetEventType())
                {
                case EventType.Removed:
                    eventTypeSuffix = "Removed";
                    memberArgs      = string.Empty;
                    break;

                case EventType.AddedOrRemoved:
                    eventTypeSuffix = "AddedOrRemoved";
                    break;
                }
            }

            var fileContent = INTERFACE_TEMPLATE
                              .Replace("${ContextName}", contextName)
                              .Replace("${OptionalContextName}", optionalContextName)
                              .Replace("${ComponentName}", componentName)
                              .Replace("${ComponentName}", componentName)
                              .Replace("${EventType}", eventTypeSuffix)
                              .Replace("${memberArgs}", memberArgs);

            return(new CodeGenFile(
                       "Events" + Path.DirectorySeparatorChar +
                       "Interfaces" + Path.DirectorySeparatorChar +
                       "I" + contextName + componentName + "Listener.cs",
                       fileContent,
                       GetType().FullName
                       ));
        }
        CodeGenFile generateSystem(string contextName, ComponentData data)
        {
            var componentName = data.GetTypeName().ToComponentName(_ignoreNamespacesConfig.ignoreNamespaces);
            var memberData    = data.GetMemberData();

            var groupEvent = memberData.Length == 0
                ? "AddedOrRemoved"
                : "Added";

            var filter = memberData.Length == 0
                ? "true"
                : "entity.has" + componentName;

            var cachedAccess = memberData.Length == 0
                ? "var " + data.GetUniquePrefix() + componentName + " = e." + data.GetUniquePrefix() + componentName + ";"
                : "var component = e." + componentName.LowercaseFirst() + ";";

            var methodArgs = memberData.Length == 0
                ? data.GetUniquePrefix() + componentName
                : getMethodArgs(memberData);

            var template = data.GetEventData().bindToEntity
                ? ENTITY_SYSTEM_TEMPLATE
                : SYSTEM_TEMPLATE;

            var fileContent = template
                              .Replace("${ContextName}", contextName)
                              .Replace("${contextName}", contextName.LowercaseFirst())
                              .Replace("${ComponentName}", componentName)
                              .Replace("${componentName}", componentName.LowercaseFirst())
                              .Replace("${GroupEvent}", groupEvent)
                              .Replace("${filter}", filter)
                              .Replace("${cachedAccess}", cachedAccess)
                              .Replace("${methodArgs}", methodArgs);

            return(new CodeGenFile(
                       "Events" + Path.DirectorySeparatorChar +
                       "Systems" + Path.DirectorySeparatorChar +
                       contextName + componentName + "EventSystem.cs",
                       fileContent,
                       GetType().FullName
                       ));
        }
        CodeGenFile generateInterface(ComponentData data)
        {
            var componentName = data.GetTypeName().ToComponentName(_ignoreNamespacesConfig.ignoreNamespaces);
            var memberData    = data.GetMemberData();

            if (memberData.Length == 0)
            {
                memberData = new[] { new MemberData("bool", data.GetUniquePrefix().LowercaseFirst() + componentName) };
            }

            var fileContent = INTERFACE_TEMPLATE
                              .Replace("${ComponentName}", componentName)
                              .Replace("${memberArgs}", getMemberArgs(memberData));

            return(new CodeGenFile(
                       "Events" + Path.DirectorySeparatorChar +
                       "Interfaces" + Path.DirectorySeparatorChar +
                       "I" + componentName + "Listener.cs",
                       fileContent,
                       GetType().FullName
                       ));
        }
 public static string PrefixedComponentName(this ComponentData data)
 {
     return(data.GetUniquePrefix().LowercaseFirst() + data.ComponentName());
 }
        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
                       ));
        }