private static void RunIntroEvent(Heroine heroine, PregnancyData preg, bool isPillEvent) { var loadedEvt = GetEvent(heroine, preg, isPillEvent); if (loadedEvt == null) { PregnancyPlugin.Logger.LogError("Unexpected null GetEvent result"); return; } // Init needed first since the custom event starts empty var evt = EventApi.CreateNewEvent(setPlayerParam: true); heroine.SetADVParam(evt); var freePill = _personalityHasPills.TryGetValue(heroine.personality, out var val) && val; evt.Add(Program.Transfer.VAR("bool", "PillForFree", freePill.ToString(CultureInfo.InvariantCulture))); evt.Add(Program.Transfer.VAR("bool", "PlayerHasPill", (StoreApi.GetItemAmountBought(AfterpillStoreId) >= 1).ToString(CultureInfo.InvariantCulture))); // Give favor by default, gets overriden if the event specifies any other value evt.Add(Program.Transfer.VAR("int", "FavorChange", "30")); evt.AddRange(loadedEvt); var scene = TalkScene.instance; scene.StartADV(evt, scene.cancellation.Token) .ContinueWith(() => Program.ADVProcessingCheck(scene.cancellation.Token)) .ContinueWith(() => { PregnancyGameController.ApplyToAllDatas((chara, data) => { if (chara == heroine) { if (isPillEvent) { data.CanAskForAfterpill = false; } else { data.CanTellAboutPregnancy = false; } return(true); } return(false); }); var vars = ActionScene.instance.AdvScene.Scenario.Vars; ApplyStatChangeVars(heroine, preg, vars); // Fix mouth getting permanently locked by the events heroine.chaCtrl.ChangeMouthFixed(false); }) .Forget(); }
/// <summary> /// Start a new "light" ADV scene that only pauses player input and shows a dialog box. Can be used in roaming mode and some other cases. /// Best to use this for events where player thinks or talks to himself with no other characters participating, for example after picking up an item on the map. /// Do not use in TalkScenes, use <see cref="StartTextSceneEvent"/> instead. /// You can get variables set in the commands through actScene.AdvScene.Scenario.Vars /// You need to use Program.SetParam if you want to add parameters related to a heroine. Alternatively use the CharaChange command with the global heroine syntax. /// Warning: You have to have a Close command or the scene will softlock after reaching the end! /// </summary> /// <param name="commands">List of commands for the event</param> public static IEnumerator StartMonologueEvent(IEnumerable <Program.Transfer> commands) { if (commands == null) { throw new ArgumentNullException(nameof(commands)); } var list = commands.ToList(); if (list.All(x => x.param.Command != Command.Close)) { list.Add(Program.Transfer.Close()); UnityEngine.Debug.LogWarning("No Close command in the transfer list! Adding close at end to prevent lockup. Add Program.Transfer.Close() at the end of list to fix this."); } // todo handle this properly? Used when going back to title screen from F1 menu and possibly other places. Possibly not a problem since we run as a coroutine? var token = CancellationToken.None; var actScene = ActionScene.instance; // Stop player input and some game functions actScene.Player.isActionNow = true; var prevBGM = string.Empty; var prevVolume = 1f; yield return(TuplelessGetBgmAndVolume((x, y) => { prevBGM = x; prevVolume = y; })); ActionScene instance = SingletonInitializer <ActionScene> .instance; Transform transform = Camera.main.transform; bool isOpenADV = false; // Run the actual scene yield return(Program.Open(new Data { position = instance.Player.position, rotation = instance.Player.rotation, scene = instance, camera = new OpenData.CameraData { position = transform.position, rotation = transform.rotation }, transferList = list }, token, new Program.OpenDataProc { onLoad = delegate { isOpenADV = true; } }).ToCoroutine(UnityEngine.Debug.LogException)); // Wait until the scene is done yield return(UniTask.WaitUntil(() => isOpenADV, PlayerLoopTiming.Update, token).ToCoroutine(UnityEngine.Debug.LogException)); yield return(Program.ADVProcessingCheck(token).ToCoroutine(UnityEngine.Debug.LogException)); // Fade back to gameplay, assuming the script faded to loading screen, does nothing otherwise yield return(Illusion.Game.Utils.Sound.GetFadePlayerWhileNull(prevBGM, prevVolume).ToCoroutine(UnityEngine.Debug.LogException)); Scene.sceneFadeCanvas.DefaultColor(); // Reenable player controls actScene.Player.isActionNow = false; }