public static bool TryScanForMotion(IncidentParms parms, IncidentDef incidentDef) { // Can spot? if (!ResearchProjectDefOf.BasicScoutingTehniques.IsFinished) { return(false); } // Detected float spottingPower = CalculateSpottingPower((Map)parms.target); if (spottingPower < new IntRange(0, 100).RandomInRange) { return(false); } // Delay IDelayHolder delay = DelayRaid(parms, incidentDef); // Indentify type IncidentDef spottedType = TryIdentifyType(parms, incidentDef, spottingPower); // Send Letter and Alert NotifySpotted(parms, delay, spottedType); return(true); }
public void SetAlertIncident(IDelayHolder delay, IncidentDef incidentDef) { string alertDescription = incidentDef?.LabelCap ?? "S.UnidentifiedMovement".Translate(); this.delay = delay; description = alertDescription; }
public static Letter NewLetter(IncidentParms parms, IDelayHolder delay, IncidentDef incidentDef = null) { if (incidentDef == null || parms.points > -1f) { return(LetterMaker.MakeLetter(LetterLabel.Translate(), GetLetterText(delay, parms, incidentDef), LetterDefOf.ThreatBig, new TargetInfo(parms.spawnCenter, (Map)parms.target))); } return(LetterMaker.MakeLetter(LetterLabel.Translate(), GetLetterText(delay, parms, incidentDef), LetterDefOf.NeutralEvent, new TargetInfo(parms.spawnCenter, (Map)parms.target))); }
private static IDelayHolder DelayRaid(IncidentParms parms, IncidentDef incidentDef) { IDelayHolder delay = CalculateDelay(parms); QueuedIncident qi = new QueuedIncident(new FiringIncident(incidentDef, null, parms), delay.GetGlobalDelay()); Find.Storyteller.incidentQueue.Add(qi); return(delay); }
private static string GetLetterText(IDelayHolder delay, IncidentParms parms, IncidentDef incidentDef = null) { StringBuilder letterText = new StringBuilder(); // description (detected text) letterText.AppendLine(GetDescription(parms, incidentDef)); // count letterText.AppendLine("S.LetterQuantityUnidendified".Translate()); // type letterText.AppendLine(GetTypeDescription(parms, incidentDef)); // arrival time letterText.Append("S.LetterTime".Translate()); letterText.Append(" " + delay.ToStringRelativeDelayToPeriod()); return(letterText.ToString()); }
public AlertIncident(IDelayHolder delay, IncidentDef incidentDef) : this() { SetAlertIncident(delay, incidentDef); }
private static void NotifySpotted(IncidentParms parms, IDelayHolder delay, IncidentDef incidentDef = null) { Find.LetterStack.ReceiveLetter(SpottedLetter.NewLetter(parms, delay, incidentDef)); Alert_Spotted.AddIncident(new AlertIncident(delay, incidentDef)); }