private static void                 _BuildTrace(ref StringBuilder s, ModHelperDef modHelperDef, Verbosity Severity, string content, Def atFault = null, string category = null, bool addInitialSectionDivider = true)
        {
            if (Severity <= Verbosity.NonFatalErrors)
            {
                addInitialSectionDivider = AppendSection(ref s, "(Error)", addInitialSectionDivider);
            }
            else if (Severity == Verbosity.Warnings)
            {
                addInitialSectionDivider = AppendSection(ref s, "(Warning)", addInitialSectionDivider);
            }
            if (
                (modHelperDef != null) &&
                (modHelperDef != Controller.Data.cclHelperDef)
                )
            {
                addInitialSectionDivider = AppendSection(ref s, modHelperDef.ModName, addInitialSectionDivider);
            }
            if (category != null)
            {
                addInitialSectionDivider = AppendSection(ref s, category, addInitialSectionDivider);
            }
            if (atFault != null)
            {
                // Name of class
                var defType = atFault.GetType().ToString();
                addInitialSectionDivider = AppendSection(ref s, defType, addInitialSectionDivider);
                addInitialSectionDivider = AppendSection(ref s, atFault.defName, addInitialSectionDivider);
            }

            addInitialSectionDivider = AppendSection(ref s, content, addInitialSectionDivider);
        }
        public bool Injected( ModHelperDef def )
        {
            if( def.tickerSwitcher.NullOrEmpty() )
            {
                return true;
            }

            foreach( var switcherSet in def.tickerSwitcher )
            {
                bool processThis = true;
                if( !switcherSet.requiredMod.NullOrEmpty() )
                {
                    processThis = Find_Extensions.ModByName( switcherSet.requiredMod ) != null;
                }
                if( processThis )
                {
                    foreach( var targetName in switcherSet.targetDefs )
                    {
                        var targetDef = DefDatabase< ThingDef >.GetNamed( targetName, false );
                        if( targetDef.tickerType != switcherSet.tickerType )
                        {
                            return false;
                        }
                    }
                }
            }

            return true;
        }
        public bool                         Inject(ModHelperDef def)
        {
            if (def.PostLoadInjectors.NullOrEmpty())
            {
                return(true);
            }

            foreach (var injectorType in def.PostLoadInjectors)
            {
                try
                {
                    var injectorObject = (SpecialInjector)Activator.CreateInstance(injectorType);
                    if (injectorObject == null)
                    {
                        CCL_Log.Message(string.Format("Unable to create instance of '{0}'", injectorType.ToString()));
                        return(false);
                    }
                    if (!injectorObject.Inject())
                    {
                        CCL_Log.Message(string.Format("Error injecting '{0}'", injectorType.ToString()));
                        return(false);
                    }
                }
                catch (Exception e)
                {
                    CCL_Log.Message(e.ToString(), string.Format("Error injecting '{0}'", injectorType.ToString()));
                    return(false);
                }
            }

            dictInjected.Add(def.defName, true);
            return(true);
        }
        public bool Inject( ModHelperDef def )
        {
            if( def.TraderKinds.NullOrEmpty() )
            {
                return true;
            }

            foreach( var traderKindSet in def.TraderKinds )
            {
                bool processThis = true;
                if( !traderKindSet.requiredMod.NullOrEmpty() )
                {
                    processThis = Find_Extensions.ModByName( traderKindSet.requiredMod ) != null;
                }
                if( processThis )
                {
                    var targetDef = traderKindSet.targetDef;
                    foreach( var stockGenerator in traderKindSet.stockGenerators )
                    {
                        var traderKindDef = DefDatabase<TraderKindDef>.GetNamed( targetDef, false );
                        traderKindDef.stockGenerators.Add( stockGenerator );
                        stockGenerator.PostLoad();
                        stockGenerator.ResolveReferences(traderKindDef);
                        CCL_Log.TraceMod(
                            def,
                            Verbosity.Injections,
                            string.Format( "Injecting {0} into {1}", stockGenerator.GetType().Name, traderKindDef.label ),
                            "TraderKinds" );
                    }
                }
            }

            dictInjected.Add( def, true );
            return true;
        }
