public override void InitializeStates(out BaseState default_state) { default_state = approach; root.Enter("SetTarget", delegate(Instance smi) { target.Set(smi.GetSMI <ThreatMonitor.Instance>().MainThreat, smi); }); approach.InitializeStates(masterTarget, target, attack, null, new CellOffset[5] { new CellOffset(0, 0), new CellOffset(1, 0), new CellOffset(-1, 0), new CellOffset(1, 1), new CellOffset(-1, 1) }, null).ToggleStatusItem(CREATURES.STATUSITEMS.ATTACK_APPROACH.NAME, CREATURES.STATUSITEMS.ATTACK_APPROACH.TOOLTIP, category: Db.Get().StatusItemCategories.Main, icon: string.Empty, icon_type: StatusItem.IconType.Info, notification_type: NotificationType.Neutral, allow_multiples: false, render_overlay: default(HashedString), status_overlays: 129022, resolve_string_callback: null, resolve_tooltip_callback: null); attack.Enter(delegate(Instance smi) { AttackStates attackStates = this; smi.Play("eat_pre", KAnim.PlayMode.Once); smi.Queue("eat_pst", KAnim.PlayMode.Once); smi.Schedule(0.5f, delegate { smi.GetComponent <Weapon>().AttackTarget(attackStates.target.Get(smi)); }, null); }).ToggleStatusItem(CREATURES.STATUSITEMS.ATTACK.NAME, CREATURES.STATUSITEMS.ATTACK.TOOLTIP, category: Db.Get().StatusItemCategories.Main, icon: string.Empty, icon_type: StatusItem.IconType.Info, notification_type: NotificationType.Neutral, allow_multiples: false, render_overlay: default(HashedString), status_overlays: 129022, resolve_string_callback: null, resolve_tooltip_callback: null).OnAnimQueueComplete(behaviourcomplete); behaviourcomplete.BehaviourComplete(GameTags.Creatures.Attack, false); }
public override void InitializeStates(out BaseState default_state) { default_state = fetch; fetch.InitializeStates(deliverer, ediblesource, ediblechunk, requestedrationcount, actualrationcount, movetodeliverypoint, null); movetodeliverypoint.InitializeStates(deliverer, deliverypoint, drop, null, null, null); drop.InitializeStates(deliverer, ediblechunk, deliverypoint, success, null); success.ReturnSuccess(); }
public override void InitializeStates(out BaseState default_state) { default_state = planFleeRoute; root.ToggleStatusItem(Db.Get().DuplicantStatusItems.Fleeing, null); planFleeRoute.Enter(delegate(StatesInstance smi) { int num = -1; int num2 = Grid.PosToCell(fleeFromTarget.Get(smi)); HashSet <int> hashSet = GameUtil.FloodCollectCells(Grid.PosToCell(smi.master.gameObject), smi.master.CanFleeTo, 300, null, true); int num3 = -1; int num4 = -1; foreach (int item in hashSet) { if (smi.master.nav.CanReach(item)) { int num5 = -1; num5 += Grid.GetCellDistance(item, num2); if (smi.master.isInFavoredDirection(item, num2)) { num5 += 8; } if (num5 > num4) { num4 = num5; num3 = item; } } } num = num3; if (num != -1) { smi.sm.fleeToTarget.Set(smi.master.CreateLocator(Grid.CellToPos(num)), smi); smi.sm.fleeToTarget.Get(smi).name = "FleeLocator"; if (num == num2) { smi.GoTo(cower); } else { smi.GoTo(flee); } } else { smi.GoTo(cower); } }); flee.InitializeStates(self, fleeToTarget, cower, cower, null, NavigationTactics.ReduceTravelDistance).ToggleAnims("anim_loco_run_insane_kanim", 2f); cower.ToggleAnims("anim_cringe_kanim", 4f).PlayAnim("cringe_pre").QueueAnim("cringe_loop", false, null) .QueueAnim("cringe_pst", false, null) .OnAnimQueueComplete(end); end.Enter(delegate(StatesInstance smi) { smi.StopSM("stopped"); }); }
public override void InitializeStates(out BaseState default_state) { default_state = findOffset; Target(mourner); root.ToggleAnims("anim_react_mourning_kanim", 0f).Exit("DestroyLocator", delegate(StatesInstance smi) { smi.DestroyLocator(); }); findOffset.Enter("CreateLocator", delegate(StatesInstance smi) { smi.CreateLocator(); }); moveto.InitializeStates(mourner, locator, mourn, null, null, null); mourn.PlayAnims((StatesInstance smi) => WORK_ANIMS, KAnim.PlayMode.Loop).ScheduleGoTo(10f, completed); completed.PlayAnim("working_pst").OnAnimQueueComplete(null).Exit(delegate(StatesInstance smi) { mourner.Get <Effects>(smi).Remove(Db.Get().effects.Get("Mourning")); }); }
public override void InitializeStates(out BaseState default_state) { default_state = plan; root.Enter("SetFleeTarget", delegate(Instance smi) { fleeToTarget.Set(CreatureHelpers.GetFleeTargetLocatorObject(smi.master.gameObject, smi.GetSMI <ThreatMonitor.Instance>().MainThreat), smi); }).ToggleStatusItem(CREATURES.STATUSITEMS.FLEEING.NAME, CREATURES.STATUSITEMS.FLEEING.TOOLTIP, category: Db.Get().StatusItemCategories.Main, icon: string.Empty, icon_type: StatusItem.IconType.Info, notification_type: NotificationType.Neutral, allow_multiples: false, render_overlay: default(HashedString), status_overlays: 129022, resolve_string_callback: null, resolve_tooltip_callback: null); plan.Enter(delegate(Instance smi) { ThreatMonitor.Instance sMI = smi.master.gameObject.GetSMI <ThreatMonitor.Instance>(); fleeToTarget.Set(CreatureHelpers.GetFleeTargetLocatorObject(smi.master.gameObject, sMI.MainThreat), smi); if ((Object)fleeToTarget.Get(smi) != (Object)null) { smi.GoTo(approach); } else { smi.GoTo(cower); } }); approach.InitializeStates(mover, fleeToTarget, cower, cower, null, NavigationTactics.ReduceTravelDistance).Enter(delegate(Instance smi) { PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Plus, CREATURES.STATUSITEMS.FLEEING.NAME.text, smi.master.transform, 1.5f, false); }); cower.Enter(delegate(Instance smi) { string s = "DEFAULT COWER ANIMATION"; if (smi.Get <KBatchedAnimController>().HasAnimation("cower")) { s = "cower"; } else if (smi.Get <KBatchedAnimController>().HasAnimation("idle")) { s = "idle"; } else if (smi.Get <KBatchedAnimController>().HasAnimation("idle_loop")) { s = "idle_loop"; } smi.Get <KBatchedAnimController>().Play(s, KAnim.PlayMode.Loop, 1f, 0f); }).ScheduleGoTo(2f, behaviourcomplete); behaviourcomplete.BehaviourComplete(GameTags.Creatures.Flee, false); }
public override void InitializeStates(out BaseState default_state) { default_state = approach; Target(recoverer); root.Enter("CreateLocator", delegate(StatesInstance smi) { smi.CreateLocator(); }).Exit("DestroyLocator", delegate(StatesInstance smi) { smi.DestroyLocator(); }).Update("UpdateLocator", delegate(StatesInstance smi, float dt) { smi.UpdateLocator(); }, UpdateRate.SIM_200ms, true); approach.InitializeStates(recoverer, locator, remove_suit, null, null, null); remove_suit.GoTo(recover); recover.ToggleAnims("anim_emotes_default_kanim", 0f).DefaultState(recover.pre).ToggleAttributeModifier("Recovering Breath", (StatesInstance smi) => smi.recoveringbreath, null) .ToggleTag(GameTags.RecoveringBreath) .TriggerOnEnter(GameHashes.BeginBreathRecovery, null) .TriggerOnExit(GameHashes.EndBreathRecovery); recover.pre.PlayAnim("breathe_pre").OnAnimQueueComplete(recover.loop); recover.loop.PlayAnim("breathe_loop", KAnim.PlayMode.Loop); recover.pst.QueueAnim("breathe_pst", false, null).OnAnimQueueComplete(null); }
public override void InitializeStates(out BaseState default_state) { default_state = approach; Target(sleeper); root.Exit("DestroyLocator", delegate(StatesInstance smi) { smi.DestroyLocator(); }); approach.InitializeStates(sleeper, bed, sleep, null, null, null); sleep.Enter("SetAnims", delegate(StatesInstance smi) { smi.SetAnim(); }).DefaultState(sleep.normal).ToggleTag(GameTags.Asleep) .DoSleep(sleeper, bed, success, null) .TriggerOnExit(GameHashes.SleepFinished) .EventHandler(GameHashes.SleepDisturbedByLight, delegate(StatesInstance smi) { isDisturbedByLight.Set(true, smi); }) .EventHandler(GameHashes.SleepDisturbedByNoise, delegate(StatesInstance smi) { isDisturbedByNoise.Set(true, smi); }); sleep.uninterruptable.DoNothing(); sleep.normal.ParamTransition(isInterruptable, sleep.uninterruptable, GameStateMachine <States, StatesInstance, SleepChore, object> .IsFalse).ToggleCategoryStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().DuplicantStatusItems.Sleeping, null).QueueAnim("working_loop", true, null) .ParamTransition(isDisturbedByNoise, sleep.interrupt_noise, GameStateMachine <States, StatesInstance, SleepChore, object> .IsTrue) .ParamTransition(isDisturbedByLight, sleep.interrupt_light, GameStateMachine <States, StatesInstance, SleepChore, object> .IsTrue) .Update(delegate(StatesInstance smi, float dt) { smi.CheckLightLevel(); }, UpdateRate.SIM_200ms, false); sleep.interrupt_noise.ToggleCategoryStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().DuplicantStatusItems.SleepingInterruptedByNoise, null).QueueAnim("interrupt_light", false, null).OnAnimQueueComplete(sleep.interrupt_noise_transition); sleep.interrupt_noise_transition.Enter(delegate(StatesInstance smi) { Effects component2 = smi.master.GetComponent <Effects>(); component2.Add(Db.Get().effects.Get("TerribleSleep"), true); if (component2.HasEffect(Db.Get().effects.Get("BadSleep"))) { component2.Remove(Db.Get().effects.Get("BadSleep")); } isDisturbedByNoise.Set(false, smi); State state2 = (!smi.master.GetComponent <Schedulable>().IsAllowed(Db.Get().ScheduleBlockTypes.Sleep)) ? success : sleep.normal; smi.GoTo(state2); }); sleep.interrupt_light.ToggleCategoryStatusItem(Db.Get().StatusItemCategories.Main, Db.Get().DuplicantStatusItems.SleepingInterruptedByLight, null).QueueAnim("interrupt", false, null).OnAnimQueueComplete(sleep.interrupt_light_transition); sleep.interrupt_light_transition.Enter(delegate(StatesInstance smi) { Effects component = smi.master.GetComponent <Effects>(); if (!component.HasEffect(Db.Get().effects.Get("TerribleSleep"))) { smi.master.GetComponent <Effects>().Add(Db.Get().effects.Get("BadSleep"), true); } State state = (!smi.master.GetComponent <Schedulable>().IsAllowed(Db.Get().ScheduleBlockTypes.Sleep)) ? success : sleep.normal; isDisturbedByLight.Set(false, smi); smi.GoTo(state); }); success.Enter(delegate(StatesInstance smi) { smi.EvaluateSleepQuality(); }).ReturnSuccess(); }
public override void InitializeStates(out BaseState default_state) { default_state = approachIncapacitated; approachIncapacitated.InitializeStates(rescuer, rescueTarget, holding.pickup, failure, Grid.DefaultOffset, null).Enter(delegate(StatesInstance smi) { DeathMonitor.Instance sMI2 = rescueTarget.GetSMI <DeathMonitor.Instance>(smi); if (sMI2 == null || sMI2.IsDead()) { smi.StopSM("target died"); } }); holding.Target(rescuer).Enter(delegate(StatesInstance smi) { States states = this; smi.sm.rescueTarget.Get(smi).Subscribe(1623392196, delegate { smi.GoTo(states.holding.ditch); }); KAnimFile anim2 = Assets.GetAnim("anim_incapacitated_carrier_kanim"); smi.master.GetComponent <KAnimControllerBase>().RemoveAnimOverrides(anim2); smi.master.GetComponent <KAnimControllerBase>().AddAnimOverrides(anim2, 0f); }).Exit(delegate(StatesInstance smi) { KAnimFile anim = Assets.GetAnim("anim_incapacitated_carrier_kanim"); smi.master.GetComponent <KAnimControllerBase>().RemoveAnimOverrides(anim); }); holding.pickup.Target(rescuer).PlayAnim("pickup").Enter(delegate(StatesInstance smi) { rescueTarget.Get(smi).gameObject.GetComponent <KBatchedAnimController>().Play("pickup", KAnim.PlayMode.Once, 1f, 0f); }) .Exit(delegate(StatesInstance smi) { rescuer.Get(smi).GetComponent <Storage>().Store(rescueTarget.Get(smi), false, false, true, false); rescueTarget.Get(smi).transform.SetLocalPosition(Vector3.zero); KBatchedAnimTracker component = rescueTarget.Get(smi).GetComponent <KBatchedAnimTracker>(); component.symbol = new HashedString("snapTo_pivot"); component.offset = new Vector3(0f, 0f, 1f); }) .EventTransition(GameHashes.AnimQueueComplete, holding.delivering, null); holding.delivering.InitializeStates(rescuer, deliverTarget, holding.deposit, holding.ditch, null, null).Enter(delegate(StatesInstance smi) { DeathMonitor.Instance sMI = rescueTarget.GetSMI <DeathMonitor.Instance>(smi); if (sMI == null || sMI.IsDead()) { smi.StopSM("target died"); } }).Update(delegate(StatesInstance smi, float dt) { if ((UnityEngine.Object)deliverTarget.Get(smi) == (UnityEngine.Object)null) { smi.GoTo(holding.ditch); } }, UpdateRate.SIM_200ms, false); holding.deposit.PlayAnim("place").EventHandler(GameHashes.AnimQueueComplete, delegate(StatesInstance smi) { smi.master.DropIncapacitatedDuplicant(); smi.SetStatus(Status.Success); smi.StopSM("complete"); }); holding.ditch.PlayAnim("place").ScheduleGoTo(0.5f, failure).Exit(delegate(StatesInstance smi) { smi.master.DropIncapacitatedDuplicant(); }); failure.Enter(delegate(StatesInstance smi) { smi.SetStatus(Status.Failed); smi.StopSM("failed"); }); }
public override void InitializeStates(out BaseState default_state) { default_state = findbreakable; Target(breaker); root.ToggleAnims("anim_loco_destructive_kanim", 0f); noTarget.Enter(delegate(StatesInstance smi) { smi.StopSM("complete/no more food"); }); findbreakable.Enter("FindBreakable", delegate(StatesInstance smi) { smi.FindBreakable(); }); move_notarget.MoveTo((StatesInstance smi) => smi.sm.moveToWallTarget.Get(smi), breaking_wall, noTarget, false); move_target.InitializeStates(breaker, breakable, breaking, findbreakable, null, null).ToggleStatusItem(Db.Get().DuplicantStatusItems.LashingOut, (object)null); breaking_wall.DefaultState(breaking_wall.Pre).Enter(delegate(StatesInstance smi) { int cell = Grid.PosToCell(smi.master.gameObject); if (Grid.Solid[Grid.OffsetCell(cell, 1, 0)]) { smi.sm.masterTarget.Get <KAnimControllerBase>(smi).AddAnimOverrides(Assets.GetAnim("anim_out_of_reach_destructive_low_kanim"), 0f); int num = wallCellToBreak = Grid.OffsetCell(cell, 1, 0); } else if (Grid.Solid[Grid.OffsetCell(cell, -1, 0)]) { smi.sm.masterTarget.Get <KAnimControllerBase>(smi).AddAnimOverrides(Assets.GetAnim("anim_out_of_reach_destructive_low_kanim"), 0f); int num2 = wallCellToBreak = Grid.OffsetCell(cell, -1, 0); } else if (Grid.Solid[Grid.OffsetCell(cell, 1, 1)]) { smi.sm.masterTarget.Get <KAnimControllerBase>(smi).AddAnimOverrides(Assets.GetAnim("anim_out_of_reach_destructive_high_kanim"), 0f); int num3 = wallCellToBreak = Grid.OffsetCell(cell, 1, 1); } else if (Grid.Solid[Grid.OffsetCell(cell, -1, 1)]) { smi.sm.masterTarget.Get <KAnimControllerBase>(smi).AddAnimOverrides(Assets.GetAnim("anim_out_of_reach_destructive_high_kanim"), 0f); int num4 = wallCellToBreak = Grid.OffsetCell(cell, -1, 1); } smi.master.GetComponent <Facing>().Face(Grid.CellToPos(wallCellToBreak)); }).Exit(delegate(StatesInstance smi) { smi.sm.masterTarget.Get <KAnimControllerBase>(smi).RemoveAnimOverrides(Assets.GetAnim("anim_out_of_reach_destructive_high_kanim")); smi.sm.masterTarget.Get <KAnimControllerBase>(smi).RemoveAnimOverrides(Assets.GetAnim("anim_out_of_reach_destructive_low_kanim")); }); breaking_wall.Pre.PlayAnim("working_pre").OnAnimQueueComplete(breaking_wall.Loop); breaking_wall.Loop.ScheduleGoTo(26f, breaking_wall.Pst).Update("PunchWallDamage", delegate(StatesInstance smi, float dt) { smi.master.PunchWallDamage(dt); }, UpdateRate.SIM_1000ms, false).Enter(delegate(StatesInstance smi) { smi.Play("working_loop", KAnim.PlayMode.Loop); }) .Update(delegate(StatesInstance smi, float dt) { if (!Grid.Solid[smi.sm.wallCellToBreak]) { smi.GoTo(breaking_wall.Pst); } }, UpdateRate.SIM_200ms, false); breaking_wall.Pst.QueueAnim("working_pst", false, null).OnAnimQueueComplete(noTarget); breaking.ToggleWork <Breakable>(breakable, null, null, null); }
public override void InitializeStates(out BaseState default_state) { default_state = approach; approach.InitializeStates(quarantined, locator, success, null, null, null); success.ReturnSuccess(); }
public override void InitializeStates(out BaseState default_state) { default_state = approachtarget; root.ToggleStatusItem(Db.Get().DuplicantStatusItems.Fighting, (StatesInstance smi) => smi.master.gameObject).EventHandler(GameHashes.TargetLost, delegate(StatesInstance smi) { smi.master.Fail("target lost"); }).Enter(delegate(StatesInstance smi) { smi.master.GetComponent <Weapon>().Configure(1f, 1f, AttackProperties.DamageType.Standard, AttackProperties.TargetType.Single, 1, 0f); }); approachtarget.InitializeStates(attacker, attackTarget, attack, null, null, NavigationTactics.Range_3_ProhibitOverlap).Enter(delegate(StatesInstance smi) { smi.master.CleanUpMultitool(); smi.master.Trigger(1039067354, attackTarget.Get(smi)); Health component3 = attackTarget.Get(smi).GetComponent <Health>(); if ((UnityEngine.Object)component3 == (UnityEngine.Object)null || component3.IsDefeated()) { smi.StopSM("target defeated"); } }); attack.Target(attacker).Enter(delegate(StatesInstance smi) { attackTarget.Get(smi).Subscribe(1088554450, smi.master.OnTargetMoved); if (attackTarget != null && smi.master.multiTool == null) { smi.master.multiTool = new MultitoolController.Instance(attackTarget.Get(smi).GetComponent <Workable>(), smi.master.GetComponent <Worker>(), "attack", Assets.GetPrefab(EffectConfigs.AttackSplashId)); smi.master.multiTool.StartSM(); } attackTarget.Get(smi).Subscribe(1969584890, smi.master.OnTargetDestroyed); smi.ScheduleGoTo(0.5f, success); }).Update(delegate(StatesInstance smi, float dt) { if (smi.master.multiTool != null) { smi.master.multiTool.UpdateHitEffectTarget(); } }, UpdateRate.SIM_200ms, false) .Exit(delegate(StatesInstance smi) { if ((UnityEngine.Object)attackTarget.Get(smi) != (UnityEngine.Object)null) { attackTarget.Get(smi).Unsubscribe(1088554450, smi.master.OnTargetMoved); } }); success.Enter("finishAttack", delegate(StatesInstance smi) { if ((UnityEngine.Object)attackTarget.Get(smi) != (UnityEngine.Object)null) { Transform transform = attackTarget.Get(smi).transform; Weapon component = attacker.Get(smi).gameObject.GetComponent <Weapon>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { component.AttackTarget(transform.gameObject); Health component2 = attackTarget.Get(smi).GetComponent <Health>(); if ((UnityEngine.Object)component2 != (UnityEngine.Object)null) { if (!component2.IsDefeated()) { smi.GoTo(attack); } else { smi.master.CleanUpMultitool(); smi.StopSM("target defeated"); } } } else { smi.master.CleanUpMultitool(); smi.StopSM("no weapon"); } } else { smi.master.CleanUpMultitool(); smi.StopSM("no target"); } }).ReturnSuccess(); }
public override void InitializeStates(out BaseState default_state) { default_state = fetching; Target(fetcher); fetching.DefaultState(fetching.next).Enter("ReservePickupables", delegate(StatesInstance smi) { smi.ReservePickupables(); }).Exit("UnreservePickupables", delegate(StatesInstance smi) { smi.UnreservePickupables(); }) .Enter("pickingup-on", delegate(StatesInstance smi) { smi.pickingup = true; }) .Exit("pickingup-off", delegate(StatesInstance smi) { smi.pickingup = false; }); fetching.next.Enter("SetupFetch", delegate(StatesInstance smi) { smi.SetupFetch(); }); ApproachSubState <Pickupable> movetopickupable = fetching.movetopickupable; TargetParameter mover = fetcher; TargetParameter move_target = fetchTarget; State pickup = fetching.pickup; State fetchfail = fetching.fetchfail; NavTactic reduceTravelDistance = NavigationTactics.ReduceTravelDistance; movetopickupable.InitializeStates(mover, move_target, pickup, fetchfail, null, reduceTravelDistance); fetching.pickup.DoPickup(fetchTarget, fetchResultTarget, fetchAmount, fetching.fetchcomplete, fetching.fetchfail); fetching.fetchcomplete.Enter(delegate(StatesInstance smi) { smi.FetchComplete(); }); fetching.fetchfail.Enter(delegate(StatesInstance smi) { smi.FetchFail(); }); delivering.DefaultState(delivering.next).OnSignal(currentdeliverycancelled, delivering.deliverfail).Enter("SetupDeliverables", delegate(StatesInstance smi) { smi.SetupDeliverables(); }) .Enter("delivering-on", delegate(StatesInstance smi) { smi.delivering = true; }) .Exit("delivering-off", delegate(StatesInstance smi) { smi.delivering = false; }); delivering.next.Enter("SetupDelivery", delegate(StatesInstance smi) { smi.SetupDelivery(); }); ApproachSubState <Storage> movetostorage = delivering.movetostorage; move_target = fetcher; mover = deliveryDestination; fetchfail = delivering.storing; pickup = delivering.deliverfail; reduceTravelDistance = NavigationTactics.ReduceTravelDistance; movetostorage.InitializeStates(move_target, mover, fetchfail, pickup, null, reduceTravelDistance).Enter(delegate(StatesInstance smi) { if ((UnityEngine.Object)deliveryObject.Get(smi) != (UnityEngine.Object)null && (UnityEngine.Object)deliveryObject.Get(smi).GetComponent <MinionIdentity>() != (UnityEngine.Object)null) { deliveryObject.Get(smi).transform.SetLocalPosition(Vector3.zero); KBatchedAnimTracker component = deliveryObject.Get(smi).GetComponent <KBatchedAnimTracker>(); component.symbol = new HashedString("snapTo_chest"); component.offset = new Vector3(0f, 0f, 1f); } }); delivering.storing.DoDelivery(fetcher, deliveryDestination, delivering.delivercomplete, delivering.deliverfail); delivering.deliverfail.Enter(delegate(StatesInstance smi) { smi.DeliverFail(); }); delivering.delivercomplete.Enter(delegate(StatesInstance smi) { smi.DeliverComplete(); }); }