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