2using System.Collections;
3using System.Collections.Generic;
92 return game.activeZone !=
null;
98 public override float uiScale =>
ui.canvasScaler.scaleFactor;
103 Debug.Log(
"Core Awake");
105 QualitySettings.vSyncCount = 0;
106 Application.targetFrameRate = 60;
117 string text =
launchArgs[i].Replace(
"-",
"").ToUpper();
119 Debug.Log(
"Commandline args:" + text);
120 if (text.StartsWith(
"LANG_"))
131 Lang.runUpdate =
true;
134 ModManager.disableMod =
true;
138 NewsList.dict =
null;
139 InvOwner.Trader = (InvOwner.Main =
null);
143 LayerDrama.haltPlaylist =
false;
144 LayerDrama.keepBGM =
false;
145 BaseModManager.isInitialized =
false;
146 Net.isUploading =
false;
147 MapPiece.initialized =
false;
148 ActPlan.warning =
false;
149 Game.isPaused =
false;
160 Canvas.GetDefaultCanvasMaterial().CopyPropertiesFromMaterial(
matUI);
161 Canvas.GetDefaultCanvasMaterial().shader =
matUI.shader;
175 BaseCore.BlockInput = () =>
ui.IsDragging;
176 CommandRegistry.assemblies.Add(typeof(
Core).Assembly);
177 SoundData.EditorPlaySpatial = delegate(SoundData a)
190 Portrait.dictList =
new Dictionary<string, List<ModItem<Sprite>>>();
202 ModManager.disableMod =
true;
222 MOD.actorSources.Initialize();
223 SpriteReplacer.dictSkins.Clear();
224 SpriteReplacer.ListSkins();
232 Component component =
item as Component;
238 GameObject obj = component.gameObject;
239 obj.SendMessage(
"OnStartCore");
240 Component[] componentsInChildren = obj.GetComponentsInChildren<Component>();
241 foreach (Component component2
in componentsInChildren)
243 Debug.Log(component2.GetType().Assembly.GetName().Name);
255 Debug.Log(
"Config doesn't exist.");
260 BookList.dict =
null;
261 BottleMessageList.list =
null;
265 string currentGameLanguage = SteamApps.GetCurrentGameLanguage();
266 if (!(currentGameLanguage ==
"chinese"))
268 if (!(currentGameLanguage ==
"japanese"))
270 BookList.dict =
null;
271 BottleMessageList.list =
null;
282 catch (Exception message)
289 ui.ShowSceneSelector();
305 SoundManager.requestCount = 0;
307 EInput.uiMousePosition = Input.mousePosition /
ui.canvasScaler.scaleFactor;
321 Canvas.GetDefaultCanvasMaterial().CopyPropertiesFromMaterial(
matUI);
324 delta = Time.smoothDeltaTime;
329 EInput.delta = (ButtonState.delta =
delta);
332 int width = Display.main.systemWidth;
333 int height = Display.main.systemHeight;
339 if (Screen.fullScreen)
341 Screen.SetResolution(width, height, fullscreen:
true);
352 if (Screen.width != w || Screen.height != h)
354 Screen.SetResolution(w, h, Screen.fullScreen);
398 UIButton.actionTooltip =
null;
413 Resources.UnloadUnusedAssets();
421 AudioListener.volume = 1f;
425 AudioListener.volume = 0f;
442 WidgetMinimap.Instance.Reload();
446 if (row.replacer.isChecked.GetValueOrDefault(row.idSprite) && row.replacer.data != null)
448 row.replacer.Validate();
453 value.data?.LoadPrefAndFixDensity();
457 foreach (ISyncScreen sync in RenderObject.syncList)
459 if (sync is CardRenderer { hasActor: not false } cardRenderer && !cardRenderer.actor.isPCC)
461 cardRenderer.actor.ReloadSprite();
470 if (IsGameStarted && debug.enable)
472 foreach (PCC.Part value2 in pccs.allParts.Values)
480 for (
int num = 0; num < array.Length; num++)
486 EInput.dragHack = 0f;
494 Widget[] componentsInChildren = ui.widgets.GetComponentsInChildren<
Widget>(includeInactive:
true);
495 foreach (
Widget widget
in componentsInChildren)
497 if (widget.gameObject !=
null)
499 UnityEngine.Object.Destroy(widget.gameObject);
506 Debug.Log(
"Exception:" + ex);
510 if (SteamAPI.IsSteamRunning())
515 catch (Exception ex2)
517 Debug.Log(
"Exception:" + ex2);
524 catch (Exception ex3)
526 Debug.Log(
"Exception:" + ex3);
532 BaseCore.resetRuntime =
false;
533 BiomeProfile.forceInitialize =
true;
534 WidgetHotbar.registering =
false;
535 WidgetHotbar.registeringItem =
null;
536 WordGen.initialized =
false;
537 RecipeManager.rebuild =
true;
538 BookList.dict =
null;
539 BottleMessageList.list =
null;
545 Debug.Log(
"Initializing:" + langCode +
"/" + forceLangCode);
546 StartCoroutine(
"OnEndOfFrame");
547 InvokeRepeating(
"Update100ms", 0.1f, 0.1f);
548 UnityEngine.Object.DestroyImmediate(ui.layoutLang.gameObject);
551 if (config.lang.IsEmpty())
555 SetLang(config.lang);
562 PCCManager.current.Init();
563 SpriteVariationManager.current.Init();
566 textures.RefreshTextures();
568 SoundManager.current.Reset();
569 if (debug.validatePref)
602 Instance = _current ?? UnityEngine.Object.FindObjectOfType<
Core>();
603 BaseCore.Instance = Instance;
613 return Instance ?? SetCurrent();
619 SourceData.dataPath = CorePath.packageCore +
"/Data/Source/";
620 Instance = (EClass.core = (EMono.core =
this));
621 SkinManager._Instance = skins;
622 PathManager.Instance = pathManager;
623 EffectManager.Instance = effects;
629 if (releaseMode != m)
632 debug = Resources.Load<
CoreDebug>(
"_Debug " + releaseMode);
640 yield
return new WaitForEndOfFrame();
641 if ((
bool)screen.guide)
643 screen.guide.OnEndOfFrame();
652 game.updater.Update100ms();
660 config.OnChangeResolution();
662 screen.RefreshScreenSize();
663 lastScreenWidth = Screen.width;
664 lastScreenHeight = Screen.height;
666 for (
int i = 0; i < componentsInChildren.Length; i++)
670 scene.camSupport.OnChangeResolution();
679 ui.FreezeScreen(duration);
689 refs.RebuildBGMList();
692 public override void StopEventSystem(Component c, Action action,
float duration = 0.12f)
694 eventSystem.enabled =
false;
695 c.transform.DOScale(
new Vector3(1f, 0f, 1f), duration).OnKill(delegate
697 eventSystem.enabled =
true;
698 }).OnComplete(delegate
702 .SetEase(Ease.Linear);
707 eventSystem.enabled =
false;
708 TweenUtil.Tween(duration,
null, delegate
710 eventSystem.enabled =
true;
714 public void SetLang(
string langCode,
bool force =
false)
716 if (!(
Lang.
langCode == langCode) || !sources || !sources.langGeneral)
719 AliasGen.list =
null;
721 WordGen.initialized =
false;
722 sources.OnChangeLang();
723 if (game !=
null && !IsGameStarted)
731 sources.ImportSourceTexts();
739 if (
string.IsNullOrEmpty(str))
741 return Array.Empty<
int>();
743 string[] array = str.Replace(
"\n",
"").Split(
',');
744 int[] array2 =
new int[array.Length * 2];
745 for (
int i = 0; i < array.Length; i++)
747 string[] array3 = array[i].Split(
'/');
748 array2[i * 2] = GetElement(array3[0]);
749 array2[i * 2 + 1] = ((!
int.TryParse(array3.TryGet(1, returnNull:
true), out var result)) ? 1 : result);
757 if (sourceElement ==
null)
759 sourceElement = UnityEngine.Object.FindObjectOfType<
SourceManager>().GetComponent<SourceManager>().
elements;
761 if (!sourceElement.initialized)
763 sourceElement.Init();
765 id =
id?.Trim() ??
"_void";
766 if (!sourceElement.alias.TryGetValue(
id, out var value))
768 if (sourceElement.fuzzyAlias.TryGetValue(
id, out var value2))
770 Debug.Log(
"#element lookup: '" +
id +
"' -> '" + value2 +
"'");
771 value = sourceElement.alias[value2];
775 Debug.LogWarning(
"#element not found: '" +
id +
"'");
776 value = sourceElement.rows[0];
784 IUISkin[] componentsInChildren = ui.GetComponentsInChildren<
IUISkin>(includeInactive:
true);
785 for (
int i = 0; i < componentsInChildren.Length; i++)
794 string ie =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
797 FileIniDataParser fileIniDataParser =
new FileIniDataParser();
798 if (!File.Exists(pathIni))
800 File.CreateText(pathIni).Close();
802 IniData iniData = fileIniDataParser.ReadFile(pathIni, Encoding.UTF8);
803 if (iniData.GetKey(
"pass").IsEmpty())
806 for (
int i = 0; i < 4; i++)
808 text += ie.RandomItem();
810 iniData.Global[
"pass"] = text;
811 fileIniDataParser.WriteFile(pathIni, iniData);
815 catch (Exception message)
818 Debug.Log(
"exception: Failed to parse:" + pathIni);
819 IO.DeleteFile(pathIni);
820 File.CreateText(pathIni).Close();
830 public static void TryWarnMod(Action action,
bool warn =
true)
834 IniData ini = GetElinIni();
835 if (ini.Global[
"agreed_usercontens_usage_terms"] !=
"yes")
837 string[] items =
new string[3] {
"readTerms",
"agree",
"disagree" };
838 Dialog.List(
"dialogTermsOfUseUGC".lang(), items, (
string j) => j, delegate(
int c,
string d)
846 ini.Global[
"agreed_usercontens_usage_terms"] =
"yes";
861 IniData ini = GetElinIni();
862 if (ini.Global[
"agreed_usercontents_upload_terms"] !=
"yes")
864 string[] items =
new string[3] {
"readTerms",
"agree",
"disagree" };
865 Dialog.List(
"dialogTermsOfUse".lang(), items, (
string j) => j, delegate(
int c,
string d)
873 ini.Global[
"agreed_usercontents_upload_terms"] =
"yes";
List< Action > actionsNextFrame
List< Action > actionsLateUpdate
static void PublishEvent(string eventId, object data=null)
RenderDataObjDummy rendererObjDummy
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
static HashSet< string > assemblies
static CoreConfig TryLoadConfig()
override void StopEventSystem(float duration=0.2f)
float nextResolutionUpdate
IEnumerator OnEndOfFrame()
override void RebuildBGMList()
static SourceElement sourceElement
void OnApplicationFocus(bool focus)
override void StopEventSystem(Component c, Action action, float duration=0.12f)
static int GetElement(string id)
static void SaveElinIni(IniData ini)
static Core SetCurrent(Core _current=null)
override void ConsumeInput()
static void TryWarnUpload(Action action)
static int[] ParseElements(string str)
static float gameDeltaNoPause
void OnChangeResolution()
void SetReleaseMode(ReleaseMode m)
static IniData GetElinIni()
override void FreezeScreen(float duration=0.2f)
override void UnfreezeScreen()
void SetLang(string langCode, bool force=false)
static void TryWarnMod(Action action, bool warn=true)
static Action< List< string > > onDrop
static void DeleteEmptyGameFolders(string path)
static void Init(string lang)
static void Toggle(string idFile, string idTopic=null)
static List< LayerInventory > listInv
static void ResetResources()
static Action< DirectoryInfo > OnAddPcc
static bool IsInitialized
override void Init(string path, string defaultPackage="_Elona")
IEnumerator RefreshMods(Action onComplete, bool syncMods)
static List< object > ListPluginObject
static readonly SpriteLoadOption loadOption
static readonly SpriteLoadOption loadOptionFull
static List< ISyncScreen > syncList
GameScreenNoMap screenNoMap
static SourcePrefInspector Instance
static Dictionary< string, SpawnList > allList
static Dictionary< string, SpriteData > dict
static Dictionary< string, SpriteReplacer > dictSkins
static void Add(Sprite sprite)
static Dictionary< string, Sprite > dict
static HashSet< string > loadedPath
SteamworksBehaviour steamworks
void OnDropFile(List< string > paths)
static Dictionary< string, SaveData > dictData
void OnChangeResolution()