Beispiel #5
0
        public bool                         Injected(ModHelperDef def)
        {
            if (def.Facilities.NullOrEmpty())
            {
                return(true);
            }

            foreach (var facilitySet in def.Facilities)
            {
                bool processThis = true;
                if (!facilitySet.requiredMod.NullOrEmpty())
                {
                    processThis = Find_Extensions.ModByName(facilitySet.requiredMod) != null;
                }
                if (processThis)
                {
                    var facilityDef = DefDatabase <ThingDef> .GetNamed(facilitySet.facility);

                    foreach (var target in facilitySet.targetDefs)
                    {
                        var targetDef = DefDatabase <ThingDef> .GetNamed(target);

                        var targetComp = targetDef.GetCompProperties <CompProperties_AffectedByFacilities>();
                        if (!targetComp.linkableFacilities.Contains(facilityDef))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Beispiel #6
0
        public bool                         Inject(ModHelperDef def)
        {
            if (def.Facilities.NullOrEmpty())
            {
                return(true);
            }

            foreach (var facilitySet in def.Facilities)
            {
                bool processThis = true;
                if (!facilitySet.requiredMod.NullOrEmpty())
                {
                    processThis = Find_Extensions.ModByName(facilitySet.requiredMod) != null;
                }
                if (processThis)
                {
                    var facilityDef = DefDatabase <ThingDef> .GetNamed(facilitySet.facility);

                    foreach (var target in facilitySet.targetDefs)
                    {
                        var targetDef = DefDatabase <ThingDef> .GetNamed(target);

                        LinkFacility(targetDef, facilityDef);
                    }
                }
            }

            return(true);
        }
Beispiel #7
0
        public bool                         Inject(ModHelperDef def)
        {
            if (def.MapComponents.NullOrEmpty())
            {
                return(true);
            }

            var existingComponents = Find.Map.components;

            foreach (var componentType in def.MapComponents)
            {
                if (!existingComponents.Exists(c => c.GetType() == componentType))
                {
                    var componentObject = (MapComponent)Activator.CreateInstance(componentType);
                    if (componentObject == null)
                    {
                        CCL_Log.Message(string.Format("Unable to create instance of '{0}'", componentType));
                        return(false);
                    }
                    existingComponents.Add(componentObject);
                }
            }

            return(true);
        }
        public bool                         Injected(ModHelperDef def)
        {
            if (def.ITabs.NullOrEmpty())
            {
                return(true);
            }

            for (var index = 0; index < def.ITabs.Count; index++)
            {
                var injectionSet = def.ITabs[index];
                if (
                    (!injectionSet.requiredMod.NullOrEmpty()) &&
                    (Find_Extensions.ModByName(injectionSet.requiredMod) == null)
                    )
                {
                    continue;
                }
                var thingDefs = DefInjectionQualifier.FilteredThingDefs(injectionSet.qualifier, ref injectionSet.qualifierInt, injectionSet.targetDefs);
                if (!thingDefs.NullOrEmpty())
                {
                    foreach (var thingDef in thingDefs)
                    {
                        if (
                            (thingDef.inspectorTabs.NullOrEmpty()) ||
                            (!thingDef.inspectorTabs.Contains(injectionSet.newITab))
                            )
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Beispiel #9
0
        public bool                         Inject(ModHelperDef def)
        {
            if (def.ThingDefAvailability.NullOrEmpty())
            {
                return(true);
            }

            for (int index = 0; index < def.ThingDefAvailability.Count; ++index)
            {
                var availabilitySet = def.ThingDefAvailability[index];

                bool processThis = true;
                if (!availabilitySet.requiredMod.NullOrEmpty())
                {
                    processThis = Find_Extensions.ModByName(availabilitySet.requiredMod) != null;
                }
                if (processThis)
                {
                    bool setMenuHidden  = !availabilitySet.menuHidden.NullOrEmpty();
                    bool setDesignation = !availabilitySet.designationCategory.NullOrEmpty();
                    bool setResearch    = availabilitySet.researchPrerequisites != null;

                    bool menuHidden = false;
                    List <ResearchProjectDef> research = null;

                    if (setMenuHidden)
                    {
                        menuHidden = availabilitySet.menuHidden.ToLower() == "true" ? true : false;
                    }
                    if (
                        (setResearch) &&
                        (availabilitySet.researchPrerequisites.Count > 0)
                        )
                    {
                        research = DefDatabase <ResearchProjectDef> .AllDefs.Where(projectDef => availabilitySet.researchPrerequisites.Contains(projectDef.defName)).ToList();
                    }

                    var targetDefs = DefDatabase <ThingDef> .AllDefs.Where(thingDef => availabilitySet.targetDefs.Contains(thingDef.defName)).ToList();

                    foreach (var target in targetDefs)
                    {
                        if (setMenuHidden)
                        {
                            target.menuHidden = menuHidden;
                        }
                        if (setDesignation)
                        {
                            target.ChangeDesignationCategory(availabilitySet.designationCategory);
                        }
                        if (setResearch)
                        {
                            target.researchPrerequisites = research;
                        }
                    }
                }
            }

            dictInjected.Add(def.defName, true);
            return(true);
        }
        public bool IsValid( ModHelperDef def, ref string errors )
        {
            if( def.tickerSwitcher.NullOrEmpty() )
            {
                return true;
            }

            bool isValid = true;

            foreach( var switcherSet in def.tickerSwitcher )
            {
                bool processThis = true;
                if( !switcherSet.requiredMod.NullOrEmpty() )
                {
                    processThis = Find_Extensions.ModByName( switcherSet.requiredMod ) != null;
                }
                if( processThis )
                {
                    foreach( var targetName in switcherSet.targetDefs )
                    {
                        var targetDef = DefDatabase< ThingDef >.GetNamed( targetName, false );
                        if( targetDef == null )
                        {
                            errors += string.Format( "Unable to resolve targetDef '{0}' in TickerSwitcher", targetName );
                            isValid = false;
                        }
                    }
                }
            }

            return isValid;
        }
        public bool Inject( ModHelperDef def )
        {
            if( def.Facilities.NullOrEmpty() )
            {
                return true;
            }

            foreach( var facilitySet in def.Facilities )
            {
                bool processThis = true;
                if( !facilitySet.requiredMod.NullOrEmpty() )
                {
                    processThis = Find_Extensions.ModByName( facilitySet.requiredMod ) != null;
                }
                if( processThis )
                {
                    var facilityDef = DefDatabase<ThingDef>.GetNamed( facilitySet.facility );
                    foreach( var target in facilitySet.targetDefs )
                    {
                        var targetDef = DefDatabase<ThingDef>.GetNamed( target );
                        LinkFacility( targetDef, facilityDef );
                    }
                }
            }

            return true;
        }
Beispiel #12
0
        public bool                         IsValid(ModHelperDef def, ref string errors)
        {
            if (def.tickerSwitcher.NullOrEmpty())
            {
                return(true);
            }

            bool isValid = true;

            foreach (var switcherSet in def.tickerSwitcher)
            {
                bool processThis = true;
                if (!switcherSet.requiredMod.NullOrEmpty())
                {
                    processThis = Find_Extensions.ModByName(switcherSet.requiredMod) != null;
                }
                if (processThis)
                {
                    foreach (var targetName in switcherSet.targetDefs)
                    {
                        var targetDef = DefDatabase <ThingDef> .GetNamed(targetName, false);

                        if (targetDef == null)
                        {
                            errors += string.Format("Unable to resolve targetDef '{0}' in TickerSwitcher", targetName);
                            isValid = false;
                        }
                    }
                }
            }

            return(isValid);
        }
Beispiel #13
0
        public bool                         Inject(ModHelperDef def)
        {
            if (def.TraderKinds.NullOrEmpty())
            {
                return(true);
            }

            for (var index = 0; index < def.TraderKinds.Count; index++)
            {
                var injectionSet = def.TraderKinds[index];
                if (
                    (!injectionSet.requiredMod.NullOrEmpty()) &&
                    (Find_Extensions.ModByName(injectionSet.requiredMod) == null)
                    )
                {
                    continue;
                }
                var traderKindDef = DefDatabase <TraderKindDef> .GetNamed(injectionSet.targetDef);

                foreach (var stockGenerator in injectionSet.stockGenerators)
                {
                    traderKindDef.stockGenerators.Add(stockGenerator);
                    stockGenerator.PostLoad();
                    stockGenerator.ResolveReferences(traderKindDef);
                    CCL_Log.TraceMod(
                        def,
                        Verbosity.Injections,
                        string.Format("Injecting {0} into {1}", stockGenerator.GetType().Name, traderKindDef.label),
                        "TraderKinds");
                }
            }

            dictInjected.Add(def, true);
            return(true);
        }
Beispiel #14
0
        public bool Inject( ModHelperDef def )
        {
            if( def.SpecialInjectors.NullOrEmpty() )
            {
                return true;
            }

            foreach( var injectorType in def.SpecialInjectors )
            {
                try
                {
                    var injectorObject = (SpecialInjector) Activator.CreateInstance( injectorType );
                    if( injectorObject == null )
                    {
                        CCL_Log.Message( string.Format( "Unable to create instance of '{0}'", injectorType.ToString() ) );
                        return false;
                    }
                    if( !injectorObject.Inject() )
                    {
                        CCL_Log.Message( string.Format( "Error injecting '{0}'", injectorType.ToString() ) );
                        return false;
                    }
                }
                catch( Exception e )
                {
                    CCL_Log.Message( e.ToString(), string.Format( "Error injecting '{0}'", injectorType.ToString() ) );
                    return false;
                }
            }

            dictInjected.Add( def.defName, true );
            return true;
        }
Beispiel #15
0
        public bool                         Inject(ModHelperDef def)
        {
            if (def.tickerSwitcher.NullOrEmpty())
            {
                return(true);
            }

            foreach (var switcherSet in def.tickerSwitcher)
            {
                bool processThis = true;
                if (!switcherSet.requiredMod.NullOrEmpty())
                {
                    processThis = Find_Extensions.ModByName(switcherSet.requiredMod) != null;
                }
                if (processThis)
                {
                    foreach (var targetName in switcherSet.targetDefs)
                    {
                        var targetDef = DefDatabase <ThingDef> .GetNamed(targetName, false);

                        targetDef.tickerType = switcherSet.tickerType;
                    }
                }
            }

            return(true);
        }
        public bool                         Injected(ModHelperDef def)
        {
            if (def.Facilities.NullOrEmpty())
            {
                return(true);
            }

            for (var index = 0; index < def.Facilities.Count; index++)
            {
                var injectionSet = def.Facilities[index];
                if (
                    (!injectionSet.requiredMod.NullOrEmpty()) &&
                    (Find_Extensions.ModByName(injectionSet.requiredMod) == null)
                    )
                {
                    continue;
                }
                var facilityDef = DefDatabase <ThingDef> .GetNamed(injectionSet.facility);

                var thingDefs = DefInjectionQualifier.FilteredThingDefs(injectionSet.qualifier, ref injectionSet.qualifierInt, injectionSet.targetDefs);
                if (!thingDefs.NullOrEmpty())
                {
                    foreach (var thingDef in thingDefs)
                    {
                        var targetComp = thingDef.GetCompProperties <CompProperties_AffectedByFacilities>();
                        if (!targetComp.linkableFacilities.Contains(facilityDef))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Beispiel #17
0
        public bool                         Injected(ModHelperDef def)
        {
            if (def.someList.NullOrEmpty())
            {
                return(true);
            }

            return(def.EngineLevelInjectionsComplete);
        }
Beispiel #18
0
        public bool Injected( ModHelperDef def )
        {
            if( def.someList.NullOrEmpty() )
            {
                return true;
            }

            return def.EngineLevelInjectionsComplete;
        }
Beispiel #19
0
 void                                InjectMapComponents()
 {
     // Inject the map components into the game
     foreach (var ModHelperDef in ModHelperDefs)
     {
         if (!ModHelperDef.MapComponentsInjected)
         {
             Log.Message("Community Core Library :: Injecting MapComponents for " + ModHelperDef.ModName);
             ModHelperDef.InjectMapComponents();
         }
     }
 }
Beispiel #20
0
 void                                InjectDesignators()
 {
     // Inject the designators into the categories
     foreach (var ModHelperDef in ModHelperDefs)
     {
         if (!ModHelperDef.DesignatorsInjected)
         {
             Log.Message("Community Core Library :: Injecting Designators for " + ModHelperDef.ModName);
             ModHelperDef.InjectDesignators();
         }
     }
 }
Beispiel #21
0
        public bool                         Inject(ModHelperDef def)
        {
            if (def.someList.NullOrEmpty())
            {
                return(true);
            }

            foreach (var something in def.someList)
            {
            }

            return(true);
        }
Beispiel #22
0
        public bool Inject( ModHelperDef def )
        {
            if( def.someList.NullOrEmpty() )
            {
                return true;
            }

            foreach( var something in def.someList )
            {
            }

            return true;
        }
Beispiel #23
0
        private static void                 _Trace(ModHelperDef modHelperDef, Verbosity Severity, string content, Def atFault = null, string category = null)
        {
#if RELEASE
            if (Severity > Verbosity.Validation)
            {
                return;
            }
#endif
            if (!_TraceFor(ref modHelperDef, Severity, atFault))
            {
                return;
            }
            var s = captureTarget;
            if (s == null)
            {
                s = BaseMessage();
            }
            else
            {
                s.Append("\t");
            }

            _BuildTrace(ref s, modHelperDef, Severity, content, atFault, category, (captureTarget == null));

            if (captureTarget == null)
            {
#if DEVELOPER
                Write(s.ToString());
#endif
                if (Severity <= Verbosity.NonFatalErrors)
                {
                    // Error
                    Verse.Log.Error(s.ToString());
                }
                else if (Severity == Verbosity.Warnings)
                {
                    // Warning
                    Verse.Log.Warning(s.ToString());
                }
                else
                {
                    // Wall of text
                    Verse.Log.Message(s.ToString());
                }
            }
            else
            {
                s.Append("\n");
            }
        }
Beispiel #24
0
        public bool                         IsValid(ModHelperDef def, ref string errors)
        {
            if (def.Designators.NullOrEmpty())
            {
                return(true);
            }

            bool isValid = true;

            foreach (var injectionSet in def.Designators)
            {
                var designatorType = injectionSet.designatorClass;
                if (
                    (designatorType == null) ||
                    (!designatorType.IsSubclassOf(typeof(Designator)))
                    )
                {
                    errors += string.Format("Unable to resolve designatorClass '{0}'", injectionSet.designatorClass);
                    isValid = false;
                }
                if (
                    (!injectionSet.reverseDesignator) &&
                    (string.IsNullOrEmpty(injectionSet.designationCategoryDef))
                    )
                {
                    errors += "Designator is not marked reverseDesignator and designationCategoryDef is null!";
                    isValid = false;
                }
                if (
                    (!string.IsNullOrEmpty(injectionSet.designationCategoryDef)) &&
                    (DefDatabase <DesignationCategoryDef> .GetNamed(injectionSet.designationCategoryDef, false) == null)
                    )
                {
                    errors += string.Format("Unable to resolve designationCategoryDef '{0}'", injectionSet.designationCategoryDef);
                    isValid = false;
                }
                if (
                    (!string.IsNullOrEmpty(injectionSet.designationCategoryDef)) &&
                    (injectionSet.designatorNextTo != null) &&
                    (!injectionSet.designatorNextTo.IsSubclassOf(typeof(Designator)))
                    )
                {
                    errors += string.Format("Unable to resolve designatorNextTo '{0}'", injectionSet.designatorNextTo);
                    isValid = false;
                }
            }

            return(isValid);
        }
Beispiel #25
0
        public bool IsValid( ModHelperDef def, ref string errors )
        {
            if( def.someList.NullOrEmpty() )
            {
                return true;
            }

            bool isValid = true;

            foreach( var something in def.someList )
            {
            }

            return isValid;
        }
Beispiel #26
0
        public bool                         IsValid(ModHelperDef def, ref string errors)
        {
            if (def.someList.NullOrEmpty())
            {
                return(true);
            }

            bool isValid = true;

            foreach (var something in def.someList)
            {
            }

            return(isValid);
        }
        public bool                         IsValid(ModHelperDef def, ref string errors)
        {
            if (def.TraderKinds.NullOrEmpty())
            {
                return(true);
            }

            bool isValid = true;

            for (int index = 0; index < def.TraderKinds.Count; ++index)
            {
                var  traderKindSet = def.TraderKinds[index];
                bool processThis   = true;
                if (!traderKindSet.requiredMod.NullOrEmpty())
                {
                    processThis = Find_Extensions.ModByName(traderKindSet.requiredMod) != null;
                }
                if (processThis)
                {
                    if (traderKindSet.targetDef.NullOrEmpty())
                    {
                        errors += string.Format("\n\ttargetDef in TraderKinds {0} is null", index);
                        isValid = false;
                    }
                    else
                    {
                        var target        = traderKindSet.targetDef;
                        var traderKindDef = DefDatabase <TraderKindDef> .GetNamed(target, false);

                        if (traderKindDef == null)
                        {
                            errors += string.Format("Unable to resolve targetDef '{0}' in TraderKinds", target);
                            isValid = false;
                        }
                    }
                    for (int index2 = 0; index2 < traderKindSet.stockGenerators.Count; ++index2)
                    {
                        if (traderKindSet.stockGenerators[index2] == null)
                        {
                            errors += string.Format("\n\tstockGenerator {0} in TraderKinds {1} is null", index2, index);
                            isValid = false;
                        }
                    }
                }
            }

            return(isValid);
        }
Beispiel #28
0
        public bool                         Injected(ModHelperDef def)
        {
            if (def.TraderKinds.NullOrEmpty())
            {
                return(true);
            }

            bool injected;

            if (!dictInjected.TryGetValue(def, out injected))
            {
                return(false);
            }

            return(injected);
        }
        public bool                         Injected(ModHelperDef def)
        {
            if (def.PostLoadInjectors.NullOrEmpty())
            {
                return(true);
            }

            bool injected;

            if (!dictInjected.TryGetValue(def.defName, out injected))
            {
                return(false);
            }

            return(injected);
        }
Beispiel #30
0
        public bool                         Injected(ModHelperDef def)
        {
            if (def.ThingDefAvailability.NullOrEmpty())
            {
                return(true);
            }

            bool injected;

            if (!dictInjected.TryGetValue(def.defName, out injected))
            {
                return(false);
            }

            return(injected);
        }
        public bool IsValid( ModHelperDef def, ref string errors )
        {
            if( def.TraderKinds.NullOrEmpty() )
            {
                return true;
            }

            bool isValid = true;

            for( int index = 0; index < def.TraderKinds.Count; ++index )
            {
                var traderKindSet = def.TraderKinds[ index ];
                bool processThis = true;
                if( !traderKindSet.requiredMod.NullOrEmpty() )
                {
                    processThis = Find_Extensions.ModByName( traderKindSet.requiredMod ) != null;
                }
                if( processThis )
                {
                    if( traderKindSet.targetDef.NullOrEmpty() )
                    {
                        errors += string.Format( "\n\ttargetDef in TraderKinds {0} is null", index );
                        isValid = false;
                    }
                    else
                    {
                        var target = traderKindSet.targetDef;
                        var traderKindDef = DefDatabase<TraderKindDef>.GetNamed( target, false );
                        if( traderKindDef == null )
                        {
                            errors += string.Format( "Unable to resolve targetDef '{0}' in TraderKinds", target );
                            isValid = false;
                        }
                    }
                    for( int index2 = 0; index2 < traderKindSet.stockGenerators.Count; ++index2 )
                    {
                        if( traderKindSet.stockGenerators[ index2 ] == null )
                        {
                            errors += string.Format( "\n\tstockGenerator {0} in TraderKinds {1} is null", index2, index );
                            isValid = false;
                        }
                    }
                }
            }

            return isValid;
        }
Beispiel #32
0
        public bool                         IsValid(ModHelperDef def, ref string errors)
        {
            if (def.TraderKinds.NullOrEmpty())
            {
                return(true);
            }

            bool isValid = true;

            for (int index = 0; index < def.TraderKinds.Count; ++index)
            {
                var injectionSet = def.TraderKinds[index];
                if (
                    (!injectionSet.requiredMod.NullOrEmpty()) &&
                    (Find_Extensions.ModByName(injectionSet.requiredMod) == null)
                    )
                {
                    continue;
                }
                for (int index2 = 0; index2 < injectionSet.stockGenerators.Count; ++index2)
                {
                    if (injectionSet.stockGenerators[index2] == null)
                    {
                        errors += string.Format("\n\tstockGenerator {0} in TraderKinds {1} is null", index2, index);
                        isValid = false;
                    }
                }
                if (injectionSet.targetDef.NullOrEmpty())
                {
                    errors += "targetDef is null";
                    isValid = false;
                }
                else
                {
                    var traderKindDef = DefDatabase <TraderKindDef> .GetNamed(injectionSet.targetDef, false);

                    if (traderKindDef == null)
                    {
                        errors += string.Format("Unable to resolve targetDef '{0}' in TraderKinds", injectionSet.targetDef);
                        isValid = false;
                    }
                }
            }

            return(isValid);
        }
Beispiel #33
0
        public bool                         Injected(ModHelperDef def)
        {
            if (def.Designators.NullOrEmpty())
            {
                return(true);
            }

            foreach (var injectionSet in def.Designators)
            {
                if (!injectionSet.DesignatorExists())
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #34
0
        public bool                         Inject(ModHelperDef def)
        {
            if (def.ThingComps.NullOrEmpty())
            {
                return(true);
            }

            for (var index = 0; index < def.ThingComps.Count; index++)
            {
                var injectionSet = def.ThingComps[index];
                if (
                    (!injectionSet.requiredMod.NullOrEmpty()) &&
                    (Find_Extensions.ModByName(injectionSet.requiredMod) == null)
                    )
                {
                    continue;
                }
                var thingDefs = DefInjectionQualifier.FilteredThingDefs(injectionSet.qualifier, ref injectionSet.qualifierInt, injectionSet.targetDefs);
                if (!thingDefs.NullOrEmpty())
                {
#if DEBUG
                    var stringBuilder = new StringBuilder();
                    stringBuilder.Append("ThingComps :: Qualifier returned: ");
#endif
                    foreach (var thingDef in thingDefs)
                    {
#if DEBUG
                        stringBuilder.Append(thingDef.defName + ", ");
#endif
                        // TODO:  Make a full copy using the comp in this def as a template
                        // Currently adds the comp in this def so all target use the same def
                        if (!thingDef.HasComp(injectionSet.compProps.compClass))
                        {
                            thingDef.comps.Add(injectionSet.compProps);
                        }
                    }
#if DEBUG
                    CCL_Log.Message(stringBuilder.ToString(), def.ModName);
#endif
                }
            }

            return(true);
        }
Beispiel #35
0
        public bool                         Injected(ModHelperDef def)
        {
            if (def.MapComponents.NullOrEmpty())
            {
                return(true);
            }

            var colonyMapComponents = Find.Map.components;

            foreach (var componentType in def.MapComponents)
            {
                if (Find_Extensions.MapComponent(componentType) == null)
                {
                    return(false);
                }
            }

            return(true);
        }
        public bool                         Inject(ModHelperDef def)
        {
            if (def.ITabs.NullOrEmpty())
            {
                return(true);
            }

            for (var index = 0; index < def.ITabs.Count; index++)
            {
                var injectionSet = def.ITabs[index];
                if (
                    (!injectionSet.requiredMod.NullOrEmpty()) &&
                    (Find_Extensions.ModByName(injectionSet.requiredMod) == null)
                    )
                {
                    continue;
                }
                var thingDefs = DefInjectionQualifier.FilteredThingDefs(injectionSet.qualifier, ref injectionSet.qualifierInt, injectionSet.targetDefs);
                if (!thingDefs.NullOrEmpty())
                {
#if DEBUG
                    var stringBuilder = new StringBuilder();
                    stringBuilder.Append("ITabs :: Qualifier returned: ");
#endif
                    foreach (var thingDef in thingDefs)
                    {
#if DEBUG
                        stringBuilder.Append(thingDef.defName + ", ");
#endif
                        if (!InjectITab(injectionSet.newITab, injectionSet.replaceITab, thingDef))
                        {
                            return(false);
                        }
                    }
#if DEBUG
                    CCL_Log.Message(stringBuilder.ToString(), def.ModName);
#endif
                }
            }

            return(true);
        }
Beispiel #37
0
        private static bool                 _TraceFor(ref ModHelperDef modHelperDef, Verbosity Severity, Def atFault)
        {
            Verbosity TraceAt = Verbosity.Default;

            if (
                (!Controller.Data.Mods.NullOrEmpty()) &&
                (!Controller.Data.ModHelperDefs.NullOrEmpty())
                )
            {
                if (
                    (modHelperDef == null) &&
                    (atFault != null)
                    )
                {
                    // Try to find the mod associated with this def

                    var mod = Find_Extensions.ModByDef(atFault);

                    if (mod != null)
                    {
                        modHelperDef = Find_Extensions.ModHelperDefForMod(mod);
                    }
                }
                if (modHelperDef != null)
                {
                    TraceAt = modHelperDef.Verbosity;
                    if (modHelperDef.Verbosity > captureVerbosity)
                    {
                        captureVerbosity = modHelperDef.Verbosity;
                    }
                }
                else if (atFault == null)
                {
                    TraceAt = captureVerbosity;
                }
                else
                {
                    TraceAt = Find_Extensions.HightestVerbosity;
                }
            }
            return(TraceAt >= Severity);
        }
        public bool                         Injected(ModHelperDef def)
        {
            if (def.Designators.NullOrEmpty())
            {
                return(true);
            }

            foreach (var designatorData in def.Designators)
            {
                var designationCategory = DefDatabase <DesignationCategoryDef> .GetNamed(designatorData.designationCategoryDef, false);

                if (!designationCategory.resolvedDesignators.Exists(d => d.GetType() == designatorData.designatorClass))
                {
                    // designator hasn't been injected yet
                    return(false);
                }
            }

            return(true);
        }
        public bool                         Inject(ModHelperDef def)
        {
            if (def.Facilities.NullOrEmpty())
            {
                return(true);
            }

            for (var index = 0; index < def.Facilities.Count; index++)
            {
                var injectionSet = def.Facilities[index];
                if (
                    (!injectionSet.requiredMod.NullOrEmpty()) &&
                    (Find_Extensions.ModByName(injectionSet.requiredMod) == null)
                    )
                {
                    continue;
                }
                var facilityDef = DefDatabase <ThingDef> .GetNamed(injectionSet.facility);

                var thingDefs = DefInjectionQualifier.FilteredThingDefs(injectionSet.qualifier, ref injectionSet.qualifierInt, injectionSet.targetDefs);
                if (!thingDefs.NullOrEmpty())
                {
#if DEBUG
                    var stringBuilder = new StringBuilder();
                    stringBuilder.Append("Facilities :: Qualifier returned: ");
#endif
                    foreach (var thingDef in thingDefs)
                    {
#if DEBUG
                        stringBuilder.Append(thingDef.defName + ", ");
#endif
                        LinkFacility(thingDef, facilityDef);
                    }
#if DEBUG
                    CCL_Log.Message(stringBuilder.ToString(), def.ModName);
#endif
                }
            }

            return(true);
        }
        public bool IsValid( ModHelperDef def, ref string errors )
        {
            if( def.Designators.NullOrEmpty() )
            {
                return true;
            }

            bool isValid = true;

            foreach( var designatorData in def.Designators )
            {
                var designatorType = designatorData.designatorClass;
                if(
                    ( designatorType == null )||
                    ( !designatorType.IsSubclassOf( typeof( Designator ) ) )
                )
                {
                    errors += string.Format( "Unable to resolve designatorClass '{0}'", designatorData.designatorClass );
                    isValid = false;
                }
                if(
                    ( string.IsNullOrEmpty( designatorData.designationCategoryDef ) )||
                    ( DefDatabase<DesignationCategoryDef>.GetNamed( designatorData.designationCategoryDef, false ) == null )
                )
                {
                    errors += string.Format( "Unable to resolve designationCategoryDef '{0}'", designatorData.designationCategoryDef );
                    isValid = false;
                }
                if(
                    ( designatorData.designatorNextTo != null )&&
                    ( !designatorData.designatorNextTo.IsSubclassOf( typeof( Designator ) ) )
                )
                {
                    errors += string.Format( "Unable to resolve designatorNextTo '{0}'", designatorData.designatorNextTo );
                    isValid = false;
                }
            }

            return isValid;
        }
Beispiel #41
0
        public bool IsValid( ModHelperDef def, ref string errors )
        {
            if( def.SpecialInjectors.NullOrEmpty() )
            {
                return true;
            }

            bool isValid = true;

            foreach( var injectorType in def.SpecialInjectors )
            {
                if(
                    ( injectorType == null )||
                    ( !injectorType.IsSubclassOf( typeof( SpecialInjector ) ) )
                )
                {
                    errors += string.Format( "\n\tUnable to resolve Special Injector '{0}'", injectorType.ToString() );
                    isValid = false;
                }
            }

            return isValid;
        }
        public bool Inject( ModHelperDef def )
        {
            if( def.ThingComps.NullOrEmpty() )
            {
                return true;
            }

            foreach( var compSet in def.ThingComps )
            {
                bool processThis = true;
                if( !compSet.requiredMod.NullOrEmpty() )
                {
                    processThis = Find_Extensions.ModByName( compSet.requiredMod ) != null;
                }
                if( processThis )
                {
                    foreach( var targetName in compSet.targetDefs )
                    {
                        // TODO:  Make a full copy using the comp in this def as a template
                        // Currently adds the comp in this def so all target use the same def
                        var targetDef = DefDatabase< ThingDef >.GetNamed( targetName );
                        if( targetDef.HasComp( compSet.compProps.compClass ) )
                        {
                            CCL_Log.TraceMod(
                                def,
                                Verbosity.Warnings,
                                string.Format( "Trying to inject ThingComp '{0}' into '{1}' when it already exists (another mod may have already injected).", compSet.compProps.compClass.ToString(), targetName ),
                                "ThingComp Injector" );
                        }
                        else
                        {
                            targetDef.comps.Add( compSet.compProps );
                        }
                    }
                }
            }

            return true;
        }
Beispiel #43
0
        private static bool _TraceFor( ref ModHelperDef modHelperDef, Verbosity Severity, Def atFault )
        {
            Verbosity TraceAt = Verbosity.Default;
            if(
                ( !Controller.Data.Mods.NullOrEmpty() )&&
                ( !Controller.Data.ModHelperDefs.NullOrEmpty() )
            )
            {
                if(
                    ( modHelperDef == null )&&
                    ( atFault != null )
                )
                {
                    // Try to find the mod associated with this def

                    var mod = Find_Extensions.ModByDef( atFault );

                    if( mod != null )
                    {
                        modHelperDef = Find_Extensions.ModHelperDefForMod( mod );
                    }
                }
                if( modHelperDef != null )
                {
                    TraceAt = modHelperDef.Verbosity;
                    if( modHelperDef.Verbosity > captureVerbosity )
                    {
                        captureVerbosity = modHelperDef.Verbosity;
                    }
                }
                else if ( atFault == null )
                {
                    TraceAt = captureVerbosity;
                }
                else
                {
                    TraceAt = Find_Extensions.HightestVerbosity;
                }
            }
            return ( TraceAt >= Severity );
        }
        public bool Injected( ModHelperDef def )
        {
            if( def.Designators.NullOrEmpty() )
            {
                return true;
            }

            foreach( var designatorData in def.Designators )
            {
                if (!designatorData.DesignatorExists() )
                {
                    return false;
                }
            }

            return true;
        }
        public bool Injected( ModHelperDef def )
        {
            if( def.ThingComps.NullOrEmpty() )
            {
                return true;
            }

            foreach( var compSet in def.ThingComps )
            {
                bool processThis = true;
                if( !compSet.requiredMod.NullOrEmpty() )
                {
                    processThis = Find_Extensions.ModByName( compSet.requiredMod ) != null;
                }
                if( processThis )
                {
                    foreach( var targetName in compSet.targetDefs )
                    {
                        var targetDef = DefDatabase< ThingDef >.GetNamed( targetName, false );
                        if(
                            ( compSet.compProps.compClass != null )&&
                            ( !targetDef.comps.Exists( s => ( s.compClass == compSet.compProps.compClass ) ) )
                        )
                        {
                            return false;
                        }
                        else if( targetDef.GetCompProperty( compSet.compProps.GetType() ) == null )
                        {
                            return false;
                        }
                    }
                }
            }

            return true;
        }
Beispiel #46
0
 public static void TraceMod( ModHelperDef modHelperDef, Verbosity Severity, string content, string category = null )
 {
     _Trace( modHelperDef, Severity, content, null, category );
 }
Beispiel #47
0
        public bool Injected( ModHelperDef def )
        {
            if( def.SpecialInjectors.NullOrEmpty() )
            {
                return true;
            }

            bool injected;
            if( !dictInjected.TryGetValue( def.defName, out injected ) )
            {
                return false;
            }

            return injected;
        }
Beispiel #48
0
        private static void _Trace( ModHelperDef modHelperDef, Verbosity Severity, string content, Def atFault = null, string category = null )
        {
            #if RELEASE
            if( Severity > Verbosity.Validation )
            {
                return;
            }
            #endif
            if( !_TraceFor( ref modHelperDef, Severity, atFault ) )
            {
                return;
            }
            var s = captureTarget;
            if( s == null )
            {
                s = BaseMessage();
            }
            else
            {
                s.Append( "\t" );
            }

            _BuildTrace( ref s, modHelperDef, Severity, content, atFault, category, ( captureTarget == null ) );

            if( captureTarget == null )
            {
            #if DEBUG
                Write( s.ToString() );
            #endif
                if( Severity <= Verbosity.NonFatalErrors )
                {
                    // Error
                    Verse.Log.Error( s.ToString() );
                }
                else if ( Severity == Verbosity.Warnings )
                {
                    // Warning
                    Verse.Log.Warning( s.ToString() );
                }
                else
                {
                    // Wall of text
                    Verse.Log.Message( s.ToString() );
                }
            }
            else
            {
                s.Append( "\n" );
            }
        }
        public bool IsValid()
        {
            if( !isValidChecked )
            {
                // Hopefully...
                isValid = true;

                var ModContentPack = Find_Extensions.ModByDefOfType<AdvancedResearchDef>( defName );
                modHelperDef = Find_Extensions.ModHelperDefForMod( ModContentPack );

                if(
                    ( modHelperDef == null )||
                    ( modHelperDef.dummy )
                )
                {
                    // Missing ModHelperDef (not dummyable)
                    isValid = false;
                    CCL_Log.TraceMod(
                        this,
                        Verbosity.FatalErrors,
                        "Requires ModHelperDef"
                    );
                }

            #if DEBUG
                // Validate research
                if( researchDefs.NullOrEmpty() )
                {
                    // Invalid project
                    isValid = false;
                    CCL_Log.TraceMod(
                        this,
                        Verbosity.FatalErrors,
                        "Missing researchDefs"
                    );
                }

                // Validate recipes
                if( IsRecipeToggle )
                {
                    // v0.12.7 - Obsoleted check to allow for automated machines
                    // Make sure thingDefs are of the appropriate type (has ITab_Bills)
                    /*
                    foreach( var thingDef in thingDefs )
                    {
                        if( thingDef.thingClass.GetInterface( "IBillGiver" ) == null )
                        {
                            // Invalid project
                            isValid = false;
                            CCL_Log.AppendTrace(
                                ref stringBuilder,
                                this,
                                Verbosity.FatalErrors,
                                "ThingDef '" + thingDef.defName + "' does not implement IBillGiver"
                            );
                        }
                    }
                    */
                }

                // Validate plant sowTags
                if( IsPlantToggle )
                {
                    // Make sure things are of the appropriate class (Plant)
                    foreach( var thingDef in thingDefs )
                    {
                        if(
                            ( thingDef.thingClass != typeof( Plant ) )&&
                            ( !thingDef.thingClass.IsSubclassOf( typeof(Plant) ) )
                        )
                        {
                            // Invalid plant
                            isValid = false;
                            CCL_Log.TraceMod(
                                this,
                                Verbosity.FatalErrors,
                                "ThingDef '" + thingDef.defName + "' ThingClass is not Plant based"
                            );
                        }
                    }

                    // Make sure sowTags are valid (!null or empty)
                    for( int i = 0; i < sowTags.Count; i++ )
                    {
                        var sowTag = sowTags[ i ];
                        if( sowTag.NullOrEmpty() )
                        {
                            isValid = false;
                            CCL_Log.TraceMod(
                                this,
                                Verbosity.FatalErrors,
                                "sowTag at index'" + i + "' is null or empty"
                            );
                        }
                    }
                }

                // Validate buildings
                if( IsBuildingToggle )
                {
                    // Make sure thingDefs are of the appropriate type (has proper designationCategory)
                    foreach( var thingDef in thingDefs )
                    {
                        if( ( thingDef.designationCategory.NullOrEmpty() )||
                            ( thingDef.designationCategory.ToLower() == "none" ) )
                        {
                            bool mhdUnlock = false;
                            foreach( var mhd in DefDatabase<ModHelperDef>.AllDefs )
                            {
                                if( mhd.ThingDefAvailability != null )
                                {
                                    foreach( var tda in mhd.ThingDefAvailability )
                                    {
                                        if(
                                            ( tda.targetDefs.Contains( thingDef.defName ) )&&
                                            ( !tda.designationCategory.NullOrEmpty() )&&
                                            ( tda.designationCategory.ToLower() != "none" )
                                        )
                                        {
                                            mhdUnlock = true;
                                            break;
                                        }
                                    }
                                }
                                if( mhdUnlock == true )
                                {
                                    break;
                                }
                            }
                            if( !mhdUnlock )
                            {
                                // Invalid project
                                isValid = false;
                                CCL_Log.TraceMod(
                                    this,
                                    Verbosity.FatalErrors,
                                    "ThingDef '" + thingDef.defName + "' :: designationCategory is null or empty"
                                );
                            }
                        }
                    }
                }

                // Validate help
                if( researchDefs.Count > 1 )
                {
                    if( ResearchConsolidator == null )
                    {
                        // Error processing data
                        isValid = false;
                        CCL_Log.TraceMod(
                            this,
                            Verbosity.FatalErrors,
                            string.Format( "No valid help consolidator for AdvancedResearchDef {0}", defName )
                        );
                    }
                    if( ( HasHelp )&&
                        ( ResearchConsolidator == this ) )
                    {
                        if( label.NullOrEmpty() )
                        {
                            // Error processing data
                            isValid = false;
                            CCL_Log.TraceMod(
                                this,
                                Verbosity.FatalErrors,
                                "Help Consolidator requires missing label"
                            );
                        }
                        if( description.NullOrEmpty() )
                        {
                            // Error processing data
                            isValid = false;
                            CCL_Log.TraceMod(
                                this,
                                Verbosity.FatalErrors,
                                "Help Consolidator requires missing description"
                            );
                        }
                    }
                }
            #endif
            }
            return isValid;
        }
        public bool Injected( ModHelperDef def )
        {
            if( def.Facilities.NullOrEmpty() )
            {
                return true;
            }

            foreach( var facilitySet in def.Facilities )
            {
                bool processThis = true;
                if( !facilitySet.requiredMod.NullOrEmpty() )
                {
                    processThis = Find_Extensions.ModByName( facilitySet.requiredMod ) != null;
                }
                if( processThis )
                {
                    var facilityDef = DefDatabase<ThingDef>.GetNamed( facilitySet.facility );

                    foreach( var target in facilitySet.targetDefs )
                    {
                        var targetDef = DefDatabase<ThingDef>.GetNamed( target );
                        var targetComp = targetDef.GetCompProperties<CompProperties_AffectedByFacilities>();
                        if( !targetComp.linkableFacilities.Contains( facilityDef ) )
                        {
                            return false;
                        }
                    }
                }
            }

            return true;
        }
        public bool IsValid( ModHelperDef def, ref string errors )
        {
            if( def.ThingComps.NullOrEmpty() )
            {
                return true;
            }

            bool isValid = true;

            foreach( var compSet in def.ThingComps )
            {
                bool processThis = true;
                if( !compSet.requiredMod.NullOrEmpty() )
                {
                    processThis = Find_Extensions.ModByName( compSet.requiredMod ) != null;
                }
                if( processThis )
                {
                    if( compSet.targetDefs.NullOrEmpty() )
                    {
                        errors += "\n\tNull or no targetDefs in ThingComps";
                        isValid = false;
                    }
                    if( compSet.compProps == null )
                    {
                        errors += "\n\tNull compProps in ThingComps";
                        isValid = false;
                    }
                    for( int index = 0; index < compSet.targetDefs.Count; ++index )
                    {
                        if( compSet.targetDefs[ index ].NullOrEmpty() )
                        {
                            errors += string.Format( "targetDef in ThingComps is null or empty at index {0}", index.ToString() );
                            isValid = false;
                        }
                        else
                        {
                            var target = compSet.targetDefs[ index ];
                            var targetDef = DefDatabase< ThingDef >.GetNamed( target, false );
                            if( targetDef == null )
                            {
                                errors += string.Format( "Unable to resolve targetDef '{0}' in ThingComps", target );
                                isValid = false;
                            }
                            else
                            {
                                if( compSet.compProps.compClass != null )
                                {
                                    if( targetDef.HasComp( compSet.compProps.compClass ) )
                                    {
                                        errors += string.Format( "targetDef '{0}' in ThingComps already has comp '{1}'", target, compSet.compProps.compClass );
                                        isValid = false;
                                    }
                                }
                                else if( compSet.compProps.GetType() != typeof( CompProperties ) )
                                {
                                    if( targetDef.GetCompProperty( compSet.compProps.GetType() ) != null )
                                    {
                                        errors += string.Format( "targetDef '{0}' in ThingComps already has comp '{1}'", target, compSet.compProps );
                                        isValid = false;
                                    }
                                }
                                else
                                {
                                    errors += string.Format( "Can not inject CompProperties without a compClass into '{0}'", target );
                                    isValid = false;
                                }
                            }
                        }
                    }
                }
            }

            return isValid;
        }
        public bool IsValid( ModHelperDef def, ref string errors )
        {
            if( def.Facilities.NullOrEmpty() )
            {
                return true;
            }

            bool isValid = true;

            for( int index = 0; index < def.Facilities.Count; ++index )
            {
                var facilitySet = def.Facilities[ index ];
                bool processThis = true;
                if( !facilitySet.requiredMod.NullOrEmpty() )
                {
                    processThis = Find_Extensions.ModByName( facilitySet.requiredMod ) != null;
                }
                if( processThis )
                {
                    if( facilitySet.facility.NullOrEmpty() )
                    {
                        errors += string.Format( "\n\tfacility in Facilities {0} is null", index );
                        isValid = false;
                    }
                    else
                    {
                        var facilityDef = DefDatabase<ThingDef>.GetNamed( facilitySet.facility, false );
                        if( facilityDef == null )
                        {
                            errors += string.Format( "Unable to resolve facility '{0}' in Facilities", facilitySet.facility );
                            isValid = false;
                        }
                        else if( facilityDef.GetCompProperties<CompProperties_Facility>() == null )
                        {
                            // Check comps
                            errors += string.Format( "'{0}' is missing CompFacility for facility injection", facilitySet.facility );
                            isValid = false;
                        }
                    }
                    for( int index2 = 0; index2 < facilitySet.targetDefs.Count; ++index2 )
                    {
                        var target = facilitySet.targetDefs[ index2 ];
                        var targetDef = DefDatabase<ThingDef>.GetNamed( target, false );
                        if( targetDef == null )
                        {
                            errors += string.Format( "Unable to resolve targetDef '{0}' in Facilities", target );
                            isValid = false;
                        }
                        else if( targetDef.GetCompProperties<CompProperties_AffectedByFacilities>() == null )
                        {
                            errors += string.Format( "'{0}' is missing CompAffectedByFacilities for facility injection", target );
                            isValid = false;
                        }
                    }
                }
            }

            return isValid;
        }
        public bool Injected( ModHelperDef def )
        {
            if( def.TraderKinds.NullOrEmpty() )
            {
                return true;
            }

            bool injected;
            if( !dictInjected.TryGetValue( def, out injected ) )
            {
                return false;
            }

            return injected;
        }
        public bool Inject( ModHelperDef def )
        {
            if( def.Designators.NullOrEmpty() )
            {
                return true;
            }

            foreach( var designatorData in def.Designators )
            {
                // Get the category
                var designationCategory = DefDatabase<DesignationCategoryDef>.GetNamed( designatorData.designationCategoryDef, false );

                // First instatiate and inject the designator into the list of resolved designators
                if ( !designatorData.DesignatorExists() )
                {
                    // Create the new designator
                    var designatorObject = (Designator) Activator.CreateInstance( designatorData.designatorClass );
                    if( designatorObject == null )
                    {
                        CCL_Log.Message( string.Format( "Unable to create instance of '{0}'", designatorData.designatorClass ) );
                        return false;
                    }

                    if( designatorData.designatorNextTo == null )
                    {
                        // Inject the designator
                        designationCategory._resolvedDesignators().Add( designatorObject );
                    }
                    else
                    {
                        // Prefers to be beside a specific designator
                        var designatorIndex = designationCategory._resolvedDesignators().FindIndex( d => (
                            ( d.GetType() == designatorData.designatorNextTo )
                        ) );

                        if( designatorIndex < 0 )
                        {
                            // Other designator doesn't exist (yet?)
                            // Inject the designator at the end
                            designationCategory._resolvedDesignators().Add( designatorObject );
                        }
                        else
                        {
                            // Inject beside desired designator
                            designationCategory._resolvedDesignators().Insert( designatorIndex + 1, designatorObject );
                        }
                    }
                }

                // Now inject the designator class into the list of classes as a saftey net for another mod resolving the category
                if( !designationCategory.specialDesignatorClasses.Exists( s => s == designatorData.designatorClass ) )
                {
                    if( designatorData.designatorNextTo == null )
                    {
                        // Inject the designator class at the end of the list
                        designationCategory.specialDesignatorClasses.Add( designatorData.designatorClass );
                    }
                    else
                    {
                        // Prefers to be beside a specific designator
                        var designatorIndex = designationCategory.specialDesignatorClasses.FindIndex( s => s == designatorData.designatorNextTo );

                        if( designatorIndex < 0 )
                        {
                            // Can't find desired designator class
                            // Inject the designator at the end
                            designationCategory.specialDesignatorClasses.Add( designatorData.designatorClass );
                        }
                        else
                        {
                            // Inject beside desired designator class
                            designationCategory.specialDesignatorClasses.Insert( designatorIndex + 1, designatorData.designatorClass );
                        }
                    }
                }
            }

            return true;
        }
Beispiel #55
0
        private static void _BuildTrace( ref StringBuilder s, ModHelperDef modHelperDef, Verbosity Severity, string content, Def atFault = null, string category = null, bool addInitialSectionDivider = true )
        {
            if( Severity <= Verbosity.NonFatalErrors )
            {
                addInitialSectionDivider = AppendSection( ref s, "(Error)", addInitialSectionDivider );
            }
            else if( Severity == Verbosity.Warnings )
            {
                addInitialSectionDivider = AppendSection( ref s, "(Warning)", addInitialSectionDivider );
            }
            if(
                ( modHelperDef != null )&&
                ( modHelperDef != Controller.Data.cclHelperDef )
            )
            {
                addInitialSectionDivider = AppendSection( ref s, modHelperDef.ModName, addInitialSectionDivider );
            }
            if( category != null )
            {
                addInitialSectionDivider = AppendSection( ref s, category, addInitialSectionDivider );
            }
            if( atFault != null )
            {
                // Name of class
                var defType = atFault.GetType().ToString();
                addInitialSectionDivider = AppendSection( ref s, defType, addInitialSectionDivider );
                addInitialSectionDivider = AppendSection( ref s, atFault.defName, addInitialSectionDivider );
            }

            addInitialSectionDivider = AppendSection( ref s, content, addInitialSectionDivider );
        }