public static float Scale(this StoryDanger d) { float result; if (d != StoryDanger.None) { if (d != StoryDanger.Low) { if (d != StoryDanger.High) { result = 0f; } else { result = 2f; } } else { result = 1f; } } else { result = 0f; } return(result); }
static void Postfix(DangerWatcher __instance, ref StoryDanger __result) { if (Multiplayer.InInterface) { __result = __instance.dangerRatingInt; } }
public static float Scale(this StoryDanger d) { return(d switch { StoryDanger.None => 0f, StoryDanger.Low => 1f, StoryDanger.High => 2f, _ => 0f, });
public static float Scale(this StoryDanger d) { if (d == StoryDanger.None) { return(0f); } if (d == StoryDanger.Low) { return(1f); } if (d != StoryDanger.High) { return(0f); } return(2f); }
public static float Scale(this StoryDanger d) { switch (d) { case StoryDanger.None: return(0f); case StoryDanger.Low: return(1f); case StoryDanger.High: return(2f); default: return(0f); } }
// ===================== Main work function ===================== /// <summary> /// - Check if the support is still here. /// - Check current threat level. /// - Perform adequate treatment when a danger level transition occurs. /// - Apply an adrenaline bonus to nearby colonists according to current danger rate. /// </summary> public override void Tick() { base.Tick(); if (this.Map == null) { // This case can occur when the alert speaker has just been uninstalled. return; } if (IsSupportAlive(this.Map, this.Position, this.Rotation) == false) { this.Destroy(DestroyMode.Deconstruct); return; } // This treatment is performed periodically only once for all speakers. if (Find.TickManager.TicksGame > nextUpdateTick) // Strict greater than so this treatment is only done once for all alert speakers. { nextUpdateTick = Find.TickManager.TicksGame + updatePeriodInTicks; previousDangerRate = currentDangerRate; currentDangerRate = this.Map.dangerWatcher.DangerRating; if (currentDangerRate != previousDangerRate) { PerformTreatmentOnDangerRateChange(); } PerformSoundTreatment(); } // This treatment is performed by all alert speaker on update tick. if (nextUpdateTick == Find.TickManager.TicksGame + updatePeriodInTicks) { UpdateGlowerParameters(); if (this.powerComp.PowerOn) { TryApplyAdrenalineBonus(); } } // This treatment is performed every tick only once for all speakers. if (Find.TickManager.TicksGame > lastDrawingUpdateTick) { lastDrawingUpdateTick = Find.TickManager.TicksGame; UpdateDrawingParameters(); } }
// ===================== Main work function ===================== /// <summary> /// - Check if the supporting wall is still alive. /// - Check current threat level. /// - Perform adequate treatment when a danger level transition occurs. /// - Apply an adrenaline bonus to nearby colonists according to current danger rate. /// </summary> public override void Tick() { base.Tick(); if (this.Map == null) { // This case can occur when the alert speaker has just been uninstalled. return; } if (CheckIfSupportingWallIsAlive(this.Map, this.Position, this.Rotation) == false) { this.Destroy(DestroyMode.Deconstruct); return; } int tickCounter = Find.TickManager.TicksGame; if (tickCounter > lastUpdateTick) { // The following treatment is performed only once per tick for all speakers. lastUpdateTick = tickCounter; if ((tickCounter % GenTicks.TicksPerRealSecond) == 0) { previousDangerRate = currentDangerRate; currentDangerRate = this.Map.dangerWatcher.DangerRating; if (currentDangerRate != previousDangerRate) { PerformTreatmentOnDangerRateTransition(); } } PerformSoundTreatment(); ComputeDrawingParameters(); } // Update for each speaker. if ((tickCounter % GenTicks.TicksPerRealSecond) == 0) { if (powerComp.PowerOn) { PerformTreatmentDuringAlert(); } } PerformDrawingTreatment(); }
// ===================== Main Work Function ===================== /// <summary> /// - Checks if the supporting wall is still alive. /// - Checks current threat level. /// - Performs adequate treatment when a danger level transition occurs. /// - Applies an adrenaline bonus to nearby colonists according to current danger rate. /// </summary> public override void Tick() { if (CheckIfSupportingWallIsAlive(this.Position, this.Rotation) == false) { this.Destroy(DestroyMode.Deconstruct); } base.Tick(); int tickCounter = Find.TickManager.TicksGame; if (lastUpdateTick != tickCounter) { // The following treatment is performed only once per tick (static treatment). lastUpdateTick = tickCounter; if ((tickCounter % (2 * GenTicks.TicksPerRealSecond)) == 0) { DisplayActiveMote(); } if ((tickCounter % GenTicks.TicksPerRealSecond) == 0) { previousDangerRate = currentDangerRate; currentDangerRate = Find.StoryWatcher.watcherDanger.DangerRating; PerformTreatmentOnDangerRateTransition(); } PerformSoundTreatment(); ComputeDrawingParameters(); } // Update for each speaker. if ((tickCounter % GenTicks.TicksPerRealSecond) == 0) { if (powerComp.PowerOn) { PerformTreatmentDuringAlert(); } } PerformDrawingTreatment(); }
public StorytellerCompPropertiesStats(StorytellerCompProperties p) { this.compClass = p.compClass.FullName; this.minDaysPassed = p.minDaysPassed; this.minIncChancePopulationIntentFactor = p.minIncChancePopulationIntentFactor; Util.Populate(out allowedTargetTags, p.allowedTargetTags, d => new DefStat <IncidentTargetTagDef>(d)); Util.Populate(out disallowedTargetTags, p.disallowedTargetTags, d => new DefStat <IncidentTargetTagDef>(d)); switch (this.compClass) { case "RimWorld.StorytellerComp_CategoryIndividualMTBByBiome": if (p is StorytellerCompProperties_CategoryIndividualMTBByBiome cb) { this.category = Util.AssignDefStat(cb.category); this.applyCaravanVisibility = cb.applyCaravanVisibility; } break; case "RimWorld.StorytellerComp_CategoryMTB": if (p is StorytellerCompProperties_CategoryMTB cm) { this.category = Util.AssignDefStat(cm.category); this.mtbDays = cm.mtbDays; this.mtbDaysFactorByDaysPassedCurve = Util.Assign(cm.mtbDaysFactorByDaysPassedCurve, v => new SimpleCurveStats(v)); } break; case "RimWorld.StorytellerComp_DeepDrillInfestation": if (p is StorytellerCompProperties_DeepDrillInfestation cd) { this.baseMtbDaysPerDrill = cd.baseMtbDaysPerDrill; } break; case "RimWorld.StorytellerComp_Disease": if (p is StorytellerCompProperties_Disease d) { this.category = Util.AssignDefStat(d.category); } break; case "RimWorld.StorytellerComp_FactionInteraction": if (p is StorytellerCompProperties_FactionInteraction fi) { this.incident = Util.AssignDefStat(fi.incident); this.baseIncidentsPerYear = fi.baseIncidentsPerYear; this.minSpacingDays = fi.minSpacingDays; this.minDanger = fi.minDanger; this.fullAlliesOnly = fi.fullAlliesOnly; } break; case "RimWorld.StorytellerComp_OnOffCycle": if (p is StorytellerCompProperties_OnOffCycle ooc) { this.category = Util.AssignDefStat(GetCategory(ooc)); this.onDays = ooc.onDays; this.offDays = ooc.offDays; this.minSpacingDays = ooc.minDaysPassed; this.numIncidentsRange = Util.Assign(ooc.numIncidentsRange, v => new MinMaxFloatStats(v)); this.acceptFractionByDaysPassedCurve = Util.Assign(ooc.acceptFractionByDaysPassedCurve, v => new SimpleCurveStats(v)); this.acceptPercentFactorPerThreatPointsCurve = Util.Assign(ooc.acceptPercentFactorPerThreatPointsCurve, v => new SimpleCurveStats(v)); this.incident = Util.AssignDefStat(ooc.incident); // TODO this.applyRaidBeaconThreatMtbFactor = ooc.applyRaidBeaconThreatMtbFactor; this.forceRaidEnemyBeforeDaysPassed = ooc.forceRaidEnemyBeforeDaysPassed; } break; case "RimWorld.StorytellerComp_RandomMain": if (p is StorytellerCompProperties_RandomMain rm) { this.mtbDays = rm.mtbDays; Util.Populate(out this.categoryWeights, rm.categoryWeights, v => new FloatValueDefStat <IncidentCategoryDef>(v.category, v.weight)); this.maxThreatBigIntervalDays = rm.maxThreatBigIntervalDays; this.randomPointsFactorRange = Util.Assign(rm.randomPointsFactorRange, v => new MinMaxFloatStats(v)); this.skipThreatBigIfRaidBeacon = rm.skipThreatBigIfRaidBeacon; } break; case "RimWorld.StorytellerComp_SingleMTB": if (p is StorytellerCompProperties_SingleMTB smtb) { this.incident = Util.AssignDefStat(smtb.incident); this.mtbDays = smtb.mtbDays; } break; case "RimWorld.StorytellerComp_Triggered": if (p is StorytellerCompProperties_Triggered t) { this.incident = Util.AssignDefStat(t.incident); this.delayTicks = t.delayTicks; } break; case "RimWorld.StorytellerCompProperties_RefiringUniqueQuest": if (p is StorytellerCompProperties_RefiringUniqueQuest ruq) { this.incident = Util.AssignDefStat(ruq.incident); this.refireEveryDays = ruq.refireEveryDays; } break; case "RimWorld.StorytellerCompProperties_SingleOnceFixed": if (p is StorytellerCompProperties_SingleOnceFixed sof) { this.incident = Util.AssignDefStat(sof.incident); this.fireAfterDaysPassed = sof.fireAfterDaysPassed; } break; case "RimWorld.StorytellerComp_ClassicIntro": case "RimWorld.StorytellerComp_ShipChunkDrop": case "RimWorld.StorytellerCompProperties_RandomQuest": case "RimWorld.StorytellerComp_SingleOnceFixed": case "RimWorld.StorytellerComp_RefiringUniqueQuest": case "RimWorld.StorytellerComp_ThreatsGenerator": case "RimWorld.StorytellerComp_RandomQuest": // Do nothing break; default: Log.Warning("Unknown StorytellerProperty type of " + this.compClass); break; } }