public override StateGraph CreateGraph() { StateGraph stateGraph = new StateGraph(); if (!ModLister.RoyaltyInstalled) { Log.ErrorOnce("Shuttle crash rescue is a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 3454535); return(stateGraph); } LordToil_Wait lordToil_Wait = new LordToil_Wait(); stateGraph.AddToil(lordToil_Wait); stateGraph.StartingToil = lordToil_Wait; LordToil_EnterShuttleOrLeave lordToil_EnterShuttleOrLeave = new LordToil_EnterShuttleOrLeave(shuttle, LocomotionUrgency.Sprint); stateGraph.AddToil(lordToil_EnterShuttleOrLeave); Transition transition = new Transition(lordToil_Wait, lordToil_EnterShuttleOrLeave); transition.AddPreAction(new TransitionAction_Custom(InitializeLoading)); transition.AddTrigger(new Trigger_Custom((TriggerSignal signal) => signal.type == TriggerSignalType.Tick && shuttle.Spawned)); stateGraph.AddTransition(transition); return(stateGraph); }
public override StateGraph CreateGraph() { StateGraph stateGraph = new StateGraph(); if (!ModLister.RoyaltyInstalled) { Log.ErrorOnce("Bestowing ceremony is a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 3454535); return(stateGraph); } LordToil_Wait lordToil_Wait = new LordToil_Wait(); stateGraph.AddToil(lordToil_Wait); LordToil_Wait lordToil_Wait2 = new LordToil_Wait(); stateGraph.AddToil(lordToil_Wait2); LordToil_Wait lordToil_Wait3 = new LordToil_Wait(); stateGraph.AddToil(lordToil_Wait3); LordToil_BestowingCeremony_MoveInPlace lordToil_BestowingCeremony_MoveInPlace = new LordToil_BestowingCeremony_MoveInPlace(spotCell, target); stateGraph.AddToil(lordToil_BestowingCeremony_MoveInPlace); LordToil_BestowingCeremony_Wait lordToil_BestowingCeremony_Wait = new LordToil_BestowingCeremony_Wait(target); stateGraph.AddToil(lordToil_BestowingCeremony_Wait); exitToil = ((shuttle == null) ? ((LordToil) new LordToil_ExitMap(LocomotionUrgency.Walk)) : ((LordToil) new LordToil_EnterShuttleOrLeave(shuttle, LocomotionUrgency.Walk, canDig: true, interruptCurrentJob: true))); stateGraph.AddToil(exitToil); Transition transition = new Transition(lordToil_Wait, lordToil_Wait2); transition.AddTrigger(new Trigger_Custom((TriggerSignal signal) => signal.type == TriggerSignalType.Tick && bestower.Spawned)); stateGraph.AddTransition(transition); Transition transition2 = new Transition(lordToil_Wait2, lordToil_BestowingCeremony_MoveInPlace); transition2.AddTrigger(new Trigger_TicksPassed(600)); stateGraph.AddTransition(transition2); Transition transition3 = new Transition(lordToil_BestowingCeremony_MoveInPlace, lordToil_BestowingCeremony_Wait); transition3.AddTrigger(new Trigger_Custom((TriggerSignal signal) => signal.type == TriggerSignalType.Tick && bestower.Position == spotCell)); stateGraph.AddTransition(transition3); Transition transition4 = new Transition(lordToil_BestowingCeremony_Wait, exitToil); transition4.AddTrigger(new Trigger_TicksPassed(30000)); transition4.AddPostAction(new TransitionAction_Custom((Action) delegate { QuestUtility.SendQuestTargetSignals(lord.questTags, "CeremonyExpired", lord.Named("SUBJECT")); })); stateGraph.AddTransition(transition4); Transition transition5 = new Transition(lordToil_BestowingCeremony_Wait, lordToil_Wait3); transition5.AddTrigger(new Trigger_Memo("CeremonyFinished")); transition5.AddPostAction(new TransitionAction_Custom((Action) delegate { QuestUtility.SendQuestTargetSignals(lord.questTags, "CeremonyDone", lord.Named("SUBJECT")); })); stateGraph.AddTransition(transition5); Transition transition6 = new Transition(lordToil_Wait3, exitToil); transition6.AddTrigger(new Trigger_TicksPassed(600)); stateGraph.AddTransition(transition6); Transition transition7 = new Transition(lordToil_BestowingCeremony_MoveInPlace, exitToil); transition7.AddSource(lordToil_BestowingCeremony_Wait); transition7.AddTrigger(new Trigger_BecamePlayerEnemy()); stateGraph.AddTransition(transition7); Transition transition8 = new Transition(lordToil_BestowingCeremony_MoveInPlace, exitToil); transition8.AddSource(lordToil_BestowingCeremony_Wait); transition8.AddTrigger(new Trigger_Custom((TriggerSignal signal) => signal.type == TriggerSignalType.Tick && bestower.Spawned && !bestower.CanReach(spotCell, PathEndMode.OnCell, Danger.Deadly))); transition8.AddPostAction(new TransitionAction_Custom((Action) delegate { Messages.Message("MessageBestowingSpotUnreachable".Translate(), bestower, MessageTypeDefOf.NegativeEvent); QuestUtility.SendQuestTargetSignals(lord.questTags, "CeremonyFailed", lord.Named("SUBJECT")); })); stateGraph.AddTransition(transition8); if (!questEndedSignal.NullOrEmpty()) { Transition transition9 = new Transition(lordToil_BestowingCeremony_MoveInPlace, exitToil); transition9.AddSource(lordToil_BestowingCeremony_Wait); transition9.AddSource(lordToil_Wait); transition9.AddSource(lordToil_Wait2); transition9.AddTrigger(new Trigger_Signal(questEndedSignal)); stateGraph.AddTransition(transition9); } return(stateGraph); }