public static bool IsLockedOut(this BuildableDef buildableDef) { bool rVal; var foo = buildableDef.GetHashCode(); if (!isLockedOut.TryGetValue(buildableDef.shortHash, out rVal)) { #if DEBUG CCL_Log.TraceMod( buildableDef, Verbosity.Stack, "IsLockedOut()" ); #endif // Is it a frame or blueprint? if ( (buildableDef.defName.EndsWith("_Frame")) || (buildableDef.defName.EndsWith("_Blueprint")) || (buildableDef.defName.EndsWith("_Blueprint_Install")) ) { isLockedOut.Add(buildableDef.shortHash, true); return(true); } // Logic is faulty ( Thingdefs inherit from buildable defs, checking for existence of blueprint eliminates all non-buildings ) // After correcting logic (Valid: blueprint == null [items], or blueprint != null and designation != null/None [buildings]), // the check no longer makes sense, since only defs with a designation category ever get a blueprint assigned. -- Fluffy. // //// Is the designationCategory locked out? //// only applies if it is buildable (has a blueprint def), but no category. //if( // buildableDef.blueprintDef != null && // ( buildableDef.designationCategory.NullOrEmpty()|| // buildableDef.designationCategory == "None" ) //) //{ // isLockedOut.Add( buildableDef, true ); // return true; //} // If the research locks it's out, check for an ARDef unlock if ( (buildableDef.researchPrerequisites != null) && (buildableDef.researchPrerequisites.Any(def => def.IsLockedOut())) && (!Controller.Data.AdvancedResearchDefs.Any(a => ( (a.IsBuildingToggle) && (!a.HideDefs) && (a.thingDefs.Contains(buildableDef as ThingDef)) )))) { rVal = true; } // Cache the result isLockedOut.Add(buildableDef.shortHash, rVal); } return(rVal); }
public override int GetHashCode() { var num1 = 7437233; if (Thing != null) { num1 ^= Thing.GetHashCode() * 712433; } var num2 = num1 ^ BuildableDef.GetHashCode() * 345111; if (StuffDef != null) { num2 ^= StuffDef.GetHashCode() * 666613; } var thingDef = BuildableDef as ThingDef; if (thingDef == null) { return(num2); } InfusionSet inf; if (Thing != null && Thing.TryGetInfusions(out inf)) { if (inf.prefix != null) { num2 ^= inf.prefix.GetHashCode(); } if (inf.suffix != null) { num2 ^= inf.suffix.GetHashCode(); } } if (thingDef.useHitPoints) { num2 = num2 ^ HitPoints * 743273 ^ MaxHitPoints * 7437; } return(num2); }