public void mod_OnStart()
        {
            if (!KingmakerPatchSettings.KingdomEvents.InstantComplete)
            {
                this.source_OnStart();
                return;
            }

            KingdomEventUIView previousView = this.alias_m_KingdomEventView;

            EventBus.RaiseEvent((IKingdomUIStartSpendTimeEvent h) => h.OnStartSpendTimeEvent(previousView.Blueprint));

            KingdomTaskEvent task = previousView.Task;

            EventBus.RaiseEvent((IKingdomUICloseEventWindow h) => h.OnClose());

            task?.Start(false);

            if (task == null || task.IsFinished || task.AssignedLeader == null || previousView.Blueprint.NeedToVisitTheThroneRoom)
            {
                return;
            }

            task.Event.Resolve(task);

            if (previousView.RulerTimeRequired <= 0)
            {
                return;
            }

            foreach (UnitEntityData unitEntityData in Kingmaker.Game.Instance.Player.AllCharacters)
            {
                RestController.ApplyRest(unitEntityData.Descriptor);
            }
        }
Пример #2
0
            public static void Postfix(KingdomEventUIView ___m_KingdomEventView, bool __state)
            {
                if (__state)
                {
                    EventBus.RaiseEvent((IKingdomUIStartSpendTimeEvent h) => h.OnStartSpendTimeEvent(___m_KingdomEventView.Blueprint));
                    KingdomTaskEvent kingdomTaskEvent = ___m_KingdomEventView?.Task;
                    EventBus.RaiseEvent((IKingdomUICloseEventWindow h) => h.OnClose());
                    kingdomTaskEvent?.Start(false);

                    if (kingdomTaskEvent == null)
                    {
                        return;
                    }

                    if (kingdomTaskEvent.IsFinished || kingdomTaskEvent.AssignedLeader == null || ___m_KingdomEventView.Blueprint.NeedToVisitTheThroneRoom)
                    {
                        return;
                    }

                    kingdomTaskEvent.Event.Resolve(kingdomTaskEvent);

                    if (___m_KingdomEventView.RulerTimeRequired <= 0)
                    {
                        return;
                    }
                    foreach (UnitEntityData unitEntityData in player.AllCharacters)
                    {
                        RestController.ApplyRest(unitEntityData.Descriptor);
                    }
                    new KingdomTimelineManager().MaybeUpdateTimeline();
                }
            }
        private EventResult.MarginType new_GetOverrideMargin()
        {
            KingdomTaskEvent associatedTask = this.AssociatedTask;

            var leaderType = LeaderType.None;

            if (associatedTask != null)
            {
                leaderType = associatedTask.AssignedLeader.Type;
            }

            EventResult.MarginType autoResolveType = this.EventBlueprint.AutoResolveResult;

            bool hasSolutions = this.EventBlueprint.Solutions.HasSolutions;

            if (!hasSolutions)
            {
                return(autoResolveType);
            }

            bool canSolve = this.EventBlueprint.Solutions.CanSolve(leaderType);

            if (!canSolve)
            {
                return(autoResolveType);
            }

            EventResult[] possibleResults = this.EventBlueprint.Solutions.GetResolutions(leaderType).Where(r => !string.IsNullOrEmpty(r.LocalizedDescription)).ToArray();

            if (possibleResults.Any(r => r.Margin == EventResult.MarginType.GreatSuccess))
            {
                return(EventResult.MarginType.GreatSuccess);
            }

            if (possibleResults.Any(r => r.Margin == EventResult.MarginType.Success))
            {
                return(EventResult.MarginType.Success);
            }

            return(autoResolveType);
        }