public override void Execute(LevelingInfo levelingInfo) { string resolvedText = ResolveText(levelingInfo, Text); Message message = new Message(resolvedText, MessageTypeDefOf.SilentInput, levelingInfo.Pawn); Messages.Message(message, historical); }
public static bool EnoughTimeHasPassed(LevelingInfo levelingInfo) { DateTime currentDateTime = DateTime.UtcNow; var key = new ValueTuple <Pawn, SkillDef>(levelingInfo.Pawn, levelingInfo.SkillRecord.def); if (_timerCache.TryGetValue(key, out DateTime lastEntryDateTime)) { DateTime nextAllowedDateTime = lastEntryDateTime.AddSeconds(settings.Profile.GeneralSettingsContent.CooldownSeconds); if (currentDateTime < nextAllowedDateTime) { return(false); } } _timerCache[key] = currentDateTime; return(true); }
public override void Execute(LevelingInfo levelingInfo) { Pawn pawn = levelingInfo.Pawn; if (pawn.Map is null) { return; } string resolvedText = ResolveText(levelingInfo, Text); MoteMaker.ThrowText(pawn.DrawPos, pawn.Map, resolvedText); if (historical) { Message message = new Message(resolvedText, MessageTypeDefOf.SilentInput, pawn); Find.Archive.Add(message); } }
public void ExecuteActions(LevelingInfo levelingInfo) { if (!levelingInfo.Pawn.IsFreeColonist) { return; } for (int i = 0; i < preparedActions.Count; i++) { preparedActions[i].Execute(levelingInfo); } bool cooldownPassed = PawnSkillTimerCache.EnoughTimeHasPassed(levelingInfo); if (!cooldownPassed) { return; } for (int i = 0; i < preparedCooldownActions.Count; i++) { preparedCooldownActions[i].Execute(levelingInfo); } }