2using System.Collections.Generic;
3using System.Globalization;
16 public CanvasGroup
cg;
50 public List<DramaChoice>
_choices =
new List<DramaChoice>();
54 public Dictionary<string, string>
dictLocalize =
new Dictionary<string, string>();
81 public static Dictionary<string, ExcelData>
dictCache =
new Dictionary<string, ExcelData>(PathComparer.Default);
98 ModUtil.LogModError(
"error during drama play\n" + ex.GetType().Name +
": " + ex.Message,
new FileInfo(
path));
99 Debug.LogException(ex);
106 cgCover.SetActive(enable:
false);
107 endroll.SetActive(enable:
false);
117 sequence.lastStep = (sequence.lastlastStep =
setup.
step);
140 string text = PackageIterator.GetFiles(
"Dialog/Drama/" +
setup.
book +
".xlsx").LastOrDefault()?.FullName;
142 if (excelData !=
null && excelData.
IsModified())
146 if (excelData ==
null)
150 excelData.maxEmptyRows = 10;
151 path = (excelData.path = text ?? (CorePath.DramaData + setup.book +
".xlsx"));
154 string key = text ?? (CorePath.DramaDataLocal + setup.book +
".xlsx");
155 if (!File.Exists(key))
157 key = excelData.
path;
160 if (excelData2 != excelData)
162 if (excelData2 !=
null && excelData2.
IsModified())
166 if (excelData2 ==
null)
170 excelData2.maxEmptyRows = 10;
171 excelData2.path = key;
175 string[] array =
new string[3]
181 foreach (Dictionary<string, string>
item in excelData2.BuildList(
setup.
sheet))
183 string text2 =
item[
"id"];
189 string[] array2 = array;
190 foreach (
string key2
in array2)
192 if (
item.TryGetValue(key2, out value) && !value.IsEmpty())
199 value =
"[ID '" + text2 +
"'] <empty text>";
204 dictLocalize[text2] = (
"[DUPLICATE ID '" + text2 +
"']\n").TagColor(
Color.red) + text3;
205 Debug.LogWarning(
"#drama duplicate id '" + text2 +
"' at " +
path +
"\n" + text3 +
" -> " + value);
212 for (
int j = 0; j < list.Count; j++)
218 catch (Exception exception)
220 Debug.LogException(exception);
267 string text =
item.TryGetValue(
"step");
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"];
291 flag = !text2.IsEmpty();
293 if (flag && text2.StartsWith(
"$") &&
tg !=
null &&
tg.
hasChara)
295 string text3 = text2.Split(
' ')[0];
298 string jump =
item.TryGetValue(
"jump");
299 string text4 =
item.TryGetValue(
"if");
300 string iF =
item.TryGetValue(
"if2");
301 string cHECK =
item.TryGetValue(
"check");
303 if (!text.IsEmpty() && !
sequence.
steps.ContainsKey(text) && action !=
"choice" && action !=
"cancel")
319 if (action ==
"reload")
332 case "enableFullPortrait":
333 case "disableFullPortrait":
336 bool flag3 = action ==
"enableFullPortrait";
339 sequence.fullPortrait = flag3;
350 sequence.skipJump = p2;
357 EMono.Sound.haltUpdate =
true;
362 SoundManager.ForceBGM();
368 if (p2.StartsWith(
"*"))
370 Quest quest = EMono.game.quests.Get(p2.TrimStart(
'*'));
371 quest?.ChangePhase(p3.ToInt(quest.GetType()));
375 EMono.player.dialogFlags[p2] = (p3.IsEmpty() ? 1 : int.Parse(p3));
386 }, 0.01f, halt:
true);
404 lastTalk.canCancel =
true;
405 lastTalk.idCancelJump = jump;
415 if (array.Length > 1)
420 text2 =
"deQuest".lang();
424 text2 =
"depart".lang();
428 text2 =
"letsTalk".lang();
432 text2 =
"daBuy".lang();
436 text2 =
"daSell".lang();
440 text2 =
"daGive".lang();
444 text2 =
"daTrade".lang();
448 text2 =
"bye".lang();
457 if (invoke.Method !=
null)
459 dramaChoice.idAction =
"";
483 if (!text2.IsEmpty())
485 dramaActor.owner.tempName = text2;
524 imageBG.enabled = false;
528 imageBG.enabled = true;
529 imageBG.sprite = Resources.Load<Sprite>(
"Media/Graphics/Image/Drama/" + p2) ?? ModUtil.LoadSprite(p2);
536 Util.Instantiate<Transform>(
"Media/Graphics/Image/Drama/" + p2,
layer).SetAsFirstSibling();
544 dialog.imageBgAdv.enabled = false;
548 dialog.imageBgAdv.enabled = true;
549 dialog.imageBgAdv.sprite = Resources.Load<Sprite>(
"Media/Graphics/Image/Drama/" + p2) ?? ModUtil.LoadSprite(p2);
556 DramaActor.useGlitch =
true;
568 LayerDrama.haltPlaylist =
false;
570 EMono.Sound.currentBGM =
null;
577 List<int> list =
new List<int>();
579 foreach (
string s
in array2)
581 list.Add(
int.Parse(s));
589 LayerDrama.haltPlaylist =
true;
590 LayerDrama.maxBGMVolume =
true;
610 LayerDrama.haltPlaylist =
true;
612 EMono.Sound.currentBGM =
null;
620 SoundManager.current.MuteBGMFor(
float.Parse(p3, CultureInfo.InvariantCulture));
627 LayerDrama.haltPlaylist =
true;
630 LayerDrama.keepBGM =
true;
637 cg.DOFade(0f, p0f).SetDelay(0.1f);
644 cg.DOFade(1f, p0f).SetDelay(0.1f);
652 cg.DOFade(1f, p0f).SetDelay(0.1f);
660 cg.DOFade(0f, p0f).SetDelay(0.1f);
666 imageCover.color = ((p3 !=
null && p3 ==
"white") ?
Color.white :
Color.black);
667 cgCover.SetActive(enable:
true);
669 cgCover.DOFade(0f, p0f).SetDelay(0.1f);
675 imageCover.color = ((p3 !=
null && p3 ==
"white") ?
Color.white :
Color.black);
676 cgCover.SetActive(enable:
true);
678 cgCover.DOFade(1f, p0f).SetDelay(0.1f);
684 imageCover.color = ((p4 !=
null && p4 ==
"white") ?
Color.white :
Color.black);
685 cgCover.SetActive(enable:
true);
687 cgCover.DOFade(1f, p0f).SetDelay(0.1f);
692 imageCover.color = ((p4 !=
null && p4 ==
"white") ?
Color.white :
Color.black);
693 cgCover.SetActive(enable:
true);
695 cgCover.DOFade(0f, p0f).SetDelay(0.1f);
707 dialog.SetActive(enable:
false);
717 imageCover.color =
Color.black;
718 cgCover.SetActive(enable:
true);
720 cgCover.DOFade(1f, p0f).SetDelay(0.1f);
724 dialog.SetActive(enable:
false);
725 imageBG.enabled =
false;
731 cg.DOFade(0f, p0f).SetDelay(0.1f);
738 goSkip.SetActive(value:
true);
743 sequence.canCancel =
bool.Parse(p2);
755 int num =
int.Parse(p2);
781 Msg.Say(
"(Failed DLC check)");
785 EMono.game.quests.Start(quest);
786 LayerDrama.currentQuest = quest;
787 if (tg != null && tg.chara != null)
789 Debug.Log(
"Starting Quest:" + quest?.ToString() +
"/" + tg.chara.quest?.ToString() +
"/" + (quest == tg.chara.quest));
794 case "setQuestClient":
799 LayerDrama.currentQuest.SetClient(tg.chara, assignQuest: false);
803 case "updateJournal":
814 int num = p3.ToInt();
831 case "completeQuest":
865 case "getAchievement":
868 if (
new string[2] {
"ONEV",
"NERUN2" }.Contains(p2))
881 chara3.renderer.ShowBossText();
911 int num = p3.ToInt();
912 thing?.
ModNum((num == 0) ? (-1) : (-num));
938 speed = p3.IsEmpty(
"2").ToFloat()
948 speed = p2.IsEmpty(
"2").ToFloat()
957 pos =
new Point(p2.ToInt(), p3.ToInt()),
958 speed = p4.IsEmpty(
"2").ToFloat()
965 EMono.scene.screenElin.focusOption =
null;
968 case "setAlwaysVisible":
977 Point point =
new Point(p[1].ToInt(), p[2].ToInt());
981 case "effectEmbarkIn":
988 case "effectEmbarkOut":
1001 component.transform.position = EMono.scene.cam.transform.position;
1005 Point point = new Point(p[1].ToInt(), p[2].ToInt());
1006 component.transform.position = point.PositionCenter();
1014 GameObject.Find(p2).GetComponent<DramaProp>().Leave();
1027 Debug.Log(
"Drama.destroy chara not found:" + p2);
1038 if (action ==
"bout_win")
1064 EMono.world.date.hour = (int)p0f;
1065 EMono.world.date.min = 0;
1097 text2 = textReplace;
1100 if (text2.StartsWith(
"#eval"))
1102 string script = text2[5..].Trim();
1103 if (!EScript.IsScriptingAvailable)
1105 return (
"[ID '" + id +
"'] <scripting is disabled>").TagColor(Color.red);
1113 text2 = func(arg).TryToString(
"[ID '" +
id +
"'] <scripting returns no text>");
1115 if (
tg !=
null && (actor ==
"tg" || actor.IsEmpty()))
1117 text2 = (enableTone ? tg.ApplyTone(text2) : text2);
1121 lastTalk.ignoreClickSound = action ==
"ignoreClickSound";
1122 lastTalk.center = p2 ==
"center";
1126 case "checkAffinity":
1129 if (!
string.IsNullOrEmpty(jump) && !flag2)
1137 return GetPerson(
id)?.chara;
1142 return GetActor(
id)?.owner;
1168 public DramaEvent CustomEvent(Action func,
string step =
null,
float duration = 0f,
bool halt =
false)
1174 customEvents.Add(dramaEventMethod);
1175 return dramaEventMethod;
1178 public void SetDialog(
string id =
"Default")
1180 if (
id ==
"Default")
1183 if (dramaSequence !=
null && dramaSequence.
fullPortrait)
1188 DialogDrama[] componentsInChildren = GetComponentsInChildren<DialogDrama>(includeInactive:
true);
1189 foreach (
DialogDrama dialogDrama
in componentsInChildren)
1191 dialogDrama.SetActive(enable:
false);
1192 if (dialogDrama.name ==
"Dialog" +
id)
1194 dialog = dialogDrama;
1199 public bool CheckIF(
string IF)
1201 if (IF ==
null || IF.IsEmpty())
1205 string[] array = IF.Split(
',');
1208 case "garden_bloom":
1217 case "wedding_whoring":
1219 case "duponne_mino":
1221 case "duponne_rescued":
1227 case "duponne_gone":
1233 case "duponne_killed":
1245 case "nerun_nadenade":
1248 return EMono.player.stats.death2 == 0;
1251 case "nerun_nadenade2":
1253 return EMono.player.stats.death2 >= 100;
1258 case "guild_promote":
1260 case "guild_maxpromote":
1262 case "scratch_check":
1264 case "sister_money":
1278 case "hasMelilithCurse":
1287 return Guild.CurrentDrama ==
Guild.
Mage;
1294 case "!hasMiscreation":
1312 case "costRecruitTicket":
1325 if (array.Length > 2)
1330 if (array[1].StartsWith(
"*"))
1332 string text = array[1].TrimStart(
'*');
1334 if (text ==
"guild")
1338 flag = quest !=
null;
1341 value = quest?.
phase ?? (-1);
1348 num = ((!
int.TryParse(array[2], out var result)) ? ((quest !=
null) ? array[2].ToInt(quest.GetType()) : 0) : result);
1352 num =
int.Parse(array[2]);
1357 if (!flag && num == -1)
1361 if (flag && value == num)
1367 if (!flag || value != num)
1373 if (flag && value > num)
1379 if (flag && value >= num)
1385 if (!flag || value < num)
1391 if (!flag || value <= num)
1399 return setup.tag == IF;
1406 layer.SetActive(enable:
true);
1407 layer.cg.alpha = 0f;
1408 layer.
cg.DOFade(1f, 0.3f);
1413 layer.SetActive(enable:
false);
static void SetNormalRarity(bool fixedMat=false)
GlobalCharaList globalCharas
int GetCurrency(string id="money")
string GetTalkText(string idTopic, bool stripPun=false, bool useDefault=true)
void ModNum(int a, bool notify=true)
int GetInt(string id, int? defaultInt=null)
bool HasElement(int ele, bool includeNagative=false)
void ModAffinity(Chara c, int a, bool show=true, bool showOnlyEmo=false)
void Slap(Chara c, bool slapToDeath=false)
void MoveZone(string alias)
Dictionary< int, BGMData > dictBGM
int GetRaw(int offsetHours=0)
DramaChoice SetCondition(Func< bool > condition)
void AddChoice(DramaChoice choice)
Dictionary< string, string > dictLocalize
DramaEventMethod AddEvent(Action func, float duration=0f, bool halt=false)
DramaEvent CustomEvent(Action func, string step=null, float duration=0f, bool halt=false)
static Dictionary< string, ExcelData > dictCache
void ParseLine(Dictionary< string, string > item)
void AddCustomEvents(string idCustom="Resident")
DramaEventMethod AddEvent(Action func, Func< string > funcJump)
void SetDialog(string id="Default")
List< DramaChoice > _choices
Dictionary< string, string > customTalkTopics
EScriptSubmission Scripting
List< DramaEvent > customEvents
DramaSequence Play(DramaSetup setup)
DramaEvent AddEvent(DramaEvent e)
List< DramaEvent > events
DramaActor AddActor(string id, Person person)
DramaActor GetActor(string id)
DramaEvent AddEvent(DramaEvent e)
Dictionary< string, int > steps
static FactionBranch BranchOrHomeBranch
static SoundManager Sound
static FactionBranch Branch
static Effect Get(Effect original)
void Play(float delay, Point from, float fixY=0f, Point to=null, Sprite sprite=null)
List< Dictionary< string, string > > BuildList(string sheetName="_default")
HomeResourceManager resources
bool Save(bool isAutoSave=false, bool silent=false)
static Guild CurrentDrama
static GuildMerchant Merchant
static QuestGuild CurrentQuest
static GuildFighter Fighter
BaseHomeResource Get(string id)
static LayerDrama Instance
static Quest currentQuest
static Religion currentReligion
void ShowScreenLock(string id)
Layer SetOnKill(Action action)
Chara FindChara(string id)
void RevealAll(bool reveal=true)
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
bool HasElement(int ele, bool excludePC=false)
Dictionary< string, int > dialogFlags
void ModKeyItem(string alias, int num=1, bool msg=true)
HashSet< string > completedIDs
bool IsCompleted(string id)
Quest Start(string id, string idGlobalChara)
static Quest Create(string _id, string _idPerson=null, Chara c=null, bool assignQuest=true)
virtual SourceQuest.Row source
virtual void JoinFaith(Chara c, ConvertType type=ConvertType.Default)
static void ShakeCam(string id="default", float magnitude=1f)
static void GetAchievement(ID_Achievement id)
static bool HasDLC(ID_DLC id)
static Thing Create(string id, int idMat=-1, int lv=-1)
static void Reserve(string idStep, Action onBeforePlay=null)
static void Play(string idStep)
static Transform Instantiate(string path, Component parent=null)
void AddPreEnter(ZonePreEnterEvent e, bool executeIfActiveZone=true)
void SetBGM(List< int > ids, bool refresh=true, float fadeDuration=0f)
Card AddCard(Card t, Point point)
bool IsBelow(int _major, int _minor, int _batch)