Elin Decompiled Documentation EA 23.364.1 Nightly
Loading...
Searching...
No Matches
DramaManager.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Globalization;
4using System.IO;
5using System.Linq;
6using DG.Tweening;
7using UnityEngine;
8using UnityEngine.UI;
9
10public class DramaManager : EMono
11{
12 public static Chara TG;
13
15
16 public CanvasGroup cg;
17
18 public CanvasGroup cgCover;
19
21
22 public Transform actorPos;
23
24 public Transform endroll;
25
27
29
31
33
35
36 public GameObject goSkip;
37
38 public Image imageBG;
39
40 public Image imageCover;
41
42 public Font[] fonts;
43
44 public Person tg;
45
46 public bool bgmChanged;
47
48 private List<DramaEvent> customEvents = new List<DramaEvent>();
49
50 public List<DramaChoice> _choices = new List<DramaChoice>();
51
52 public Dictionary<string, string> customTalkTopics = new Dictionary<string, string>();
53
54 public Dictionary<string, string> dictLocalize = new Dictionary<string, string>();
55
56 public float creditSpeed;
57
58 [NonSerialized]
59 public string path;
60
61 private string lastIF;
62
63 private string lastIF2;
64
65 private SoundSource lastSound;
66
68
69 public bool enableTone;
70
71 public bool customEventsAdded;
72
73 public bool idDefaultPassed;
74
75 public int countLine;
76
77 private string idDefault;
78
79 private string textReplace;
80
81 public static Dictionary<string, ExcelData> dictCache = new Dictionary<string, ExcelData>(PathComparer.Default);
82
83 public bool keepAmbientBGM => !bgmChanged;
84
85 public EScriptSubmission Scripting => EScriptSubmission.Create(setup.book);
86
88
89 private void Update()
90 {
91 try
92 {
94 }
95 catch (Exception ex)
96 {
97 layer.Close();
98 ModUtil.LogModError("error during drama play\n" + ex.GetType().Name + ": " + ex.Message, new FileInfo(path));
99 Debug.LogException(ex);
100 }
101 }
102
104 {
105 this.setup = setup;
106 cgCover.SetActive(enable: false);
107 endroll.SetActive(enable: false);
108 tg = setup.person;
109 SetDialog();
111 {
112 setup = setup,
113 manager = this,
114 id = setup.sheet
115 };
116 Load();
117 sequence.lastStep = (sequence.lastlastStep = setup.step);
118 if (!setup.forceJump.IsEmpty())
119 {
121 }
122 else
123 {
124 sequence.Play();
125 }
126 return sequence;
127 }
128
130 {
131 sequence.Clear();
132 customEvents.Clear();
133 customTalkTopics.Clear();
134 moldActor = actorPos.CreateMold<DramaActor>();
135 if (tg != null)
136 {
137 sequence.AddActor("tg", tg);
138 }
139 sequence.AddActor("pc", new Person(EMono.pc));
140 string text = PackageIterator.GetFiles("Dialog/Drama/" + setup.book + ".xlsx").LastOrDefault()?.FullName;
141 ExcelData excelData = dictCache.TryGetValue(text);
142 if (excelData != null && excelData.IsModified())
143 {
144 excelData = null;
145 }
146 if (excelData == null)
147 {
148 excelData = new ExcelData();
149 }
150 excelData.maxEmptyRows = 10;
151 path = (excelData.path = text ?? (CorePath.DramaData + setup.book + ".xlsx"));
152 List<Dictionary<string, string>> list = excelData.BuildList(setup.sheet);
153 dictCache[excelData.path] = excelData;
154 string key = text ?? (CorePath.DramaDataLocal + setup.book + ".xlsx");
155 if (!File.Exists(key))
156 {
157 key = excelData.path;
158 }
159 ExcelData excelData2 = dictCache.TryGetValue(key);
160 if (excelData2 != excelData)
161 {
162 if (excelData2 != null && excelData2.IsModified())
163 {
164 excelData2 = null;
165 }
166 if (excelData2 == null)
167 {
168 excelData2 = new ExcelData();
169 }
170 excelData2.maxEmptyRows = 10;
171 excelData2.path = key;
172 dictCache[excelData2.path] = excelData2;
173 }
174 dictLocalize.Clear();
175 string[] array = new string[3]
176 {
177 "text_" + Lang.langCode,
178 "text",
179 "text_EN"
180 };
181 foreach (Dictionary<string, string> item in excelData2.BuildList(setup.sheet))
182 {
183 string text2 = item["id"];
184 if (text2.IsEmpty())
185 {
186 continue;
187 }
188 string value = null;
189 string[] array2 = array;
190 foreach (string key2 in array2)
191 {
192 if (item.TryGetValue(key2, out value) && !value.IsEmpty())
193 {
194 break;
195 }
196 }
197 if (value == null)
198 {
199 value = "[ID '" + text2 + "'] <empty text>";
200 }
201 if (!dictLocalize.TryAdd(text2, value))
202 {
203 string text3 = dictLocalize[text2];
204 dictLocalize[text2] = ("[DUPLICATE ID '" + text2 + "']\n").TagColor(Color.red) + text3;
205 Debug.LogWarning("#drama duplicate id '" + text2 + "' at " + path + "\n" + text3 + " -> " + value);
206 }
207 }
209 lastTalk = null;
211 countLine = 0;
212 for (int j = 0; j < list.Count; j++)
213 {
214 try
215 {
216 ParseLine(list[j]);
217 }
218 catch (Exception exception)
219 {
220 Debug.LogException(exception);
221 }
222 countLine++;
223 }
225 sequence.steps["end"] = 99999;
226 sequence.AddActor("narrator", new Person("narrator"));
227 return sequence;
228 }
229
230 public void AddCustomEvents(string idCustom = "Resident")
231 {
233 {
234 return;
235 }
236 DramaCustomSequence dramaCustomSequence = new DramaCustomSequence
237 {
238 manager = this,
240 idCustom = idCustom,
241 events = customEvents,
244 };
245 CustomEvent(delegate
246 {
247 sequence.Exit();
248 });
249 if (tg != null && tg.hasChara)
250 {
251 TG = tg.chara;
252 dramaCustomSequence.Build(tg.chara);
253 }
254 if (!sequence.setup.textData.IsEmpty())
255 {
256 dramaCustomSequence.BuildTextData();
257 }
258 foreach (DramaEvent customEvent in customEvents)
259 {
260 AddEvent(customEvent);
261 }
262 customEventsAdded = true;
263 }
264
265 public void ParseLine(Dictionary<string, string> item)
266 {
267 string text = item.TryGetValue("step");
268 if (text == "//")
269 {
270 return;
271 }
272 if (text == idDefault)
273 {
274 idDefaultPassed = true;
275 }
276 string[] array = item.TryGetValue("action")?.Split('/');
277 string action = array.TryGet(0, returnNull: true);
278 string actor = item.GetValueOrDefault("actor", "#1");
279 string[] p = item.TryGetValue("param")?.Split(',') ?? Array.Empty<string>();
280 string p2 = ((p.Length != 0) ? p[0] : "");
281 string p3 = ((p.Length > 1) ? p[1] : "");
282 string p4 = ((p.Length > 2) ? p[2] : "");
283 float.TryParse(p2, out var p0f);
284 float.TryParse(p3, out var result);
285 string text2 = item.TryGetValue("text_JP");
286 bool flag = !text2.IsEmpty();
287 string id = item["id"];
288 if (!id.IsEmpty())
289 {
290 text2 = dictLocalize.TryGetValue(id);
291 flag = !text2.IsEmpty();
292 }
293 if (flag && text2.StartsWith("$") && tg != null && tg.hasChara)
294 {
295 string text3 = text2.Split(' ')[0];
296 text2 = text2.Replace(text3, tg.chara.GetTalkText(text3[1..]));
297 }
298 string jump = item.TryGetValue("jump");
299 string text4 = item.TryGetValue("if");
300 string iF = item.TryGetValue("if2");
301 string cHECK = item.TryGetValue("check");
302 bool flag2 = false;
303 if (!text.IsEmpty() && !sequence.steps.ContainsKey(text) && action != "choice" && action != "cancel")
304 {
305 sequence.steps.Add(text, sequence.events.Count);
306 }
307 if (text4 == "*")
308 {
309 text4 = lastIF;
310 iF = lastIF2;
311 }
312 else
313 {
314 lastIF = text4;
315 lastIF2 = iF;
316 }
317 if (!CheckIF(text4) || !CheckIF(iF))
318 {
319 if (action == "reload")
320 {
321 string id2 = "flag" + countLine;
322 sequence.AddStep(id2);
323 }
324 return;
325 }
326 if (LayerDrama.fromBook && action == "editPlaylist")
327 {
328 action = "BGM";
329 }
330 switch (action)
331 {
332 case "enableFullPortrait":
333 case "disableFullPortrait":
334 AddEvent(delegate
335 {
336 bool flag3 = action == "enableFullPortrait";
337 if (sequence.fullPortrait != flag3)
338 {
339 sequence.fullPortrait = flag3;
340 SetDialog();
341 }
342 });
343 break;
344 case "enableTone":
345 enableTone = true;
346 break;
347 case "canSkip":
348 AddEvent(delegate
349 {
350 sequence.skipJump = p2;
351 });
352 break;
353 case "screenLock":
355 break;
356 case "haltBGM":
357 EMono.Sound.haltUpdate = true;
358 break;
359 case "forceBGM":
360 AddEvent(delegate
361 {
362 SoundManager.ForceBGM();
363 });
364 break;
365 case "setFlag":
366 AddEvent(delegate
367 {
368 if (p2.StartsWith("*"))
369 {
370 Quest quest = EMono.game.quests.Get(p2.TrimStart('*'));
371 quest?.ChangePhase(p3.ToInt(quest.GetType()));
372 }
373 else
374 {
375 EMono.player.dialogFlags[p2] = (p3.IsEmpty() ? 1 : int.Parse(p3));
376 }
377 });
378 break;
379 case "reload":
380 {
381 string __step = "flag" + countLine;
382 AddEvent(delegate
383 {
384 Load();
385 sequence.Play(jump.IsEmpty(__step));
386 }, 0.01f, halt: true);
387 sequence.AddStep(__step);
388 break;
389 }
390 case "inject":
391 {
392 DramaEventTalk dramaEventTalk = lastTalk;
393 if (idDefaultPassed)
394 {
395 AddCustomEvents(p2);
396 }
397 lastTalk = dramaEventTalk;
398 break;
399 }
400 case "topic":
401 customTalkTopics[p2] = text2;
402 break;
403 case "cancel":
404 lastTalk.canCancel = true;
405 lastTalk.idCancelJump = jump;
406 break;
407 case "_choices":
408 foreach (DramaChoice choice in _choices)
409 {
410 lastTalk.AddChoice(choice);
411 }
412 break;
413 case "choice":
414 {
415 if (array.Length > 1)
416 {
417 switch (array[1])
418 {
419 case "quest":
420 text2 = "deQuest".lang();
421 jump = "_quest";
422 break;
423 case "depart":
424 text2 = "depart".lang();
425 jump = "_depart";
426 break;
427 case "rumor":
428 text2 = "letsTalk".lang();
429 jump = "_rumor";
430 break;
431 case "buy":
432 text2 = "daBuy".lang();
433 jump = "_buy";
434 break;
435 case "sell":
436 text2 = "daSell".lang();
437 jump = "_sell";
438 break;
439 case "give":
440 text2 = "daGive".lang();
441 jump = "_give";
442 break;
443 case "trade":
444 text2 = "daTrade".lang();
445 jump = "_trade";
446 break;
447 case "bye":
448 text2 = "bye".lang();
449 jump = "_bye";
450 break;
451 }
452 }
453 flag2 = true;
454 DramaChoice dramaChoice = new DramaChoice(text2, jump, p2, cHECK, text4);
455 lastTalk.AddChoice(dramaChoice);
456 var (invoke, invokeP) = CustomDramaExpansion.BuildInvokeExpression(item.TryGetValue("param"));
457 if (invoke.Method != null)
458 {
459 dramaChoice.idAction = "";
460 dramaChoice.SetCondition(() => invoke.SafeInvoke(this, item, invokeP));
461 }
462 break;
463 }
464 case "addTempActor":
465 {
466 Person person = new Person(actor);
467 Chara chara = EMono.game.cards.globalCharas.Find(actor) ?? EMono._map.FindChara(actor);
468 if (chara != null)
469 {
470 person.SetChara(chara);
471 }
472 sequence.AddActor(actor, person);
473 break;
474 }
475 case "addActor":
476 {
477 if (actor == "god")
478 {
480 break;
481 }
482 DramaActor dramaActor = sequence.AddActor(actor, new Person(actor));
483 if (!text2.IsEmpty())
484 {
485 dramaActor.owner.tempName = text2;
486 }
487 break;
488 }
489 case "invoke":
491 {
492 break;
493 }
494 if (jump.IsEmpty())
495 {
496 AddEvent(delegate
497 {
498 typeof(DramaOutcome).GetMethod(p[0]).Invoke(outcome, null);
499 });
500 break;
501 }
502 AddEvent(delegate
503 {
504 }, () => (!(bool)typeof(DramaOutcome).GetMethod(p[0]).Invoke(outcome, null)) ? "" : jump);
505 flag2 = true;
506 break;
507 case "refAction1":
508 AddEvent(delegate
509 {
511 });
512 break;
513 case "refAction2":
514 AddEvent(delegate
515 {
517 });
518 break;
519 case "setBG":
520 AddEvent(delegate
521 {
522 if (p2.IsEmpty())
523 {
524 imageBG.enabled = false;
525 }
526 else
527 {
528 imageBG.enabled = true;
529 imageBG.sprite = Resources.Load<Sprite>("Media/Graphics/Image/Drama/" + p2) ?? ModUtil.LoadSprite(p2);
530 }
531 });
532 break;
533 case "setBG2":
534 AddEvent(delegate
535 {
536 Util.Instantiate<Transform>("Media/Graphics/Image/Drama/" + p2, layer).SetAsFirstSibling();
537 });
538 break;
539 case "setAdvBG":
540 AddEvent(delegate
541 {
542 if (p2.IsEmpty())
543 {
544 dialog.imageBgAdv.enabled = false;
545 }
546 else
547 {
548 dialog.imageBgAdv.enabled = true;
549 dialog.imageBgAdv.sprite = Resources.Load<Sprite>("Media/Graphics/Image/Drama/" + p2) ?? ModUtil.LoadSprite(p2);
550 }
551 });
552 break;
553 case "glitch":
554 AddEvent(delegate
555 {
556 DramaActor.useGlitch = true;
557 });
558 break;
559 case "setDialog":
560 AddEvent(delegate
561 {
562 SetDialog(p2.IsEmpty("Default"));
563 });
564 break;
565 case "Playlist":
566 AddEvent(delegate
567 {
568 LayerDrama.haltPlaylist = false;
569 EMono.Sound.StopBGM();
570 EMono.Sound.currentBGM = null;
571 bgmChanged = true;
572 });
573 break;
574 case "editPlaylist":
575 AddEvent(delegate
576 {
577 List<int> list = new List<int>();
578 string[] array2 = p;
579 foreach (string s in array2)
580 {
581 list.Add(int.Parse(s));
582 }
583 EMono._zone.SetBGM(list);
584 });
585 break;
586 case "BGM":
587 AddEvent(delegate
588 {
589 LayerDrama.haltPlaylist = true;
590 LayerDrama.maxBGMVolume = true;
591 EMono.Sound.PlayBGM(EMono.core.refs.dictBGM[p2.ToInt()]);
592 bgmChanged = true;
593 });
594 break;
595 case "BGMStay":
596 AddEvent(delegate
597 {
598 EMono.Sound.PlayBGM(EMono.core.refs.dictBGM[p2.ToInt()]);
599 });
600 break;
601 case "lastBGM":
602 AddEvent(delegate
603 {
604 EMono.Sound.StopBGM(p0f, playLastBGM: true);
605 });
606 break;
607 case "stopBGM":
608 AddEvent(delegate
609 {
610 LayerDrama.haltPlaylist = true;
611 EMono.Sound.StopBGM(p0f);
612 EMono.Sound.currentBGM = null;
613 });
614 break;
615 case "sound":
616 AddEvent(delegate
617 {
618 if (p3 != "")
619 {
620 SoundManager.current.MuteBGMFor(float.Parse(p3, CultureInfo.InvariantCulture));
621 }
622 lastSound?.Stop();
623 lastSound = EMono.Sound.Play(p2);
624 });
625 break;
626 case "haltPlaylist":
627 LayerDrama.haltPlaylist = true;
628 break;
629 case "keepBGM":
630 LayerDrama.keepBGM = true;
631 break;
632 case "alphaInOut":
633 AddEvent(delegate
634 {
635 DOTween.Kill(cg);
636 cg.alpha = 1f;
637 cg.DOFade(0f, p0f).SetDelay(0.1f);
638 }, p0f, halt: true);
639 AddEvent(new DramaEventWait((result == 0f) ? 0.1f : result));
640 AddEvent(delegate
641 {
642 DOTween.Kill(cg);
643 cg.alpha = 0f;
644 cg.DOFade(1f, p0f).SetDelay(0.1f);
645 }, p0f);
646 break;
647 case "alphaIn":
648 AddEvent(delegate
649 {
650 DOTween.Kill(cg);
651 cg.alpha = 0f;
652 cg.DOFade(1f, p0f).SetDelay(0.1f);
653 }, p0f);
654 break;
655 case "alphaOut":
656 AddEvent(delegate
657 {
658 DOTween.Kill(cg);
659 cg.alpha = 1f;
660 cg.DOFade(0f, p0f).SetDelay(0.1f);
661 }, p0f, halt: true);
662 break;
663 case "fadeIn":
664 AddEvent(delegate
665 {
666 imageCover.color = ((p3 != null && p3 == "white") ? Color.white : Color.black);
667 cgCover.SetActive(enable: true);
668 cgCover.alpha = 1f;
669 cgCover.DOFade(0f, p0f).SetDelay(0.1f);
670 }, p0f);
671 break;
672 case "fadeOut":
673 AddEvent(delegate
674 {
675 imageCover.color = ((p3 != null && p3 == "white") ? Color.white : Color.black);
676 cgCover.SetActive(enable: true);
677 cgCover.alpha = 0f;
678 cgCover.DOFade(1f, p0f).SetDelay(0.1f);
679 }, p0f, halt: true);
680 break;
681 case "fadeInOut":
682 AddEvent(delegate
683 {
684 imageCover.color = ((p4 != null && p4 == "white") ? Color.white : Color.black);
685 cgCover.SetActive(enable: true);
686 cgCover.alpha = 0f;
687 cgCover.DOFade(1f, p0f).SetDelay(0.1f);
688 }, p0f, halt: true);
689 AddEvent(new DramaEventWait((result == 0f) ? 0.1f : result));
690 AddEvent(delegate
691 {
692 imageCover.color = ((p4 != null && p4 == "white") ? Color.white : Color.black);
693 cgCover.SetActive(enable: true);
694 cgCover.alpha = 1f;
695 cgCover.DOFade(0f, p0f).SetDelay(0.1f);
696 }, p0f);
697 break;
698 case "hideUI":
699 AddEvent(delegate
700 {
701 EMono.ui.Hide(p0f);
702 });
703 break;
704 case "hideDialog":
705 AddEvent(delegate
706 {
707 dialog.SetActive(enable: false);
708 });
709 break;
710 case "fadeEnd":
711 if (p0f == 0f)
712 {
713 p0f = 1f;
714 }
715 AddEvent(delegate
716 {
717 imageCover.color = Color.black;
718 cgCover.SetActive(enable: true);
719 cgCover.alpha = 0f;
720 cgCover.DOFade(1f, p0f).SetDelay(0.1f);
721 }, p0f, halt: true);
722 AddEvent(delegate
723 {
724 dialog.SetActive(enable: false);
725 imageBG.enabled = false;
726 });
727 AddEvent(delegate
728 {
729 DOTween.Kill(cg);
730 cg.alpha = 1f;
731 cg.DOFade(0f, p0f).SetDelay(0.1f);
732 }, p0f, halt: true);
733 break;
734 case "endroll":
736 break;
737 case "showSkip":
738 goSkip.SetActive(value: true);
739 break;
740 case "canCancel":
741 AddEvent(delegate
742 {
743 sequence.canCancel = bool.Parse(p2);
744 });
745 break;
746 case "wait":
747 AddEvent(new DramaEventWait(p0f));
748 break;
749 case "end":
751 break;
752 case "modAffinity":
753 AddEvent(delegate
754 {
755 int num = int.Parse(p2);
756 if (EMono.debug.enable)
757 {
758 num *= 10;
759 }
761 });
762 break;
763 case "acceptQuest":
765 {
766 break;
767 }
768 AddEvent(delegate
769 {
770 Quest quest = EMono.game.quests.globalList.Where((Quest a) => a.source.id == p2).First();
771 EMono.game.quests.globalList.Remove(quest);
772 EMono.game.quests.Start(quest);
773 });
774 break;
775 case "startQuest":
776 AddEvent(delegate
777 {
778 Quest quest = Quest.Create(p2);
779 if (!quest.HasDLC)
780 {
781 Msg.Say("(Failed DLC check)");
782 }
783 else
784 {
785 EMono.game.quests.Start(quest);
786 LayerDrama.currentQuest = quest;
787 if (tg != null && tg.chara != null)
788 {
789 Debug.Log("Starting Quest:" + quest?.ToString() + "/" + tg.chara.quest?.ToString() + "/" + (quest == tg.chara.quest));
790 }
791 }
792 });
793 break;
794 case "setQuestClient":
795 AddEvent(delegate
796 {
797 if (LayerDrama.currentQuest != null)
798 {
799 LayerDrama.currentQuest.SetClient(tg.chara, assignQuest: false);
800 }
801 });
802 break;
803 case "updateJournal":
804 AddEvent(delegate
805 {
807 });
808 break;
809 case "addKeyItem":
810 if (!LayerDrama.fromBook)
811 {
812 AddEvent(delegate
813 {
814 int num = p3.ToInt();
815 EMono.player.ModKeyItem(p2, (num == 0) ? 1 : num);
816 });
817 }
818 break;
819 case "drop":
820 if (!LayerDrama.fromBook)
821 {
822 AddEvent(delegate
823 {
824 Msg.Say("dropReward");
826 Thing t = ThingGen.Create(p2);
828 });
829 }
830 break;
831 case "completeQuest":
832 if (!LayerDrama.fromBook)
833 {
834 AddEvent(delegate
835 {
838 });
839 }
840 break;
841 case "nextPhase":
842 if (!LayerDrama.fromBook)
843 {
844 AddEvent(delegate
845 {
846 EMono.game.quests.Get(p2).NextPhase();
847 });
848 }
849 break;
850 case "changePhase":
851 if (!LayerDrama.fromBook)
852 {
853 AddEvent(delegate
854 {
855 EMono.game.quests.Get(p2).ChangePhase(p3.ToInt());
856 });
857 }
858 break;
859 case "addResource":
860 AddEvent(delegate
861 {
862 EMono.BranchOrHomeBranch.resources.Get(p2).Mod(p3.ToInt());
863 });
864 break;
865 case "getAchievement":
866 AddEvent(delegate
867 {
868 if (new string[2] { "ONEV", "NERUN2" }.Contains(p2))
869 {
870 Steam.GetAchievement(p2.ToEnum<ID_Achievement>());
871 }
872 });
873 break;
874 case "bossText":
875 AddEvent(delegate
876 {
877 foreach (Chara chara3 in EMono._map.charas)
878 {
879 if (chara3.bossText)
880 {
881 chara3.renderer.ShowBossText();
882 }
883 }
884 });
885 break;
886 case "shake":
887 AddEvent(delegate
888 {
890 });
891 break;
892 case "tutorial":
894 {
895 Tutorial.Play(p2);
896 });
897 break;
898 case "slap":
899 AddEvent(delegate
900 {
902 {
904 });
905 });
906 break;
907 case "removeItem":
908 AddEvent(delegate
909 {
910 Thing thing = EMono.pc.things.Find(p2);
911 int num = p3.ToInt();
912 thing?.ModNum((num == 0) ? (-1) : (-num));
913 });
914 break;
915 case "destroyItem":
916 AddEvent(delegate
917 {
918 EMono.pc.things.Find(p2).Destroy();
919 });
920 break;
921 case "focus":
922 AddEvent(delegate
923 {
925 EMono.scene.screenElin.focusOption = new BaseGameScreen.FocusOption
926 {
927 pos = pos
928 };
929 });
930 break;
931 case "focusChara":
932 AddEvent(delegate
933 {
934 Point pos = EMono._map.FindChara(p2).pos.Copy();
936 {
937 pos = pos,
938 speed = p3.IsEmpty("2").ToFloat()
939 };
940 });
941 break;
942 case "focusPC":
943 AddEvent(delegate
944 {
945 EMono.scene.screenElin.focusOption = new BaseGameScreen.FocusOption
946 {
947 player = true,
948 speed = p2.IsEmpty("2").ToFloat()
949 };
950 });
951 break;
952 case "focusPos":
953 AddEvent(delegate
954 {
955 EMono.scene.screenElin.focusOption = new BaseGameScreen.FocusOption
956 {
957 pos = new Point(p2.ToInt(), p3.ToInt()),
958 speed = p4.IsEmpty("2").ToFloat()
959 };
960 });
961 break;
962 case "unfocus":
963 AddEvent(delegate
964 {
965 EMono.scene.screenElin.focusOption = null;
966 });
967 break;
968 case "setAlwaysVisible":
969 AddEvent(delegate
970 {
971 LayerDrama.alwaysVisible = EMono._map.FindChara(p2);
972 });
973 break;
974 case "effect":
975 AddEvent(delegate
976 {
977 Point point = new Point(p[1].ToInt(), p[2].ToInt());
978 Effect.Get(p2).Play(point);
979 });
980 break;
981 case "effectEmbarkIn":
982 AddEvent(delegate
983 {
985 Util.Instantiate("UI/Layer/LayerEmbark/EmbarkActor_crystal");
986 });
987 break;
988 case "effectEmbarkOut":
989 AddEvent(delegate
990 {
991 UnityEngine.Object.FindObjectOfType<EmbarkActor>().Hide();
992 });
993 break;
994 case "propEnter":
995 AddEvent(delegate
996 {
997 DramaProp component = Util.Instantiate("Media/Drama/Prop/" + p2).GetComponent<DramaProp>();
998 component.name = p2;
999 if (p3.IsEmpty())
1000 {
1001 component.transform.position = EMono.scene.cam.transform.position;
1002 }
1003 else
1004 {
1005 Point point = new Point(p[1].ToInt(), p[2].ToInt());
1006 component.transform.position = point.PositionCenter();
1007 }
1008 component.Enter();
1009 });
1010 break;
1011 case "propLeave":
1012 AddEvent(delegate
1013 {
1014 GameObject.Find(p2).GetComponent<DramaProp>().Leave();
1015 });
1016 break;
1017 case "destroy":
1018 AddEvent(delegate
1019 {
1020 Chara chara2 = EMono._map.FindChara(p2);
1021 if (chara2 != null)
1022 {
1023 chara2.Destroy();
1024 }
1025 else
1026 {
1027 Debug.Log("Drama.destroy chara not found:" + p2);
1028 }
1029 });
1030 break;
1031 case "bout_win":
1032 case "bout_lose":
1033 AddEvent(delegate
1034 {
1036 {
1038 if (action == "bout_win")
1039 {
1041 {
1042 target = tg.chara
1043 });
1044 }
1045 EMono.pc.MoveZone(zone);
1046 });
1047 });
1048 break;
1049 case "moveZone":
1050 AddEvent(delegate
1051 {
1053 });
1054 break;
1055 case "save":
1056 AddEvent(delegate
1057 {
1058 EMono.game.Save(isAutoSave: false, silent: true);
1059 });
1060 break;
1061 case "setHour":
1062 AddEvent(delegate
1063 {
1064 EMono.world.date.hour = (int)p0f;
1065 EMono.world.date.min = 0;
1069 });
1070 break;
1071 case "%worship":
1072 AddEvent(delegate
1073 {
1075 Tutorial.Reserve("faith");
1076 });
1077 break;
1078 case "replace":
1079 AddEvent(delegate
1080 {
1081 textReplace = text2;
1082 });
1083 break;
1084 default:
1085 if (CustomDramaExpansion.ParseAction(action, this, item))
1086 {
1087 return;
1088 }
1089 if (!flag)
1090 {
1091 break;
1092 }
1093 lastTalk = AddEvent(new DramaEventTalk(actor, delegate
1094 {
1095 if (!textReplace.IsEmpty())
1096 {
1097 text2 = textReplace;
1098 textReplace = null;
1099 }
1100 if (text2.StartsWith("#eval"))
1101 {
1102 string script = text2[5..].Trim();
1103 if (!EScript.IsScriptingAvailable)
1104 {
1105 return ("[ID '" + id + "'] <scripting is disabled>").TagColor(Color.red);
1106 }
1107 Func<EDramaScriptState, object> func = Scripting.Compile<EDramaScriptState>(script);
1109 {
1110 dm = this,
1111 line = item
1112 };
1113 text2 = func(arg).TryToString("[ID '" + id + "'] <scripting returns no text>");
1114 }
1115 if (tg != null && (actor == "tg" || actor.IsEmpty()))
1116 {
1117 text2 = (enableTone ? tg.ApplyTone(text2) : text2);
1118 }
1119 return text2;
1120 })) as DramaEventTalk;
1121 lastTalk.ignoreClickSound = action == "ignoreClickSound";
1122 lastTalk.center = p2 == "center";
1123 break;
1124 case "new":
1125 case "saveBGM":
1126 case "checkAffinity":
1127 break;
1128 }
1129 if (!string.IsNullOrEmpty(jump) && !flag2)
1131 AddEvent(new DramaEventGoto(jump));
1132 }
1133 }
1134
1135 public Chara GetChara(string id)
1136 {
1137 return GetPerson(id)?.chara;
1138 }
1139
1140 public Person GetPerson(string id)
1141 {
1142 return GetActor(id)?.owner;
1143 }
1144
1145 public DramaActor GetActor(string id)
1146 {
1147 return sequence.GetActor(id);
1148 }
1149
1151 {
1152 return sequence.AddEvent(e);
1153 }
1154
1155 public DramaEventMethod AddEvent(Action func, float duration = 0f, bool halt = false)
1156 {
1157 return AddEvent(new DramaEventMethod(func, duration, halt)) as DramaEventMethod;
1158 }
1159
1160 public DramaEventMethod AddEvent(Action func, Func<string> funcJump)
1161 {
1162 return AddEvent(new DramaEventMethod(func)
1164 jumpFunc = funcJump
1165 }) as DramaEventMethod;
1166 }
1167
1168 public DramaEvent CustomEvent(Action func, string step = null, float duration = 0f, bool halt = false)
1169 {
1170 DramaEventMethod dramaEventMethod = new DramaEventMethod(func, duration, halt)
1171 {
1172 step = step
1174 customEvents.Add(dramaEventMethod);
1175 return dramaEventMethod;
1176 }
1177
1178 public void SetDialog(string id = "Default")
1179 {
1180 if (id == "Default")
1181 {
1182 DramaSequence dramaSequence = sequence;
1183 if (dramaSequence != null && dramaSequence.fullPortrait)
1184 {
1185 id = "Full";
1186 }
1187 }
1188 DialogDrama[] componentsInChildren = GetComponentsInChildren<DialogDrama>(includeInactive: true);
1189 foreach (DialogDrama dialogDrama in componentsInChildren)
1190 {
1191 dialogDrama.SetActive(enable: false);
1192 if (dialogDrama.name == "Dialog" + id)
1193 {
1194 dialog = dialogDrama;
1195 }
1196 }
1197 }
1198
1199 public bool CheckIF(string IF)
1200 {
1201 if (IF == null || IF.IsEmpty())
1202 {
1203 return true;
1204 }
1205 string[] array = IF.Split(',');
1206 switch (array[0])
1207 {
1208 case "garden_bloom":
1209 foreach (Chara member in EMono.pc.party.members)
1210 {
1211 if (member.CanBloom())
1212 {
1213 return true;
1214 }
1215 }
1216 return false;
1217 case "wedding_whoring":
1218 return false;
1219 case "duponne_mino":
1220 return EMono.pc.things.Find("minohorn") != null;
1221 case "duponne_rescued":
1223 {
1224 return EMono._map.FindChara("lurie_boss") != null;
1225 }
1226 return false;
1227 case "duponne_gone":
1229 {
1230 return EMono.pc.things.Find("duponneball") == null;
1231 }
1232 return false;
1233 case "duponne_killed":
1235 {
1237 }
1238 return false;
1239 case "survival":
1240 return EMono.game.IsSurvival;
1241 case "!survival":
1242 return !EMono.game.IsSurvival;
1243 case "fromBook":
1244 return LayerDrama.fromBook;
1245 case "nerun_nadenade":
1246 if (!EMono.game.startVersion.IsBelow(0, 23, 232))
1247 {
1248 return EMono.player.stats.death2 == 0;
1249 }
1250 return false;
1251 case "nerun_nadenade2":
1252 GameLang.refDrama1 = EMono.player.stats.death2.ToString() ?? "";
1253 return EMono.player.stats.death2 >= 100;
1254 case "!fromBook":
1255 return !LayerDrama.fromBook;
1256 case "WindRest":
1257 return EMono._zone is Zone_WindRest;
1258 case "guild_promote":
1259 return Guild.CurrentDrama.relation.exp >= Guild.CurrentDrama.relation.ExpToNext;
1260 case "guild_maxpromote":
1261 return Guild.CurrentDrama.relation.rank >= Guild.CurrentDrama.relation.MaxRank;
1262 case "scratch_check":
1263 return EMono.game.dateScratch > EMono.game.world.date.GetRaw();
1264 case "sister_money":
1265 return EMono.pc.GetCurrency() >= 10000;
1266 case "fiamaPet":
1267 if (EMono.pc.homeBranch != null)
1268 {
1269 foreach (Chara member2 in EMono.pc.homeBranch.members)
1270 {
1271 if (member2.isDead && member2.CanRevive() && member2.GetInt(100) != 0)
1272 {
1273 return true;
1274 }
1275 }
1276 }
1277 return false;
1278 case "hasMelilithCurse":
1279 return EMono.pc.HasElement(1206);
1280 case "merchant":
1281 return Guild.CurrentDrama == Guild.Merchant;
1282 case "fighter":
1283 return Guild.CurrentDrama == Guild.Fighter;
1284 case "thief":
1285 return Guild.CurrentDrama == Guild.Thief;
1286 case "mage":
1287 return Guild.CurrentDrama == Guild.Mage;
1288 case "hasDLC":
1289 return Steam.HasDLC(array[1].ToEnum<ID_DLC>());
1290 case "hasFlag":
1291 return EMono.player.dialogFlags.TryGetValue(array[1], 0) != 0;
1292 case "!hasFlag":
1293 return EMono.player.dialogFlags.TryGetValue(array[1], 0) == 0;
1294 case "!hasMiscreation":
1295 return !EMono.pc.party.HasElement(1248, excludePC: true);
1296 case "hasItem":
1297 return EMono.pc.things.Find(array[1]) != null;
1298 case "nasuDeliver":
1299 if (EMono.game.quests.GetPhase<QuestNasu>() == 2)
1300 {
1301 return EMono.pc.things.Find("backpack_holding") != null;
1302 }
1303 return false;
1304 case "isCompleted":
1305 return EMono.game.quests.IsCompleted(array[1]);
1306 case "costRecruit":
1307 if (EMono.Branch != null && EMono.Branch.IsRecruit(tg.chara))
1308 {
1309 return EMono.pc.GetCurrency("money2") >= CalcGold.Hire(tg.chara);
1310 }
1311 return true;
1312 case "costRecruitTicket":
1313 if (EMono.Branch != null && EMono.Branch.IsRecruit(tg.chara))
1314 {
1315 return EMono.pc.things.Find("ticket_resident") != null;
1316 }
1317 return false;
1318 case "letterTrial":
1320 {
1321 return EMono.pc.things.Find("letter_trial") != null;
1322 }
1323 return false;
1324 default:
1325 if (array.Length > 2)
1326 {
1327 int value;
1328 bool flag = EMono.player.dialogFlags.TryGetValue(array[1], out value);
1329 int num = 0;
1330 if (array[1].StartsWith("*"))
1331 {
1332 string text = array[1].TrimStart('*');
1333 Quest quest = EMono.game.quests.Get(text);
1334 if (text == "guild")
1335 {
1336 quest = Guild.CurrentQuest;
1337 }
1338 flag = quest != null;
1339 if (!EMono.game.quests.completedIDs.Contains(text))
1340 {
1341 value = quest?.phase ?? (-1);
1342 }
1343 else
1344 {
1345 value = 999;
1346 flag = true;
1347 }
1348 num = ((!int.TryParse(array[2], out var result)) ? ((quest != null) ? array[2].ToInt(quest.GetType()) : 0) : result);
1349 }
1350 else
1351 {
1352 num = int.Parse(array[2]);
1353 }
1354 switch (array[0])
1355 {
1356 case "=":
1357 if (!flag && num == -1)
1358 {
1359 return true;
1360 }
1361 if (flag && value == num)
1362 {
1363 return true;
1364 }
1365 break;
1366 case "!":
1367 if (!flag || value != num)
1368 {
1369 return true;
1370 }
1371 break;
1372 case ">":
1373 if (flag && value > num)
1374 {
1375 return true;
1376 }
1377 break;
1378 case ">=":
1379 if (flag && value >= num)
1380 {
1381 return true;
1382 }
1383 break;
1384 case "<":
1385 if (!flag || value < num)
1386 {
1387 return true;
1388 }
1389 break;
1390 case "<=":
1391 if (!flag || value <= num)
1392 {
1393 return true;
1394 }
1395 break;
1396 }
1397 return false;
1399 return setup.tag == IF;
1400 }
1401 }
1402
1403 public void Show()
1404 {
1405 SE.PopDrama();
1406 layer.SetActive(enable: true);
1407 layer.cg.alpha = 0f;
1408 layer.cg.DOFade(1f, 0.3f);
1409 }
1410
1411 public void Hide()
1412 {
1413 layer.SetActive(enable: false);
1414 }
1415}
if(!match.Success)
ID_Achievement
FocusOption focusOption
static int Hire(Chara c)
Definition: CalcGold.cs:8
static void SetNormalRarity(bool fixedMat=false)
Chara Find(string id)
Definition: CardManager.cs:20
GlobalCharaList globalCharas
Definition: CardManager.cs:46
int GetCurrency(string id="money")
Definition: Card.cs:4168
void RecalculateFOV()
Definition: Card.cs:6883
string GetTalkText(string idTopic, bool stripPun=false, bool useDefault=true)
Definition: Card.cs:7372
Point pos
Definition: Card.cs:60
void Destroy()
Definition: Card.cs:5330
ThingContainer things
Definition: Card.cs:39
void ModNum(int a, bool notify=true)
Definition: Card.cs:3708
int GetInt(string id, int? defaultInt=null)
Definition: Card.cs:2579
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6399
Definition: Chara.cs:10
bool CanRevive()
Definition: Chara.cs:5530
void ModAffinity(Chara c, int a, bool show=true, bool showOnlyEmo=false)
Definition: Chara.cs:8537
Party party
Definition: Chara.cs:45
void Slap(Chara c, bool slapToDeath=false)
Definition: Chara.cs:6758
Zone currentZone
Definition: Chara.cs:261
bool CanBloom()
Definition: Chara.cs:9350
FactionBranch homeBranch
Definition: Chara.cs:1122
bool isDead
Definition: Chara.cs:395
void MoveZone(string alias)
Definition: Chara.cs:3626
bool enable
Definition: CoreDebug.cs:302
Dictionary< int, BGMData > dictBGM
Definition: CoreRef.cs:388
CoreRef refs
Definition: Core.cs:51
int GetRaw(int offsetHours=0)
Definition: Date.cs:328
DramaChoice SetCondition(Func< bool > condition)
Definition: DramaChoice.cs:62
void AddChoice(DramaChoice choice)
Dictionary< string, string > dictLocalize
Definition: DramaManager.cs:54
DramaSequence sequence
Definition: DramaManager.cs:28
DramaOutcome outcome
Definition: DramaManager.cs:30
bool customEventsAdded
Definition: DramaManager.cs:71
string lastIF2
Definition: DramaManager.cs:63
DramaEventMethod AddEvent(Action func, float duration=0f, bool halt=false)
string textReplace
Definition: DramaManager.cs:79
CanvasGroup cg
Definition: DramaManager.cs:16
DramaEvent CustomEvent(Action func, string step=null, float duration=0f, bool halt=false)
LayerDrama layer
Definition: DramaManager.cs:14
CanvasGroup cgCover
Definition: DramaManager.cs:18
DialogDrama dialog
Definition: DramaManager.cs:32
Font[] fonts
Definition: DramaManager.cs:42
static Dictionary< string, ExcelData > dictCache
Definition: DramaManager.cs:81
DramaSequence Load()
Transform actorPos
Definition: DramaManager.cs:22
bool CheckIF(string IF)
bool idDefaultPassed
Definition: DramaManager.cs:73
void ParseLine(Dictionary< string, string > item)
void AddCustomEvents(string idCustom="Resident")
DramaEventMethod AddEvent(Action func, Func< string > funcJump)
UIDynamicList listCredit
Definition: DramaManager.cs:20
void SetDialog(string id="Default")
SoundSource lastSound
Definition: DramaManager.cs:65
List< DramaChoice > _choices
Definition: DramaManager.cs:50
Dictionary< string, string > customTalkTopics
Definition: DramaManager.cs:52
EScriptSubmission Scripting
Definition: DramaManager.cs:85
DramaActor moldActor
Definition: DramaManager.cs:26
Image imageCover
Definition: DramaManager.cs:40
string idDefault
Definition: DramaManager.cs:77
List< DramaEvent > customEvents
Definition: DramaManager.cs:48
DramaEventTalk lastTalk
Definition: DramaManager.cs:67
Transform endroll
Definition: DramaManager.cs:24
string lastIF
Definition: DramaManager.cs:61
DramaSequence Play(DramaSetup setup)
bool keepAmbientBGM
Definition: DramaManager.cs:83
float creditSpeed
Definition: DramaManager.cs:56
DramaEvent AddEvent(DramaEvent e)
static Chara TG
Definition: DramaManager.cs:12
void Update()
Definition: DramaManager.cs:89
GameObject goSkip
Definition: DramaManager.cs:36
DramaSetup setup
Definition: DramaManager.cs:34
DramaActor tgActor
Definition: DramaManager.cs:87
void Enter()
Definition: DramaProp.cs:11
DramaSetup setup
List< DramaEvent > events
DramaActor AddActor(string id, Person person)
DramaActor GetActor(string id)
DramaEvent AddEvent(DramaEvent e)
void Play(string id)
void AddStep(string id)
Dictionary< string, int > steps
string sheet
Definition: DramaSetup.cs:5
string step
Definition: DramaSetup.cs:7
string book
Definition: DramaSetup.cs:9
Person person
Definition: DramaSetup.cs:19
string textData
Definition: DramaSetup.cs:11
string forceJump
Definition: DramaSetup.cs:13
Definition: EMono.cs:4
static Core core
Definition: EMono.cs:5
static Chara pc
Definition: EMono.cs:13
static Player player
Definition: EMono.cs:11
static Zone _zone
Definition: EMono.cs:19
static FactionBranch BranchOrHomeBranch
Definition: EMono.cs:23
static Game game
Definition: EMono.cs:7
static Scene scene
Definition: EMono.cs:27
static UI ui
Definition: EMono.cs:15
static SoundManager Sound
Definition: EMono.cs:39
static FactionBranch Branch
Definition: EMono.cs:21
static Map _map
Definition: EMono.cs:17
static CoreDebug debug
Definition: EMono.cs:45
Definition: Effect.cs:7
static Effect Get(Effect original)
Definition: Effect.cs:80
void Play(float delay, Point from, float fixY=0f, Point to=null, Sprite sprite=null)
Definition: Effect.cs:100
bool IsModified()
Definition: ExcelData.cs:72
List< Dictionary< string, string > > BuildList(string sheetName="_default")
Definition: ExcelData.cs:92
string path
Definition: ExcelData.cs:27
bool IsRecruit(Chara c)
List< Chara > members
HomeResourceManager resources
FactionRelation relation
Definition: FACTION.cs:126
bool Save(bool isAutoSave=false, bool silent=false)
Definition: Game.cs:1116
SpatialManager spatials
Definition: Game.cs:153
CardManager cards
Definition: Game.cs:156
bool IsSurvival
Definition: Game.cs:276
Version startVersion
Definition: Game.cs:171
new World world
Definition: Game.cs:177
QuestManager quests
Definition: Game.cs:183
Definition: Guild.cs:2
static Guild CurrentDrama
Definition: Guild.cs:24
static GuildMerchant Merchant
Definition: Guild.cs:62
static QuestGuild CurrentQuest
Definition: Guild.cs:64
static GuildMage Mage
Definition: Guild.cs:58
static GuildFighter Fighter
Definition: Guild.cs:56
static GuildThief Thief
Definition: Guild.cs:60
Definition: Hide.cs:4
BaseHomeResource Get(string id)
Definition: Lang.cs:7
static string langCode
Definition: Lang.cs:29
CanvasGroup cg
Definition: LayerDrama.cs:30
static LayerDrama Instance
Definition: LayerDrama.cs:20
static bool fromBook
Definition: LayerDrama.cs:16
static Quest currentQuest
Definition: LayerDrama.cs:6
static Religion currentReligion
Definition: LayerDrama.cs:8
static Action refAction2
Definition: LayerDrama.cs:26
static Action refAction1
Definition: LayerDrama.cs:24
void ShowScreenLock(string id)
Definition: Layer.cs:207
virtual void Close()
Definition: Layer.cs:468
Layer SetOnKill(Action action)
Definition: Layer.cs:584
Chara FindChara(string id)
Definition: Map.cs:2778
List< Chara > charas
Definition: Map.cs:87
void RevealAll(bool reveal=true)
Definition: Map.cs:1021
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
bool HasElement(int ele, bool excludePC=false)
Definition: Party.cs:212
List< Chara > members
Definition: Party.cs:19
Definition: Person.cs:6
bool hasChara
Definition: Person.cs:38
void SetChara(Chara c)
Definition: Person.cs:88
Chara chara
Definition: Person.cs:36
bool killedDuponne
Definition: Player.cs:592
int death2
Definition: Player.cs:105
Flags flags
Definition: Player.cs:1173
Stats stats
Definition: Player.cs:1095
Dictionary< string, int > dialogFlags
Definition: Player.cs:1119
void ModKeyItem(string alias, int num=1, bool msg=true)
Definition: Player.cs:2243
void MoveZone(Zone z)
Definition: Player.cs:2136
Definition: Point.cs:9
Point Copy()
Definition: Point.cs:487
HashSet< string > completedIDs
Definition: QuestManager.cs:17
int GetPhase(string id)
void Complete(Quest q)
Definition: QuestManager.cs:98
bool IsCompleted(string id)
void UpdateJournal()
Quest Start(string id, string idGlobalChara)
Definition: QuestManager.cs:41
List< Quest > globalList
Definition: QuestManager.cs:14
Quest Get(string id)
Definition: Quest.cs:7
virtual bool HasDLC
Definition: Quest.cs:147
static Quest Create(string _id, string _idPerson=null, Chara c=null, bool assignQuest=true)
Definition: Quest.cs:241
int phase
Definition: Quest.cs:40
virtual SourceQuest.Row source
Definition: Quest.cs:107
virtual void JoinFaith(Chara c, ConvertType type=ConvertType.Default)
Definition: Religion.cs:341
GameScreen screenElin
Definition: Scene.cs:93
void OnChangeHour()
Definition: Scene.cs:782
Definition: Shaker.cs:5
static void ShakeCam(string id="default", float magnitude=1f)
Definition: Shaker.cs:25
Zone Find(string id)
Definition: Steam.cs:12
static void GetAchievement(ID_Achievement id)
Definition: Steam.cs:53
static bool HasDLC(ID_DLC id)
Definition: Steam.cs:43
Thing Find(int uid)
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
static void Reserve(string idStep, Action onBeforePlay=null)
Definition: Tutorial.cs:55
static void Play(string idStep)
Definition: Tutorial.cs:7
Definition: Util.cs:10
static Transform Instantiate(string path, Component parent=null)
Definition: Util.cs:67
GameDate date
Definition: World.cs:6
void AddPreEnter(ZonePreEnterEvent e, bool executeIfActiveZone=true)
Definition: Zone.cs:12
ZoneEventManager events
Definition: Zone.cs:43
void SetBGM(List< int > ids, bool refresh=true, float fadeDuration=0f)
Definition: Zone.cs:3265
ZoneInstance instance
Definition: Zone.cs:58
Card AddCard(Card t, Point point)
Definition: Zone.cs:2162
bool IsBelow(int _major, int _minor, int _batch)
Definition: Version.cs:49