public StoreIncidentEditor([NotNull] StoreIncident storeIncident) : base(storeIncident) { onlyOneOfTypeAllowed = true; _eventType = storeIncident.GetModExtension <EventExtension>()?.EventType ?? EventTypes.Default; _costBuffer = storeIncident.cost.ToString(); _capBuffer = storeIncident.eventCap.ToString(); _wagerBuffer = (storeIncidentVariables?.maxWager ?? 0).ToString(); _karmaTypeOptions = Data.KarmaTypes.Values.Select(t => new FloatMenuOption(t.ToString(), () => storeIncident.karmaType = t)).ToList(); }
private void PerformEventLookup(string query) { StoreIncident result = DefDatabase <StoreIncident> .AllDefs.FirstOrDefault( i => i.cost > 0 && (i.abbreviation.ToToolkit().EqualsIgnoreCase(query.ToToolkit()) || i.defName.ToToolkit().EqualsIgnoreCase(query.ToToolkit())) ); if (result == null) { return; } EventTypes eventType = result.GetModExtension <EventExtension>()?.EventType ?? EventTypes.Default; switch (eventType) { case EventTypes.Default: NotifyLookupComplete("TKUtils.Price.Limited".LocalizeKeyed(result.abbreviation.CapitalizeFirst(), result.cost.ToString("N0"))); return; case EventTypes.Item: case EventTypes.PawnKind: case EventTypes.Trait: NotifyLookupComplete("TKUtils.Price.Overridden".LocalizeKeyed(eventType.ToString())); return; case EventTypes.Misc: NotifyLookupComplete("TKUtils.Price.External".Localize()); return; case EventTypes.Variable: NotifyLookupComplete( new[] { "TKUtils.Price.Variables".LocalizeKeyed(result.abbreviation.CapitalizeFirst(), result.cost.ToString("N0")), "TKUtils.Price.External".Localize() }.GroupedJoin() ); return; } }