public IEnumerable <Thing> ThingsToSpawnAfterLoad() { Dictionary <ushort, ThingDef> thingDefsByShortHash = new Dictionary <ushort, ThingDef>(); foreach (ThingDef current in DefDatabase <ThingDef> .AllDefs) { if (thingDefsByShortHash.ContainsKey(current.shortHash)) { Log.Error(string.Concat(new object[] { "Hash collision between ", current, " and ", thingDefsByShortHash[current.shortHash], ": both have short hash ", current.shortHash })); } else { thingDefsByShortHash.Add(current.shortHash, current); } } List <Thing> loadables = new List <Thing>(); MapSerializeUtility.LoadUshort(this.compressedData, this.map, delegate(IntVec3 c, ushort val) { if (val == 0) { return; } ThingDef def = null; try { def = thingDefsByShortHash[val]; } catch (KeyNotFoundException) { Log.Error("Map compressor decompression error: No thingDef with short hash " + val + ". Adding as null to dictionary."); thingDefsByShortHash.Add(val, null); } Thing thing = ThingMaker.MakeThing(def, null); thing.SetPositionDirect(c); loadables.Add(thing); }); return(loadables); }
internal void <> m__0(IntVec3 c, ushort val) { if (val == 0) { return; } ThingDef thingDef = BackCompatibility.BackCompatibleThingDefWithShortHash_Force(val, this.major, this.minor); if (thingDef == null) { try { thingDef = this.thingDefsByShortHash[val]; } catch (KeyNotFoundException) { ThingDef thingDef2 = BackCompatibility.BackCompatibleThingDefWithShortHash(val); if (thingDef2 != null) { thingDef = thingDef2; this.thingDefsByShortHash.Add(val, thingDef2); } else { Log.Error("Map compressor decompression error: No thingDef with short hash " + val + ". Adding as null to dictionary.", false); this.thingDefsByShortHash.Add(val, null); } } } if (thingDef != null) { try { Thing thing = ThingMaker.MakeThing(thingDef, null); thing.SetPositionDirect(c); this.loadables.Add(thing); } catch (Exception arg) { Log.Error("Could not instantiate compressed thing: " + arg, false); } } }
public IEnumerable <Thing> ThingsToSpawnAfterLoad() { Dictionary <ushort, ThingDef> thingDefsByShortHash = new Dictionary <ushort, ThingDef>(); foreach (ThingDef current in DefDatabase <ThingDef> .AllDefs) { if (thingDefsByShortHash.ContainsKey(current.shortHash)) { Log.Error(string.Concat(new object[] { "Hash collision between ", current, " and ", thingDefsByShortHash[current.shortHash], ": both have short hash ", current.shortHash }), false); } else { thingDefsByShortHash.Add(current.shortHash, current); } } int major = VersionControl.MajorFromVersionString(ScribeMetaHeaderUtility.loadedGameVersion); int minor = VersionControl.MinorFromVersionString(ScribeMetaHeaderUtility.loadedGameVersion); List <Thing> loadables = new List <Thing>(); MapSerializeUtility.LoadUshort(this.compressedData, this.map, delegate(IntVec3 c, ushort val) { if (val == 0) { return; } ThingDef thingDef = BackCompatibility.BackCompatibleThingDefWithShortHash_Force(val, major, minor); if (thingDef == null) { try { thingDef = thingDefsByShortHash[val]; } catch (KeyNotFoundException) { ThingDef thingDef2 = BackCompatibility.BackCompatibleThingDefWithShortHash(val); if (thingDef2 != null) { thingDef = thingDef2; thingDefsByShortHash.Add(val, thingDef2); } else { Log.Error("Map compressor decompression error: No thingDef with short hash " + val + ". Adding as null to dictionary.", false); thingDefsByShortHash.Add(val, null); } } } if (thingDef != null) { try { Thing thing = ThingMaker.MakeThing(thingDef, null); thing.SetPositionDirect(c); loadables.Add(thing); } catch (Exception arg) { Log.Error("Could not instantiate compressed thing: " + arg, false); } } }); return(loadables); }