public static void TraceMod(Def atFault, Verbosity Severity, string content, string category = null) { var mod = Find_Extensions.ModByDef(atFault); var modHelperDef = Find_Extensions.ModHelperDefForMod(mod); _Trace(modHelperDef, Severity, content, atFault, category); }
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 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 static void TraceMod(LoadedMod mod, Verbosity Severity, string content, string category = null) { var modHelperDef = Find_Extensions.ModHelperDefForMod(mod); _Trace(modHelperDef, Severity, content, null, category); }