Exemple #1
0
            public static bool Prefix(CueSelection __instance, ref BlueprintCueBase __result)
            {
                if (!settings.toggleRandomizeCueSelections)
                {
                    return(true);
                }
                List <BlueprintCueBase> blueprintCueBaseList = null;

                foreach (BlueprintCueBase blueprintCueBase in __instance.Cues.Dereference())
                {
                    if (blueprintCueBase != null && blueprintCueBase.CanShow())
                    {
                        if (blueprintCueBaseList == null)
                        {
                            blueprintCueBaseList = new();
                        }
                        blueprintCueBaseList.Add(blueprintCueBase);
                    }
                }
                if (blueprintCueBaseList == null)
                {
                    __result = null;
                    return(false);
                }
                int index = UnityEngine.Random.Range(0, blueprintCueBaseList.Count);

                Mod.Debug($"CueSelection_Select_Patch - index: {index}");
                __result = blueprintCueBaseList[index];
                return(false);
            }
Exemple #2
0
 public static void GameFlagAndConversationHappenedExample()
 {
     foreach (UnitEntityData unitEntityData in Game.Instance.State.PlayerState.AllCharacters)
     {
         string characterName      = unitEntityData.CharacterName;
         string characterCondition = "";
         if (characterName == "Valerie")
         {
             //Scar
             BlueprintDialog blueprintDialog = Game.Instance.Player.Dialog.ShownDialogs.ToList <BlueprintDialog>().Find(x => x.AssetGuid == "3fb2516a55a21684aac00eb4f4015a77");
             if (blueprintDialog != null)
             {
                 characterCondition = "ValerieScar";
             }
             //Scar Healed
             BlueprintCueBase blueprintCueBase = Game.Instance.Player.Dialog.ShownCues.ToList <BlueprintCueBase>().Find(x => x.AssetGuid == "3bc0f984c248897479bc30b16d91ffc5");
             if (blueprintCueBase != null)
             {
                 characterCondition = "ValerieHealed";
             }
         }
         if (characterName == "Tristian")
         {
             //Blinded
             if (Game.Instance.Player.UnlockableFlags.UnlockedFlags.Keys.FirstOrDefault(x => x.name.Equals("OculusShattered")))
             {
                 characterCondition = "TristianBlind";
             }
         }
         Main.DebugLog(characterName + " - " + characterCondition);
     }
 }
Exemple #3
0
            public static bool Prefix(DialogSpeaker __instance, BlueprintCueBase cue, ref UnitEntityData __result)
            {
                if (!settings.toggleRemoteCompanionDialog)
                {
                    return(true);
                }
                if (__instance.Blueprint == null)
                {
                    __result = null;
                    return(false);
                }
                Mod.Trace($"getting unit for speaker {__instance.Blueprint.name}");
                var dialogPosition = Game.Instance.DialogController.DialogPosition;

                Mod.Trace($"dialogPos: {dialogPosition}");
                var second = Game.Instance.EntityCreator.CreationQueue.Select(ce => ce.Entity).OfType <UnitEntityData>();

                __instance.MakeEssentialCharactersConscious();
                Mod.Trace($"second: {second?.ToString()} matching: {second.Select(u => __instance.SelectMatchingUnit(u))}");
                var overrides   = DialogSpeaker_GetEntityOverrides;
                var GUID        = cue?.AssetGuid.ToString();
                var hasOverride = GUID != null?DialogSpeaker_GetEntityOverrides.ContainsKey(GUID) : false;

                var overrideValue = hasOverride && DialogSpeaker_GetEntityOverrides[GUID];
                var unit          = Game.Instance.State.Units.Concat(Game.Instance.Player.AllCrossSceneUnits)
                                    //.Where(u => u.IsInGame && !u.Suppressed)
                                    .Where(u => hasOverride ? overrideValue : settings.toggleExCompanionDialog || !u.IsExCompanion())
                                    .Concat(second)
                                    .Select(new Func <UnitEntityData, UnitEntityData>(__instance.SelectMatchingUnit))
                                    .NotNull()
                                    .Distinct()
                                    .Nearest(dialogPosition);

                Mod.Debug($"found {unit?.CharacterName ?? "no one".cyan()} position: {unit?.Position.ToString() ?? "n/a"}");
                if (unit != null)
                {
                    if (unit.DistanceTo(dialogPosition) > 25)
                    {
                        var mainChar      = Game.Instance.Player.MainCharacter.Value;
                        var mainPos       = mainChar.Position;
                        var offset        = 4f * UnityEngine.Random.insideUnitSphere;
                        var mainDirection = mainChar.OrientationDirection;
                        unit.Position = mainPos - 5 * mainDirection + offset;
                    }
                    __result = unit;
                    return(false);
                }
                DialogDebug.Add((BlueprintScriptableObject)cue, "speaker doesnt exist", Color.red);
                __result = null;
                return(false);
            }
