private void AddRecordIfNotThereAlready(ThingKey key, ThingEntry record) { if (!entries.TryGetValue(key, out _)) { entries[key] = record; } }
public ThingEntry LookupThingEntry(ThingKey key) { if (entries.TryGetValue(key, out var result)) { return(result); } return(null); }
private void AddThingDef(ThingDef def, ThingType type) { if (def.MadeFromStuff) { foreach (var s in stuff) { if (!s.stuffProps.CanMake(def)) { continue; } var key = new ThingKey(def, s); var entry = CreateThingEntry(def, s, type); if (entry != null) { AddRecordIfNotThereAlready(key, entry); } } } else if (def.race != null && def.race.Animal) { if (def.race.hasGenders) { var femaleEntry = CreateThingEntry(def, Gender.Female, type); if (femaleEntry != null) { AddRecordIfNotThereAlready(new ThingKey(def, Gender.Female), femaleEntry); } var maleEntry = CreateThingEntry(def, Gender.Male, type); if (maleEntry != null) { AddRecordIfNotThereAlready(new ThingKey(def, Gender.Male), maleEntry); } } else { var key = new ThingKey(def, Gender.None); var entry = CreateThingEntry(def, Gender.None, type); if (entry != null) { AddRecordIfNotThereAlready(key, entry); } } } else { var key = new ThingKey(def, null); var entry = CreateThingEntry(def, null, Gender.None, type); if (entry != null) { AddRecordIfNotThereAlready(key, entry); } } }
public ThingEntry AddThingDefWithStuff(ThingDef def, ThingDef stuff, ThingType type) { ThingKey key = new ThingKey(def, stuff); ThingEntry entry = CreateThingEntry(def, stuff, type); if (entry != null) { AddRecordIfNotThereAlready(key, entry); } return(entry); }
public double CalculateThingCost(ThingKey thingKey) { var entry = ThingDatabase.Instance.LookupThingEntry(thingKey); if (entry != null) { return(entry.cost); } return(0); }
protected bool AddRecordIfNotThereAlready(ThingKey key, ThingEntry record) { if (entries.TryGetValue(key, out ThingEntry value)) { return(false); } else { entries[key] = record; return(true); } }
public ThingEntry LookupThingEntry(ThingKey key) { ThingEntry result; if (entries.TryGetValue(key, out result)) { return(result); } else { return(null); } }
public override bool Equals(System.Object o) { if (o == null) { return(false); } if (!(o is ThingKey)) { return(false); } ThingKey pair = (ThingKey)o; return(thingDef == pair.thingDef && stuffDef == pair.stuffDef); }