Beispiel #1
0
            // DoNotification but with a custom version that checks the whitelist.
            public static void DoNotification(SicknessInstance.States __instance)
            {
                var state_target = Traverse.Create(__instance.infected).CallMethod <
                    GameStateMachine <SicknessInstance.States, SicknessInstance.StatesInstance,
                                      SicknessInstance, object> .TargetParameter>("GetStateTarget");

                __instance.infected.Enter("DoNotification()", smi =>
                {
                    // if it's not to be skipped, (reluctantly) do the notification.
                    if (!SkipNotifications.SicknessIDs.Contains(smi.master.Sickness.Id))
                    {
                        var notification = Traverse.Create(smi.master).
                                           GetField <Notification>("notification");
                        state_target.Get <Notifier>(smi).Add(notification, string.Empty);
                    }
                });
            }
Beispiel #2
0
            public static void Postfix(SicknessInstance.States __instance)
            {
                var old_enterActions = __instance.infected.enterActions;
                var new_enterActions = (__instance.infected.enterActions =
                                            new List <StateMachine.Action>());

                if (old_enterActions != null)
                {
                    for (var i = 0; i < old_enterActions.Count; i++)
                    {
                        if (old_enterActions[i].name != "DoNotification()")
                        {
                            new_enterActions.Add(old_enterActions[i]);
                        }
                        else
                        {
                            DoNotification(__instance);
                        }
                    }
                }
            }