Created
May 12, 2020 16:56
-
-
Save MadaraUchiha/c2a8e9a81c8ffd551c80fda10207ac36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PrisonersNeedRecruiting | |
open Verse | |
open RimWorld | |
let inline (!>) (x: ^a): ^b = | |
((^a or ^b): (static member op_Implicit: ^a -> ^b) x) | |
type MouseEvent = | |
| RightClick | |
| Else of int | |
let toMouseEvent ev = | |
match ev with | |
| 1 -> RightClick | |
| _ -> Else ev | |
type AlertPrisonersNonInteract() = | |
inherit Alert_Critical() | |
let mutable prevUnassignedPrisoner = List.empty | |
let mutable dismissed = false | |
member this.UnassignedPrisoners | |
with private get () = | |
PawnsFinder.AllMaps_PrisonersOfColonySpawned | |
|> Seq.filter (fun prisoner -> prisoner.guest.interactionMode = PrisonerInteractionModeDefOf.NoInteraction) | |
member private this.IsDirty() = | |
prevUnassignedPrisoner | |
<> Seq.toList this.UnassignedPrisoners | |
override this.GetLabel() = | |
match Seq.length this.UnassignedPrisoners with | |
| 1 -> "PrisonerSetToNonInteract" | |
| _ -> "PrisonersSetToNonInteract" | |
|> Translator.TranslateSimple | |
override this.GetExplanation() = | |
let coloredShortName (prisoner: Pawn) = !>prisoner.NameShortColored | |
let formattedPrisoners = | |
this.UnassignedPrisoners | |
|> Seq.map (coloredShortName >> (fun x -> " - " + x)) | |
|> Seq.fold (+) "\n" | |
TranslatorFormattedStringExtensions.Translate("PrisonersSetToNonInteractDesc", !>formattedPrisoners) | |
override this.GetReport() = | |
if this.IsDirty() then | |
do prevUnassignedPrisoner <- Seq.toList this.UnassignedPrisoners | |
do dismissed <- false | |
if dismissed then | |
AlertReport.Inactive | |
else | |
this.UnassignedPrisoners | |
|> ResizeArray<Pawn> // Convert to a C# List | |
|> AlertReport.CulpritsAre | |
override this.OnClick() = | |
match UnityEngine.Event.current.button |> toMouseEvent with | |
| RightClick -> base.OnClick() | |
| Else -> do dismissed <- true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment