Elin Decompiled Documentation EA 23.316 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 text2 = item.TryGetValue("step");
268 if (text2 == "//")
269 {
270 return;
271 }
272 if (text2 == 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 text = item.TryGetValue("text_JP");
286 bool flag = !text.IsEmpty();
287 string id = item["id"];
288 if (!id.IsEmpty())
289 {
290 text = dictLocalize.TryGetValue(id);
291 flag = !text.IsEmpty();
292 }
293 if (flag && text.StartsWith("$") && tg != null && tg.hasChara)
294 {
295 string text3 = text.Split(' ')[0];
296 text = text.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 (!text2.IsEmpty() && !sequence.steps.ContainsKey(text2) && action != "choice" && action != "cancel")
304 {
305 sequence.steps.Add(text2, 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 "disableFullPortrait":
333 AddEvent(delegate
334 {
335 sequence.fullPortrait = false;
336 });
337 break;
338 case "enableTone":
339 enableTone = true;
340 break;
341 case "canSkip":
342 AddEvent(delegate
343 {
344 sequence.skipJump = p2;
345 });
346 break;
347 case "screenLock":
349 break;
350 case "haltBGM":
351 EMono.Sound.haltUpdate = true;
352 break;
353 case "forceBGM":
354 AddEvent(delegate
355 {
356 SoundManager.ForceBGM();
357 });
358 break;
359 case "setFlag":
360 AddEvent(delegate
361 {
362 if (p2.StartsWith("*"))
363 {
364 Quest quest3 = EMono.game.quests.Get(p2.TrimStart('*'));
365 quest3?.ChangePhase(p3.ToInt(quest3.GetType()));
366 }
367 else
368 {
369 EMono.player.dialogFlags[p2] = (p3.IsEmpty() ? 1 : int.Parse(p3));
370 }
371 });
372 break;
373 case "reload":
374 {
375 string __step = "flag" + countLine;
376 AddEvent(delegate
377 {
378 Load();
379 sequence.Play(jump.IsEmpty(__step));
380 }, 0.01f, halt: true);
381 sequence.AddStep(__step);
382 break;
383 }
384 case "inject":
385 {
386 DramaEventTalk dramaEventTalk = lastTalk;
387 if (idDefaultPassed)
388 {
389 AddCustomEvents(p2);
390 }
391 lastTalk = dramaEventTalk;
392 break;
393 }
394 case "topic":
395 customTalkTopics[p2] = text;
396 break;
397 case "cancel":
398 lastTalk.canCancel = true;
399 lastTalk.idCancelJump = jump;
400 break;
401 case "_choices":
402 foreach (DramaChoice choice in _choices)
403 {
404 lastTalk.AddChoice(choice);
405 }
406 break;
407 case "choice":
408 {
409 if (array.Length > 1)
410 {
411 switch (array[1])
412 {
413 case "quest":
414 text = "deQuest".lang();
415 jump = "_quest";
416 break;
417 case "depart":
418 text = "depart".lang();
419 jump = "_depart";
420 break;
421 case "rumor":
422 text = "letsTalk".lang();
423 jump = "_rumor";
424 break;
425 case "buy":
426 text = "daBuy".lang();
427 jump = "_buy";
428 break;
429 case "sell":
430 text = "daSell".lang();
431 jump = "_sell";
432 break;
433 case "give":
434 text = "daGive".lang();
435 jump = "_give";
436 break;
437 case "trade":
438 text = "daTrade".lang();
439 jump = "_trade";
440 break;
441 case "bye":
442 text = "bye".lang();
443 jump = "_bye";
444 break;
445 }
446 }
447 flag2 = true;
448 DramaChoice dramaChoice = new DramaChoice(text, jump, p2, cHECK, text4);
449 lastTalk.AddChoice(dramaChoice);
450 var (invoke, invokeP) = CustomDramaExpansion.BuildInvokeExpression(item.TryGetValue("param"));
451 if (invoke.Method != null)
452 {
453 dramaChoice.idAction = "";
454 dramaChoice.SetCondition(() => invoke.SafeInvoke(this, item, invokeP));
455 }
456 break;
457 }
458 case "addTempActor":
459 {
460 Person person = new Person(actor);
461 Chara chara = EMono.game.cards.globalCharas.Find(actor) ?? EMono._map.FindChara(actor);
462 if (chara != null)
463 {
464 person.SetChara(chara);
465 }
466 sequence.AddActor(actor, person);
467 break;
468 }
469 case "addActor":
470 {
471 if (actor == "god")
472 {
474 break;
475 }
476 DramaActor dramaActor = sequence.AddActor(actor, new Person(actor));
477 if (!text.IsEmpty())
478 {
479 dramaActor.owner.tempName = text;
480 }
481 break;
482 }
483 case "invoke":
485 {
486 break;
487 }
488 if (jump.IsEmpty())
489 {
490 AddEvent(delegate
491 {
492 typeof(DramaOutcome).GetMethod(p[0]).Invoke(outcome, null);
493 });
494 break;
495 }
496 AddEvent(delegate
497 {
498 }, () => (!(bool)typeof(DramaOutcome).GetMethod(p[0]).Invoke(outcome, null)) ? "" : jump);
499 flag2 = true;
500 break;
501 case "refAction1":
502 AddEvent(delegate
503 {
505 });
506 break;
507 case "refAction2":
508 AddEvent(delegate
509 {
511 });
512 break;
513 case "setBG":
514 AddEvent(delegate
515 {
516 if (p2.IsEmpty())
517 {
518 imageBG.enabled = false;
519 }
520 else
521 {
522 imageBG.enabled = true;
523 imageBG.sprite = Resources.Load<Sprite>("Media/Graphics/Image/Drama/" + p2) ?? ModUtil.LoadSprite(p2);
524 }
525 });
526 break;
527 case "setBG2":
528 AddEvent(delegate
529 {
530 Util.Instantiate<Transform>("Media/Graphics/Image/Drama/" + p2, layer).SetAsFirstSibling();
531 });
532 break;
533 case "setAdvBG":
534 AddEvent(delegate
535 {
536 if (p2.IsEmpty())
537 {
538 dialog.imageBgAdv.enabled = false;
539 }
540 else
541 {
542 dialog.imageBgAdv.enabled = true;
543 dialog.imageBgAdv.sprite = Resources.Load<Sprite>("Media/Graphics/Image/Drama/" + p2) ?? ModUtil.LoadSprite(p2);
544 }
545 });
546 break;
547 case "glitch":
548 AddEvent(delegate
549 {
550 DramaActor.useGlitch = true;
551 });
552 break;
553 case "setDialog":
554 AddEvent(delegate
555 {
556 SetDialog(p2.IsEmpty("Default"));
557 });
558 break;
559 case "Playlist":
560 AddEvent(delegate
561 {
562 LayerDrama.haltPlaylist = false;
563 EMono.Sound.StopBGM();
564 EMono.Sound.currentBGM = null;
565 bgmChanged = true;
566 });
567 break;
568 case "editPlaylist":
569 AddEvent(delegate
570 {
571 List<int> list = new List<int>();
572 string[] array2 = p;
573 foreach (string s in array2)
574 {
575 list.Add(int.Parse(s));
576 }
577 EMono._zone.SetBGM(list);
578 });
579 break;
580 case "BGM":
581 AddEvent(delegate
582 {
583 LayerDrama.haltPlaylist = true;
584 LayerDrama.maxBGMVolume = true;
585 EMono.Sound.PlayBGM(EMono.core.refs.dictBGM[p2.ToInt()]);
586 bgmChanged = true;
587 });
588 break;
589 case "BGMStay":
590 AddEvent(delegate
591 {
592 EMono.Sound.PlayBGM(EMono.core.refs.dictBGM[p2.ToInt()]);
593 });
594 break;
595 case "lastBGM":
596 AddEvent(delegate
597 {
598 EMono.Sound.StopBGM(p0f, playLastBGM: true);
599 });
600 break;
601 case "stopBGM":
602 AddEvent(delegate
603 {
604 LayerDrama.haltPlaylist = true;
605 EMono.Sound.StopBGM(p0f);
606 EMono.Sound.currentBGM = null;
607 });
608 break;
609 case "sound":
610 AddEvent(delegate
611 {
612 if (p3 != "")
613 {
614 SoundManager.current.MuteBGMFor(float.Parse(p3, CultureInfo.InvariantCulture));
615 }
616 lastSound?.Stop();
617 lastSound = EMono.Sound.Play(p2);
618 });
619 break;
620 case "haltPlaylist":
621 LayerDrama.haltPlaylist = true;
622 break;
623 case "keepBGM":
624 LayerDrama.keepBGM = true;
625 break;
626 case "alphaInOut":
627 AddEvent(delegate
628 {
629 DOTween.Kill(cg);
630 cg.alpha = 1f;
631 cg.DOFade(0f, p0f).SetDelay(0.1f);
632 }, p0f, halt: true);
633 AddEvent(new DramaEventWait((result == 0f) ? 0.1f : result));
634 AddEvent(delegate
635 {
636 DOTween.Kill(cg);
637 cg.alpha = 0f;
638 cg.DOFade(1f, p0f).SetDelay(0.1f);
639 }, p0f);
640 break;
641 case "alphaIn":
642 AddEvent(delegate
643 {
644 DOTween.Kill(cg);
645 cg.alpha = 0f;
646 cg.DOFade(1f, p0f).SetDelay(0.1f);
647 }, p0f);
648 break;
649 case "alphaOut":
650 AddEvent(delegate
651 {
652 DOTween.Kill(cg);
653 cg.alpha = 1f;
654 cg.DOFade(0f, p0f).SetDelay(0.1f);
655 }, p0f, halt: true);
656 break;
657 case "fadeIn":
658 AddEvent(delegate
659 {
660 imageCover.color = ((p3 != null && p3 == "white") ? Color.white : Color.black);
661 cgCover.SetActive(enable: true);
662 cgCover.alpha = 1f;
663 cgCover.DOFade(0f, p0f).SetDelay(0.1f);
664 }, p0f);
665 break;
666 case "fadeOut":
667 AddEvent(delegate
668 {
669 imageCover.color = ((p3 != null && p3 == "white") ? Color.white : Color.black);
670 cgCover.SetActive(enable: true);
671 cgCover.alpha = 0f;
672 cgCover.DOFade(1f, p0f).SetDelay(0.1f);
673 }, p0f, halt: true);
674 break;
675 case "fadeInOut":
676 AddEvent(delegate
677 {
678 imageCover.color = ((p4 != null && p4 == "white") ? Color.white : Color.black);
679 cgCover.SetActive(enable: true);
680 cgCover.alpha = 0f;
681 cgCover.DOFade(1f, p0f).SetDelay(0.1f);
682 }, p0f, halt: true);
683 AddEvent(new DramaEventWait((result == 0f) ? 0.1f : result));
684 AddEvent(delegate
685 {
686 imageCover.color = ((p4 != null && p4 == "white") ? Color.white : Color.black);
687 cgCover.SetActive(enable: true);
688 cgCover.alpha = 1f;
689 cgCover.DOFade(0f, p0f).SetDelay(0.1f);
690 }, p0f);
691 break;
692 case "hideUI":
693 AddEvent(delegate
694 {
695 EMono.ui.Hide(p0f);
696 });
697 break;
698 case "hideDialog":
699 AddEvent(delegate
700 {
701 dialog.SetActive(enable: false);
702 });
703 break;
704 case "fadeEnd":
705 if (p0f == 0f)
706 {
707 p0f = 1f;
708 }
709 AddEvent(delegate
710 {
711 imageCover.color = Color.black;
712 cgCover.SetActive(enable: true);
713 cgCover.alpha = 0f;
714 cgCover.DOFade(1f, p0f).SetDelay(0.1f);
715 }, p0f, halt: true);
716 AddEvent(delegate
717 {
718 dialog.SetActive(enable: false);
719 imageBG.enabled = false;
720 });
721 AddEvent(delegate
722 {
723 DOTween.Kill(cg);
724 cg.alpha = 1f;
725 cg.DOFade(0f, p0f).SetDelay(0.1f);
726 }, p0f, halt: true);
727 break;
728 case "endroll":
730 break;
731 case "showSkip":
732 goSkip.SetActive(value: true);
733 break;
734 case "canCancel":
735 AddEvent(delegate
736 {
737 sequence.canCancel = bool.Parse(p2);
738 });
739 break;
740 case "wait":
741 AddEvent(new DramaEventWait(p0f));
742 break;
743 case "end":
745 break;
746 case "modAffinity":
747 AddEvent(delegate
748 {
749 int num = int.Parse(p2);
750 if (EMono.debug.enable)
751 {
752 num *= 10;
753 }
755 });
756 break;
757 case "acceptQuest":
759 {
760 break;
761 }
762 AddEvent(delegate
763 {
764 Quest quest = EMono.game.quests.globalList.Where((Quest a) => a.source.id == p2).First();
765 EMono.game.quests.globalList.Remove(quest);
766 EMono.game.quests.Start(quest);
767 });
768 break;
769 case "startQuest":
770 AddEvent(delegate
771 {
772 Quest quest2 = Quest.Create(p2);
773 if (!quest2.HasDLC)
774 {
775 Msg.Say("(Failed DLC check)");
776 }
777 else
778 {
779 EMono.game.quests.Start(quest2);
780 LayerDrama.currentQuest = quest2;
781 if (tg != null && tg.chara != null)
782 {
783 Debug.Log("Starting Quest:" + quest2?.ToString() + "/" + tg.chara.quest?.ToString() + "/" + (quest2 == tg.chara.quest));
784 }
785 }
786 });
787 break;
788 case "setQuestClient":
789 AddEvent(delegate
790 {
791 if (LayerDrama.currentQuest != null)
792 {
793 LayerDrama.currentQuest.SetClient(tg.chara, assignQuest: false);
794 }
795 });
796 break;
797 case "updateJournal":
798 AddEvent(delegate
799 {
801 });
802 break;
803 case "addKeyItem":
804 if (!LayerDrama.fromBook)
805 {
806 AddEvent(delegate
807 {
808 int num2 = p3.ToInt();
809 EMono.player.ModKeyItem(p2, (num2 == 0) ? 1 : num2);
810 });
811 }
812 break;
813 case "drop":
814 if (!LayerDrama.fromBook)
815 {
816 AddEvent(delegate
817 {
818 Msg.Say("dropReward");
820 Thing t = ThingGen.Create(p2);
822 });
823 }
824 break;
825 case "completeQuest":
826 if (!LayerDrama.fromBook)
827 {
828 AddEvent(delegate
829 {
832 });
833 }
834 break;
835 case "nextPhase":
836 if (!LayerDrama.fromBook)
837 {
838 AddEvent(delegate
839 {
840 EMono.game.quests.Get(p2).NextPhase();
841 });
842 }
843 break;
844 case "changePhase":
845 if (!LayerDrama.fromBook)
846 {
847 AddEvent(delegate
848 {
849 EMono.game.quests.Get(p2).ChangePhase(p3.ToInt());
850 });
851 }
852 break;
853 case "addResource":
854 AddEvent(delegate
855 {
856 EMono.BranchOrHomeBranch.resources.Get(p2).Mod(p3.ToInt());
857 });
858 break;
859 case "getAchievement":
860 AddEvent(delegate
861 {
862 if (new string[2] { "ONEV", "NERUN2" }.Contains(p2))
863 {
864 Steam.GetAchievement(p2.ToEnum<ID_Achievement>());
865 }
866 });
867 break;
868 case "bossText":
869 AddEvent(delegate
870 {
871 foreach (Chara chara3 in EMono._map.charas)
872 {
873 if (chara3.bossText)
874 {
875 chara3.renderer.ShowBossText();
876 }
877 }
878 });
879 break;
880 case "shake":
881 AddEvent(delegate
882 {
884 });
885 break;
886 case "tutorial":
888 {
889 Tutorial.Play(p2);
890 });
891 break;
892 case "slap":
893 AddEvent(delegate
894 {
896 {
898 });
899 });
900 break;
901 case "removeItem":
902 AddEvent(delegate
903 {
904 Thing thing = EMono.pc.things.Find(p2);
905 int num3 = p3.ToInt();
906 thing?.ModNum((num3 == 0) ? (-1) : (-num3));
907 });
908 break;
909 case "destroyItem":
910 AddEvent(delegate
911 {
912 EMono.pc.things.Find(p2).Destroy();
913 });
914 break;
915 case "focus":
916 AddEvent(delegate
917 {
919 EMono.scene.screenElin.focusOption = new BaseGameScreen.FocusOption
920 {
921 pos = pos
922 };
923 });
924 break;
925 case "focusChara":
926 AddEvent(delegate
927 {
928 Point pos2 = EMono._map.FindChara(p2).pos.Copy();
930 {
931 pos = pos2,
932 speed = p3.IsEmpty("2").ToFloat()
933 };
934 });
935 break;
936 case "focusPC":
937 AddEvent(delegate
938 {
939 EMono.scene.screenElin.focusOption = new BaseGameScreen.FocusOption
940 {
941 player = true,
942 speed = p2.IsEmpty("2").ToFloat()
943 };
944 });
945 break;
946 case "focusPos":
947 AddEvent(delegate
948 {
949 EMono.scene.screenElin.focusOption = new BaseGameScreen.FocusOption
950 {
951 pos = new Point(p2.ToInt(), p3.ToInt()),
952 speed = p4.IsEmpty("2").ToFloat()
953 };
954 });
955 break;
956 case "unfocus":
957 AddEvent(delegate
958 {
959 EMono.scene.screenElin.focusOption = null;
960 });
961 break;
962 case "setAlwaysVisible":
963 AddEvent(delegate
964 {
965 LayerDrama.alwaysVisible = EMono._map.FindChara(p2);
966 });
967 break;
968 case "effect":
969 AddEvent(delegate
970 {
971 Point from = new Point(p[1].ToInt(), p[2].ToInt());
972 Effect.Get(p2).Play(from);
973 });
974 break;
975 case "effectEmbarkIn":
976 AddEvent(delegate
977 {
979 Util.Instantiate("UI/Layer/LayerEmbark/EmbarkActor_crystal");
980 });
981 break;
982 case "effectEmbarkOut":
983 AddEvent(delegate
984 {
985 UnityEngine.Object.FindObjectOfType<EmbarkActor>().Hide();
986 });
987 break;
988 case "propEnter":
989 AddEvent(delegate
990 {
991 DramaProp component = Util.Instantiate("Media/Drama/Prop/" + p2).GetComponent<DramaProp>();
992 component.name = p2;
993 if (p3.IsEmpty())
994 {
995 component.transform.position = EMono.scene.cam.transform.position;
996 }
997 else
998 {
999 Point point = new Point(p[1].ToInt(), p[2].ToInt());
1000 component.transform.position = point.PositionCenter();
1001 }
1002 component.Enter();
1003 });
1004 break;
1005 case "propLeave":
1006 AddEvent(delegate
1007 {
1008 GameObject.Find(p2).GetComponent<DramaProp>().Leave();
1009 });
1010 break;
1011 case "destroy":
1012 AddEvent(delegate
1013 {
1014 Chara chara2 = EMono._map.FindChara(p2);
1015 if (chara2 != null)
1016 {
1017 chara2.Destroy();
1018 }
1019 else
1020 {
1021 Debug.Log("Drama.destroy chara not found:" + p2);
1022 }
1023 });
1024 break;
1025 case "bout_win":
1026 case "bout_lose":
1027 AddEvent(delegate
1028 {
1030 {
1032 if (action == "bout_win")
1033 {
1035 {
1036 target = tg.chara
1037 });
1038 }
1039 EMono.pc.MoveZone(zone);
1040 });
1041 });
1042 break;
1043 case "moveZone":
1044 AddEvent(delegate
1045 {
1047 });
1048 break;
1049 case "save":
1050 AddEvent(delegate
1051 {
1052 EMono.game.Save(isAutoSave: false, silent: true);
1053 });
1054 break;
1055 case "setHour":
1056 AddEvent(delegate
1057 {
1058 EMono.world.date.hour = (int)p0f;
1059 EMono.world.date.min = 0;
1063 });
1064 break;
1065 case "%worship":
1066 AddEvent(delegate
1067 {
1069 Tutorial.Reserve("faith");
1070 });
1071 break;
1072 case "replace":
1073 AddEvent(delegate
1074 {
1075 textReplace = text;
1076 });
1077 break;
1078 default:
1079 if (CustomDramaExpansion.ParseAction(action, this, item))
1080 {
1081 return;
1082 }
1083 if (!flag)
1084 {
1085 break;
1086 }
1087 lastTalk = AddEvent(new DramaEventTalk(actor, delegate
1088 {
1089 if (!textReplace.IsEmpty())
1090 {
1091 text = textReplace;
1092 textReplace = null;
1093 }
1094 if (text.StartsWith("#eval"))
1095 {
1096 string script = text[5..].Trim();
1097 if (!EScript.IsScriptingAvailable)
1098 {
1099 return ("[ID '" + id + "'] <scripting is disabled>").TagColor(Color.red);
1100 }
1101 Func<EDramaScriptState, object> func = Scripting.Compile<EDramaScriptState>(script);
1103 {
1104 dm = this,
1105 line = item
1106 };
1107 text = func(arg).TryToString("[ID '" + id + "'] <scripting returns no text>");
1108 }
1109 if (tg != null && (actor == "tg" || actor.IsEmpty()))
1110 {
1111 text = (enableTone ? tg.ApplyTone(text) : text);
1112 }
1113 return text;
1114 })) as DramaEventTalk;
1115 lastTalk.center = p2 == "center";
1116 break;
1117 case "new":
1118 case "saveBGM":
1119 case "checkAffinity":
1120 break;
1121 }
1122 if (!string.IsNullOrEmpty(jump) && !flag2)
1124 AddEvent(new DramaEventGoto(jump));
1125 }
1126 }
1127
1128 public Chara GetChara(string id)
1129 {
1130 return GetPerson(id)?.chara;
1131 }
1132
1133 public Person GetPerson(string id)
1134 {
1135 return GetActor(id)?.owner;
1136 }
1137
1138 public DramaActor GetActor(string id)
1139 {
1140 return sequence.GetActor(id);
1141 }
1142
1144 {
1145 return sequence.AddEvent(e);
1146 }
1147
1148 public DramaEventMethod AddEvent(Action func, float duration = 0f, bool halt = false)
1149 {
1150 return AddEvent(new DramaEventMethod(func, duration, halt)) as DramaEventMethod;
1151 }
1152
1153 public DramaEventMethod AddEvent(Action func, Func<string> funcJump)
1154 {
1155 return AddEvent(new DramaEventMethod(func)
1157 jumpFunc = funcJump
1158 }) as DramaEventMethod;
1159 }
1160
1161 public DramaEvent CustomEvent(Action func, string step = null, float duration = 0f, bool halt = false)
1162 {
1163 DramaEventMethod dramaEventMethod = new DramaEventMethod(func, duration, halt)
1164 {
1165 step = step
1167 customEvents.Add(dramaEventMethod);
1168 return dramaEventMethod;
1169 }
1170
1171 public void SetDialog(string id = "Default")
1172 {
1173 DialogDrama[] componentsInChildren = GetComponentsInChildren<DialogDrama>(includeInactive: true);
1174 foreach (DialogDrama dialogDrama in componentsInChildren)
1175 {
1176 if ((bool)dialogDrama.portrait)
1177 {
1178 dialogDrama.portrait.imageFull.SetActive(enable: false);
1179 }
1180 dialogDrama.SetActive(enable: false);
1181 if (dialogDrama.name == "Dialog" + id)
1182 {
1183 dialog = dialogDrama;
1184 }
1185 }
1186 }
1187
1188 public bool CheckIF(string IF)
1189 {
1190 if (IF == null || IF.IsEmpty())
1191 {
1192 return true;
1193 }
1194 string[] array = IF.Split(',');
1195 switch (array[0])
1196 {
1197 case "garden_bloom":
1198 foreach (Chara member in EMono.pc.party.members)
1199 {
1200 if (member.CanBloom())
1201 {
1202 return true;
1203 }
1204 }
1205 return false;
1206 case "wedding_whoring":
1207 return false;
1208 case "duponne_mino":
1209 return EMono.pc.things.Find("minohorn") != null;
1210 case "duponne_rescued":
1212 {
1213 return EMono._map.FindChara("lurie_boss") != null;
1214 }
1215 return false;
1216 case "duponne_gone":
1218 {
1219 return EMono.pc.things.Find("duponneball") == null;
1220 }
1221 return false;
1222 case "duponne_killed":
1224 {
1226 }
1227 return false;
1228 case "survival":
1229 return EMono.game.IsSurvival;
1230 case "!survival":
1231 return !EMono.game.IsSurvival;
1232 case "fromBook":
1233 return LayerDrama.fromBook;
1234 case "nerun_nadenade":
1235 if (!EMono.game.startVersion.IsBelow(0, 23, 232))
1236 {
1237 return EMono.player.stats.death2 == 0;
1238 }
1239 return false;
1240 case "nerun_nadenade2":
1241 GameLang.refDrama1 = EMono.player.stats.death2.ToString() ?? "";
1242 return EMono.player.stats.death2 >= 100;
1243 case "!fromBook":
1244 return !LayerDrama.fromBook;
1245 case "WindRest":
1246 return EMono._zone is Zone_WindRest;
1247 case "guild_promote":
1248 return Guild.CurrentDrama.relation.exp >= Guild.CurrentDrama.relation.ExpToNext;
1249 case "guild_maxpromote":
1250 return Guild.CurrentDrama.relation.rank >= Guild.CurrentDrama.relation.MaxRank;
1251 case "scratch_check":
1252 return EMono.game.dateScratch > EMono.game.world.date.GetRaw();
1253 case "sister_money":
1254 return EMono.pc.GetCurrency() >= 10000;
1255 case "fiamaPet":
1256 if (EMono.pc.homeBranch != null)
1257 {
1258 foreach (Chara member2 in EMono.pc.homeBranch.members)
1259 {
1260 if (member2.isDead && member2.CanRevive() && member2.GetInt(100) != 0)
1261 {
1262 return true;
1263 }
1264 }
1265 }
1266 return false;
1267 case "hasMelilithCurse":
1268 return EMono.pc.HasElement(1206);
1269 case "merchant":
1270 return Guild.CurrentDrama == Guild.Merchant;
1271 case "fighter":
1272 return Guild.CurrentDrama == Guild.Fighter;
1273 case "thief":
1274 return Guild.CurrentDrama == Guild.Thief;
1275 case "mage":
1276 return Guild.CurrentDrama == Guild.Mage;
1277 case "hasDLC":
1278 return Steam.HasDLC(array[1].ToEnum<ID_DLC>());
1279 case "hasFlag":
1280 return EMono.player.dialogFlags.TryGetValue(array[1], 0) != 0;
1281 case "!hasFlag":
1282 return EMono.player.dialogFlags.TryGetValue(array[1], 0) == 0;
1283 case "!hasMiscreation":
1284 return !EMono.pc.party.HasElement(1248, excludePC: true);
1285 case "hasItem":
1286 return EMono.pc.things.Find(array[1]) != null;
1287 case "nasuDeliver":
1288 if (EMono.game.quests.GetPhase<QuestNasu>() == 2)
1289 {
1290 return EMono.pc.things.Find("backpack_holding") != null;
1291 }
1292 return false;
1293 case "isCompleted":
1294 return EMono.game.quests.IsCompleted(array[1]);
1295 case "costRecruit":
1296 if (EMono.Branch != null && EMono.Branch.IsRecruit(tg.chara))
1297 {
1298 return EMono.pc.GetCurrency("money2") >= CalcGold.Hire(tg.chara);
1299 }
1300 return true;
1301 case "costRecruitTicket":
1302 if (EMono.Branch != null && EMono.Branch.IsRecruit(tg.chara))
1303 {
1304 return EMono.pc.things.Find("ticket_resident") != null;
1305 }
1306 return false;
1307 case "letterTrial":
1309 {
1310 return EMono.pc.things.Find("letter_trial") != null;
1311 }
1312 return false;
1313 default:
1314 if (array.Length > 2)
1315 {
1316 int value;
1317 bool flag = EMono.player.dialogFlags.TryGetValue(array[1], out value);
1318 int num = 0;
1319 if (array[1].StartsWith("*"))
1320 {
1321 string text = array[1].TrimStart('*');
1322 Quest quest = EMono.game.quests.Get(text);
1323 if (text == "guild")
1324 {
1325 quest = Guild.CurrentQuest;
1326 }
1327 flag = quest != null;
1328 if (!EMono.game.quests.completedIDs.Contains(text))
1329 {
1330 value = quest?.phase ?? (-1);
1331 }
1332 else
1333 {
1334 value = 999;
1335 flag = true;
1336 }
1337 num = ((!int.TryParse(array[2], out var result)) ? ((quest != null) ? array[2].ToInt(quest.GetType()) : 0) : result);
1338 }
1339 else
1340 {
1341 num = int.Parse(array[2]);
1342 }
1343 switch (array[0])
1344 {
1345 case "=":
1346 if (!flag && num == -1)
1347 {
1348 return true;
1349 }
1350 if (flag && value == num)
1351 {
1352 return true;
1353 }
1354 break;
1355 case "!":
1356 if (!flag || value != num)
1357 {
1358 return true;
1359 }
1360 break;
1361 case ">":
1362 if (flag && value > num)
1363 {
1364 return true;
1365 }
1366 break;
1367 case ">=":
1368 if (flag && value >= num)
1369 {
1370 return true;
1371 }
1372 break;
1373 case "<":
1374 if (!flag || value < num)
1375 {
1376 return true;
1377 }
1378 break;
1379 case "<=":
1380 if (!flag || value <= num)
1381 {
1382 return true;
1383 }
1384 break;
1385 }
1386 return false;
1388 return setup.tag == IF;
1389 }
1390 }
1391
1392 public void Show()
1393 {
1394 SE.PopDrama();
1395 layer.SetActive(enable: true);
1396 layer.cg.alpha = 0f;
1397 layer.cg.DOFade(1f, 0.3f);
1398 }
1399
1400 public void Hide()
1401 {
1402 layer.SetActive(enable: false);
1403 }
1404}
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:4133
void RecalculateFOV()
Definition: Card.cs:6759
string GetTalkText(string idTopic, bool stripPun=false, bool useDefault=true)
Definition: Card.cs:7248
Point pos
Definition: Card.cs:60
void Destroy()
Definition: Card.cs:5268
ThingContainer things
Definition: Card.cs:39
void ModNum(int a, bool notify=true)
Definition: Card.cs:3673
int GetInt(string id, int? defaultInt=null)
Definition: Card.cs:2551
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6285
Definition: Chara.cs:10
bool CanRevive()
Definition: Chara.cs:5302
void ModAffinity(Chara c, int a, bool show=true, bool showOnlyEmo=false)
Definition: Chara.cs:8236
Party party
Definition: Chara.cs:43
void Slap(Chara c, bool slapToDeath=false)
Definition: Chara.cs:6511
Zone currentZone
Definition: Chara.cs:259
bool CanBloom()
Definition: Chara.cs:9031
FactionBranch homeBranch
Definition: Chara.cs:1089
bool isDead
Definition: Chara.cs:393
void MoveZone(string alias)
Definition: Chara.cs:3451
bool enable
Definition: CoreDebug.cs:301
Dictionary< int, BGMData > dictBGM
Definition: CoreRef.cs:386
CoreRef refs
Definition: Core.cs:51
int GetRaw(int offsetHours=0)
Definition: Date.cs:328
Portrait portrait
Definition: DialogDrama.cs:41
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:1040
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:463
Layer SetOnKill(Action action)
Definition: Layer.cs:579
Chara FindChara(string id)
Definition: Map.cs:2613
List< Chara > charas
Definition: Map.cs:81
void RevealAll(bool reveal=true)
Definition: Map.cs:918
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:198
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:108
Flags flags
Definition: Player.cs:1161
Stats stats
Definition: Player.cs:1083
Dictionary< string, int > dialogFlags
Definition: Player.cs:1107
void ModKeyItem(string alias, int num=1, bool msg=true)
Definition: Player.cs:2208
void MoveZone(Zone z)
Definition: Player.cs:2101
Definition: Point.cs:9
Point Copy()
Definition: Point.cs:491
Image imageFull
Definition: Portrait.cs:30
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:330
GameScreen screenElin
Definition: Scene.cs:93
void OnChangeHour()
Definition: Scene.cs:783
Definition: Shaker.cs:5
static void ShakeCam(string id="default", float magnitude=1f)
Definition: Shaker.cs:25
Zone Find(string id)
Definition: Steam.cs:10
static void GetAchievement(ID_Achievement id)
Definition: Steam.cs:51
static bool HasDLC(ID_DLC id)
Definition: Steam.cs:41
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:40
void SetBGM(List< int > ids, bool refresh=true, float fadeDuration=0f)
Definition: Zone.cs:3094
ZoneInstance instance
Definition: Zone.cs:55
Card AddCard(Card t, Point point)
Definition: Zone.cs:2066
bool IsBelow(int _major, int _minor, int _batch)
Definition: Version.cs:31