Exemple #4
0
            public static bool Prefix(DialogController __instance, [NotNull] ref IEnumerable <BlueprintAnswerBase> answers, [CanBeNull] BlueprintCueBase continueCue)
            {
                if (!settings.toggleShowAnswersForEachConditionalResponse)
                {
                    return(true);
                }
                List <BlueprintAnswerBase> expandedAnswers = new();

                foreach (var answerBase in answers)
                {
                    if (answerBase is BlueprintAnswer answer)
                    {
                        if (answer.NextCue is CueSelection cueSelection)
                        {
                            Mod.Debug($"checking: {answer.name} - {cueSelection.Cues.Count} {answer.Text}");
                            var cueCount = cueSelection.Cues.Count;
                            if (cueCount <= 1)
                            {
                                expandedAnswers.Add(answer);
                            }
                            else
                            {
                                var cues = cueSelection.Cues.Dereference <BlueprintCueBase>();
                                if (cues.All(c => c.Conditions.HasConditions))
                                {
                                    foreach (var cueBase in cueSelection.Cues.Dereference <BlueprintCueBase>())
                                    {
                                        if (answer.ShowOnce)
                                        {
                                            var dialog           = Game.Instance.Player.Dialog;
                                            var dialogController = Game.Instance.DialogController;
                                            if (dialogController.LocalSelectedAnswers.Where(a => a.AssetGuid == answer.AssetGuid).Any())
                                            {
                                                continue;
                                            }
                                            if (dialog.SelectedAnswers.Where(a => a.AssetGuid == answer.AssetGuid).Any())
                                            {
                                                continue;
                                            }
                                        }
                                        if (settings.toggleShowAllAnswersForEachConditionalResponse || cueBase.CanShow())
                                        {
                                            var multiAnswer = answer.ShallowClone();
                                            var cueSel      = cueSelection.ShallowClone();
                                            cueSel.Cues = new List <BlueprintCueBaseReference>()
                                            {
                                                cueBase.ToReference <BlueprintCueBaseReference>()
                                            };
                                            cueSel.Strategy     = Strategy.First;
                                            multiAnswer.NextCue = cueSel;
                                            expandedAnswers.Add(multiAnswer);
                                        }
                                    }
                                }
                                else
                                {
                                    expandedAnswers.Add(answer);
                                }
                            }
                        }
                        else
                        {
                            expandedAnswers.Add(answer);
                        }
                    }
                    else
                    {
                        expandedAnswers.Add(answerBase);
                    }
                }
                answers = expandedAnswers;
                return(true);
            }
Exemple #5
0
        public static BlueprintCheck CreateCheck(string name, int num, StatType type, int dc, BlueprintCueBase success, BlueprintCueBase fail, bool hidden = false, DCModifier[] dCModifier = null, ConditionsChecker condition = null, params BlueprintComponent[] components)
        {
            BlueprintCheck o = Helpers.Create <BlueprintCheck>();

            o.Success     = success;
            o.Fail        = fail;
            o.Hidden      = hidden;
            o.DC          = dc;
            o.DCModifiers = dCModifier == null?Array.Empty <DCModifier>() : dCModifier;

            o.Type       = type;
            o.Conditions = condition == null ? new ConditionsChecker() : condition;
            o.name       = "Check_" + name + num;
            o.SetComponents(components);
            library.AddAsset(o, Guid(o.name));
            return(o);
        }