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 "disableFullPortrait":
335 sequence.fullPortrait =
false;
344 sequence.skipJump = p2;
351 EMono.Sound.haltUpdate =
true;
356 SoundManager.ForceBGM();
362 if (p2.StartsWith(
"*"))
364 Quest quest = EMono.game.quests.Get(p2.TrimStart(
'*'));
365 quest?.ChangePhase(p3.ToInt(quest.GetType()));
369 EMono.player.dialogFlags[p2] = (p3.IsEmpty() ? 1 : int.Parse(p3));
380 }, 0.01f, halt:
true);
398 lastTalk.canCancel =
true;
399 lastTalk.idCancelJump = jump;
409 if (array.Length > 1)
414 text2 =
"deQuest".lang();
418 text2 =
"depart".lang();
422 text2 =
"letsTalk".lang();
426 text2 =
"daBuy".lang();
430 text2 =
"daSell".lang();
434 text2 =
"daGive".lang();
438 text2 =
"daTrade".lang();
442 text2 =
"bye".lang();
451 if (invoke.Method !=
null)
453 dramaChoice.idAction =
"";
477 if (!text2.IsEmpty())
479 dramaActor.owner.tempName = text2;
518 imageBG.enabled = false;
522 imageBG.enabled = true;
523 imageBG.sprite = Resources.Load<Sprite>(
"Media/Graphics/Image/Drama/" + p2) ?? ModUtil.LoadSprite(p2);
530 Util.Instantiate<Transform>(
"Media/Graphics/Image/Drama/" + p2,
layer).SetAsFirstSibling();
538 dialog.imageBgAdv.enabled = false;
542 dialog.imageBgAdv.enabled = true;
543 dialog.imageBgAdv.sprite = Resources.Load<Sprite>(
"Media/Graphics/Image/Drama/" + p2) ?? ModUtil.LoadSprite(p2);
550 DramaActor.useGlitch =
true;
562 LayerDrama.haltPlaylist =
false;
564 EMono.Sound.currentBGM =
null;
571 List<int> list =
new List<int>();
573 foreach (
string s
in array2)
575 list.Add(
int.Parse(s));
583 LayerDrama.haltPlaylist =
true;
584 LayerDrama.maxBGMVolume =
true;
604 LayerDrama.haltPlaylist =
true;
606 EMono.Sound.currentBGM =
null;
614 SoundManager.current.MuteBGMFor(
float.Parse(p3, CultureInfo.InvariantCulture));
621 LayerDrama.haltPlaylist =
true;
624 LayerDrama.keepBGM =
true;
631 cg.DOFade(0f, p0f).SetDelay(0.1f);
638 cg.DOFade(1f, p0f).SetDelay(0.1f);
646 cg.DOFade(1f, p0f).SetDelay(0.1f);
654 cg.DOFade(0f, p0f).SetDelay(0.1f);
660 imageCover.color = ((p3 !=
null && p3 ==
"white") ?
Color.white :
Color.black);
661 cgCover.SetActive(enable:
true);
663 cgCover.DOFade(0f, p0f).SetDelay(0.1f);
669 imageCover.color = ((p3 !=
null && p3 ==
"white") ?
Color.white :
Color.black);
670 cgCover.SetActive(enable:
true);
672 cgCover.DOFade(1f, p0f).SetDelay(0.1f);
678 imageCover.color = ((p4 !=
null && p4 ==
"white") ?
Color.white :
Color.black);
679 cgCover.SetActive(enable:
true);
681 cgCover.DOFade(1f, p0f).SetDelay(0.1f);
686 imageCover.color = ((p4 !=
null && p4 ==
"white") ?
Color.white :
Color.black);
687 cgCover.SetActive(enable:
true);
689 cgCover.DOFade(0f, p0f).SetDelay(0.1f);
701 dialog.SetActive(enable:
false);
711 imageCover.color =
Color.black;
712 cgCover.SetActive(enable:
true);
714 cgCover.DOFade(1f, p0f).SetDelay(0.1f);
718 dialog.SetActive(enable:
false);
719 imageBG.enabled =
false;
725 cg.DOFade(0f, p0f).SetDelay(0.1f);
732 goSkip.SetActive(value:
true);
737 sequence.canCancel =
bool.Parse(p2);
749 int num =
int.Parse(p2);
775 Msg.Say(
"(Failed DLC check)");
779 EMono.game.quests.Start(quest);
780 LayerDrama.currentQuest = quest;
781 if (tg != null && tg.chara != null)
783 Debug.Log(
"Starting Quest:" + quest?.ToString() +
"/" + tg.chara.quest?.ToString() +
"/" + (quest == tg.chara.quest));
788 case "setQuestClient":
793 LayerDrama.currentQuest.SetClient(tg.chara, assignQuest: false);
797 case "updateJournal":
808 int num = p3.ToInt();
825 case "completeQuest":
859 case "getAchievement":
862 if (
new string[2] {
"ONEV",
"NERUN2" }.Contains(p2))
875 chara3.renderer.ShowBossText();
905 int num = p3.ToInt();
906 thing?.
ModNum((num == 0) ? (-1) : (-num));
932 speed = p3.IsEmpty(
"2").ToFloat()
942 speed = p2.IsEmpty(
"2").ToFloat()
951 pos =
new Point(p2.ToInt(), p3.ToInt()),
952 speed = p4.IsEmpty(
"2").ToFloat()
959 EMono.scene.screenElin.focusOption =
null;
962 case "setAlwaysVisible":
971 Point point =
new Point(p[1].ToInt(), p[2].ToInt());
975 case "effectEmbarkIn":
982 case "effectEmbarkOut":
995 component.transform.position = EMono.scene.cam.transform.position;
999 Point point = new Point(p[1].ToInt(), p[2].ToInt());
1000 component.transform.position = point.PositionCenter();
1008 GameObject.Find(p2).GetComponent<DramaProp>().Leave();
1021 Debug.Log(
"Drama.destroy chara not found:" + p2);
1032 if (action ==
"bout_win")
1058 EMono.world.date.hour = (int)p0f;
1059 EMono.world.date.min = 0;
1091 text2 = textReplace;
1094 if (text2.StartsWith(
"#eval"))
1096 string script = text2[5..].Trim();
1097 if (!EScript.IsScriptingAvailable)
1099 return (
"[ID '" + id +
"'] <scripting is disabled>").TagColor(Color.red);
1107 text2 = func(arg).TryToString(
"[ID '" +
id +
"'] <scripting returns no text>");
1109 if (
tg !=
null && (actor ==
"tg" || actor.IsEmpty()))
1111 text2 = (enableTone ? tg.ApplyTone(text2) : text2);
1115 lastTalk.ignoreClickSound = action ==
"ignoreClickSound";
1116 lastTalk.center = p2 ==
"center";
1120 case "checkAffinity":
1123 if (!
string.IsNullOrEmpty(jump) && !flag2)
1131 return GetPerson(
id)?.chara;
1136 return GetActor(
id)?.owner;
1162 public DramaEvent CustomEvent(Action func,
string step =
null,
float duration = 0f,
bool halt =
false)
1168 customEvents.Add(dramaEventMethod);
1169 return dramaEventMethod;
1172 public void SetDialog(
string id =
"Default")
1174 DialogDrama[] componentsInChildren = GetComponentsInChildren<DialogDrama>(includeInactive:
true);
1175 foreach (
DialogDrama dialogDrama
in componentsInChildren)
1181 dialogDrama.SetActive(enable:
false);
1182 if (dialogDrama.name ==
"Dialog" +
id)
1184 dialog = dialogDrama;
1189 public bool CheckIF(
string IF)
1191 if (IF ==
null || IF.IsEmpty())
1195 string[] array = IF.Split(
',');
1198 case "garden_bloom":
1207 case "wedding_whoring":
1209 case "duponne_mino":
1211 case "duponne_rescued":
1217 case "duponne_gone":
1223 case "duponne_killed":
1235 case "nerun_nadenade":
1238 return EMono.player.stats.death2 == 0;
1241 case "nerun_nadenade2":
1243 return EMono.player.stats.death2 >= 100;
1248 case "guild_promote":
1250 case "guild_maxpromote":
1252 case "scratch_check":
1254 case "sister_money":
1268 case "hasMelilithCurse":
1277 return Guild.CurrentDrama ==
Guild.
Mage;
1284 case "!hasMiscreation":
1302 case "costRecruitTicket":
1315 if (array.Length > 2)
1320 if (array[1].StartsWith(
"*"))
1322 string text = array[1].TrimStart(
'*');
1324 if (text ==
"guild")
1328 flag = quest !=
null;
1331 value = quest?.
phase ?? (-1);
1338 num = ((!
int.TryParse(array[2], out var result)) ? ((quest !=
null) ? array[2].ToInt(quest.GetType()) : 0) : result);
1342 num =
int.Parse(array[2]);
1347 if (!flag && num == -1)
1351 if (flag && value == num)
1357 if (!flag || value != num)
1363 if (flag && value > num)
1369 if (flag && value >= num)
1375 if (!flag || value < num)
1381 if (!flag || value <= num)
1389 return setup.tag == IF;
1396 layer.SetActive(enable:
true);
1397 layer.cg.alpha = 0f;
1398 layer.
cg.DOFade(1f, 0.3f);
1403 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)