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 text2 =
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 text =
item.TryGetValue(
"text_JP");
286 bool flag = !text.IsEmpty();
287 string id =
item[
"id"];
291 flag = !text.IsEmpty();
293 if (flag && text.StartsWith(
"$") &&
tg !=
null &&
tg.
hasChara)
295 string text3 = text.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 (!text2.IsEmpty() && !
sequence.
steps.ContainsKey(text2) && 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 quest3 = EMono.game.quests.Get(p2.TrimStart(
'*'));
365 quest3?.ChangePhase(p3.ToInt(quest3.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 text =
"deQuest".lang();
418 text =
"depart".lang();
422 text =
"letsTalk".lang();
426 text =
"daBuy".lang();
430 text =
"daSell".lang();
434 text =
"daGive".lang();
438 text =
"daTrade".lang();
451 if (invoke.Method !=
null)
453 dramaChoice.idAction =
"";
479 dramaActor.owner.tempName = text;
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(quest2);
780 LayerDrama.currentQuest = quest2;
781 if (tg != null && tg.chara != null)
783 Debug.Log(
"Starting Quest:" + quest2?.ToString() +
"/" + tg.chara.quest?.ToString() +
"/" + (quest2 == tg.chara.quest));
788 case "setQuestClient":
793 LayerDrama.currentQuest.SetClient(tg.chara, assignQuest: false);
797 case "updateJournal":
808 int num2 = p3.ToInt();
825 case "completeQuest":
859 case "getAchievement":
862 if (
new string[2] {
"ONEV",
"NERUN2" }.Contains(p2))
875 chara3.renderer.ShowBossText();
905 int num3 = p3.ToInt();
906 thing?.
ModNum((num3 == 0) ? (-1) : (-num3));
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 from =
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;
1094 if (text.StartsWith(
"#eval"))
1096 string script = text[5..].Trim();
1097 if (!EScript.IsScriptingAvailable)
1099 return (
"[ID '" + id +
"'] <scripting is disabled>").TagColor(Color.red);
1107 text = func(arg).TryToString(
"[ID '" +
id +
"'] <scripting returns no text>");
1109 if (
tg !=
null && (actor ==
"tg" || actor.IsEmpty()))
1111 text = (enableTone ? tg.ApplyTone(text) : text);
1115 lastTalk.center = p2 ==
"center";
1119 case "checkAffinity":
1122 if (!
string.IsNullOrEmpty(jump) && !flag2)
1130 return GetPerson(
id)?.chara;
1135 return GetActor(
id)?.owner;
1161 public DramaEvent CustomEvent(Action func,
string step =
null,
float duration = 0f,
bool halt =
false)
1167 customEvents.Add(dramaEventMethod);
1168 return dramaEventMethod;
1171 public void SetDialog(
string id =
"Default")
1173 DialogDrama[] componentsInChildren = GetComponentsInChildren<DialogDrama>(includeInactive:
true);
1174 foreach (
DialogDrama dialogDrama
in componentsInChildren)
1180 dialogDrama.SetActive(enable:
false);
1181 if (dialogDrama.name ==
"Dialog" +
id)
1183 dialog = dialogDrama;
1188 public bool CheckIF(
string IF)
1190 if (IF ==
null || IF.IsEmpty())
1194 string[] array = IF.Split(
',');
1197 case "garden_bloom":
1206 case "wedding_whoring":
1208 case "duponne_mino":
1210 case "duponne_rescued":
1216 case "duponne_gone":
1222 case "duponne_killed":
1234 case "nerun_nadenade":
1237 return EMono.player.stats.death2 == 0;
1240 case "nerun_nadenade2":
1242 return EMono.player.stats.death2 >= 100;
1247 case "guild_promote":
1249 case "guild_maxpromote":
1251 case "scratch_check":
1253 case "sister_money":
1267 case "hasMelilithCurse":
1276 return Guild.CurrentDrama ==
Guild.
Mage;
1283 case "!hasMiscreation":
1301 case "costRecruitTicket":
1314 if (array.Length > 2)
1319 if (array[1].StartsWith(
"*"))
1321 string text = array[1].TrimStart(
'*');
1323 if (text ==
"guild")
1327 flag = quest !=
null;
1330 value = quest?.
phase ?? (-1);
1337 num = ((!
int.TryParse(array[2], out var result)) ? ((quest !=
null) ? array[2].ToInt(quest.GetType()) : 0) : result);
1341 num =
int.Parse(array[2]);
1346 if (!flag && num == -1)
1350 if (flag && value == num)
1356 if (!flag || value != num)
1362 if (flag && value > num)
1368 if (flag && value >= num)
1374 if (!flag || value < num)
1380 if (!flag || value <= num)
1388 return setup.tag == IF;
1395 layer.SetActive(enable:
true);
1396 layer.cg.alpha = 0f;
1397 layer.
cg.DOFade(1f, 0.3f);
1402 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)