2using System.Collections;
3using System.Collections.Generic;
89 return game.activeZone !=
null;
95 public override float uiScale =>
ui.canvasScaler.scaleFactor;
100 Debug.Log(
"Core Awake");
102 QualitySettings.vSyncCount = 0;
103 Application.targetFrameRate = 60;
111 string[] array = (Application.isEditor ?
debug.
command.Split(
',') : Environment.GetCommandLineArgs());
112 for (
int i = 0; i < array.Length; i++)
114 string text = array[i];
115 text = text.Replace(
"-",
"").ToUpper();
116 Debug.Log(
"Commandline args:" + text);
117 if (text.StartsWith(
"LANG_"))
128 Lang.runUpdate =
true;
131 ModManager.disableMod =
true;
135 NewsList.dict =
null;
136 InvOwner.Trader = (InvOwner.Main =
null);
140 LayerDrama.haltPlaylist =
false;
141 LayerDrama.keepBGM =
false;
142 BaseModManager.isInitialized =
false;
143 Net.isUploading =
false;
144 MapPiece.initialized =
false;
145 ActPlan.warning =
false;
146 Game.isPaused =
false;
157 Canvas.GetDefaultCanvasMaterial().CopyPropertiesFromMaterial(
matUI);
158 Canvas.GetDefaultCanvasMaterial().shader =
matUI.shader;
172 BaseCore.BlockInput = () =>
ui.IsDragging;
173 CommandRegistry.assemblies.Add(typeof(
Core).Assembly);
174 SoundData.EditorPlaySpatial = delegate(SoundData a)
181 MOD.OnAddPcc =
pccs.Add;
191 Portrait.dictList =
new Dictionary<string, List<ModItem<Sprite>>>();
203 ModManager.disableMod =
true;
223 MOD.actorSources.Initialize();
224 SpriteReplacer.dictSkins.Clear();
225 SpriteReplacer.ListSkins();
233 Component component =
item as Component;
239 GameObject obj = component.gameObject;
240 obj.SendMessage(
"OnStartCore");
241 Component[] componentsInChildren = obj.GetComponentsInChildren<Component>();
242 foreach (Component component2
in componentsInChildren)
244 Debug.Log(component2.GetType().Assembly.GetName().Name);
256 Debug.Log(
"Config doesn't exist.");
261 BookList.dict =
null;
265 string currentGameLanguage = SteamApps.GetCurrentGameLanguage();
266 if (!(currentGameLanguage ==
"chinese"))
268 if (!(currentGameLanguage ==
"japanese"))
270 BookList.dict =
null;
281 catch (Exception message)
288 ui.ShowSceneSelector();
304 SoundManager.requestCount = 0;
306 EInput.uiMousePosition = Input.mousePosition /
ui.canvasScaler.scaleFactor;
320 Canvas.GetDefaultCanvasMaterial().CopyPropertiesFromMaterial(
matUI);
323 delta = Time.smoothDeltaTime;
328 EInput.delta = (ButtonState.delta =
delta);
331 int width = Display.main.systemWidth;
332 int height = Display.main.systemHeight;
338 if (Screen.fullScreen)
340 Screen.SetResolution(width, height, fullscreen:
true);
351 if (Screen.width != w || Screen.height != h)
353 Screen.SetResolution(w, h, Screen.fullScreen);
396 UIButton.actionTooltip =
null;
411 Resources.UnloadUnusedAssets();
419 AudioListener.volume = 1f;
423 AudioListener.volume = 0f;
440 WidgetMinimap.Instance.Reload();
444 if (row.replacer.hasChacked && row.replacer.data != null)
446 row.replacer.data.GetSprite();
455 foreach (PCC.Part value in
pccs.allParts.Values)
463 for (
int i = 0; i < array.Length; i++)
469 EInput.dragHack = 0f;
477 Widget[] componentsInChildren = ui.widgets.GetComponentsInChildren<
Widget>(includeInactive:
true);
478 foreach (
Widget widget
in componentsInChildren)
480 if (widget.gameObject !=
null)
482 UnityEngine.Object.Destroy(widget.gameObject);
489 Debug.Log(
"Exception:" + ex);
493 if (SteamAPI.IsSteamRunning())
498 catch (Exception ex2)
500 Debug.Log(
"Exception:" + ex2);
507 catch (Exception ex3)
509 Debug.Log(
"Exception:" + ex3);
515 BaseCore.resetRuntime =
false;
516 BiomeProfile.forceInitialize =
true;
517 WidgetHotbar.registering =
false;
518 WidgetHotbar.registeringItem =
null;
519 WordGen.initialized =
false;
520 RecipeManager.rebuild =
true;
521 BookList.dict =
null;
527 Debug.Log(
"Initializing:" + langCode +
"/" + forceLangCode);
528 StartCoroutine(
"OnEndOfFrame");
529 InvokeRepeating(
"Update100ms", 0.1f, 0.1f);
530 UnityEngine.Object.DestroyImmediate(ui.layoutLang.gameObject);
532 if (config.
lang.IsEmpty())
536 SetLang(config.
lang);
548 PCCManager.current.Init();
549 SpriteVariationManager.current.Init();
553 SoundManager.current.Reset();
587 Instance = _current ?? UnityEngine.Object.FindObjectOfType<
Core>();
588 BaseCore.Instance = Instance;
598 return Instance ?? SetCurrent();
604 SourceData.dataPath = CorePath.packageCore +
"/Data/Source/";
605 Instance = (EClass.core = (EMono.core =
this));
606 SkinManager._Instance = skins;
607 PathManager.Instance = pathManager;
608 EffectManager.Instance = effects;
614 if (releaseMode != m)
617 debug = Resources.Load<
CoreDebug>(
"_Debug " + releaseMode);
625 yield
return new WaitForEndOfFrame();
626 if ((
bool)screen.
guide)
648 lastScreenWidth = Screen.width;
649 lastScreenHeight = Screen.height;
651 for (
int i = 0; i < componentsInChildren.Length; i++)
664 ui.FreezeScreen(duration);
677 public override void StopEventSystem(Component c, Action action,
float duration = 0.12f)
679 eventSystem.enabled =
false;
680 c.transform.DOScale(
new Vector3(1f, 0f, 1f), duration).OnKill(delegate
682 eventSystem.enabled =
true;
683 }).OnComplete(delegate
687 .SetEase(Ease.Linear);
692 eventSystem.enabled =
false;
693 TweenUtil.Tween(duration,
null, delegate
695 eventSystem.enabled =
true;
699 public void SetLang(
string langCode,
bool force =
false)
704 AliasGen.list =
null;
706 WordGen.initialized =
false;
708 if (game !=
null && !IsGameStarted)
718 if (
string.IsNullOrEmpty(str))
722 string[] array = str.Replace(
"\n",
"").Split(
',');
723 int[] array2 =
new int[array.Length * 2];
724 for (
int i = 0; i < array.Length; i++)
726 string[] array3 = array[i].Split(
'/');
727 array2[i * 2] = GetElement(array3[0]);
728 array2[i * 2 + 1] = ((array3.Length == 1) ? 1 :
int.Parse(array3[1]));
736 if (sourceElement ==
null)
738 sourceElement = UnityEngine.Object.FindObjectOfType<
SourceManager>().GetComponent<SourceManager>().
elements;
740 if (!sourceElement.initialized)
742 sourceElement.Init();
744 if (!sourceElement.alias.TryGetValue(
id ??
"_void", out var value))
746 Debug.LogError(
"exception:" +
id);
747 value = sourceElement.rows[0];
754 IUISkin[] componentsInChildren = ui.GetComponentsInChildren<
IUISkin>(includeInactive:
true);
755 for (
int i = 0; i < componentsInChildren.Length; i++)
764 string ie =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
767 FileIniDataParser fileIniDataParser =
new FileIniDataParser();
768 if (!File.Exists(pathIni))
770 File.CreateText(pathIni).Close();
772 IniData iniData = fileIniDataParser.ReadFile(pathIni, Encoding.UTF8);
773 if (iniData.GetKey(
"pass").IsEmpty())
776 for (
int i = 0; i < 4; i++)
778 text += ie.RandomItem();
780 iniData.Global[
"pass"] = text;
781 fileIniDataParser.WriteFile(pathIni, iniData);
785 catch (Exception message)
788 Debug.Log(
"exception: Failed to parse:" + pathIni);
789 IO.DeleteFile(pathIni);
790 File.CreateText(pathIni).Close();
800 public static void TryWarnMod(Action action,
bool warn =
true)
804 IniData ini = GetElinIni();
805 if (ini.Global[
"agreed_usercontens_usage_terms"] !=
"yes")
807 string[] items =
new string[3] {
"readTerms",
"agree",
"disagree" };
808 Dialog.List(
"dialogTermsOfUseUGC".lang(), items, (
string j) => j, delegate(
int c,
string d)
816 ini.Global[
"agreed_usercontens_usage_terms"] =
"yes";
831 IniData ini = GetElinIni();
832 if (ini.Global[
"agreed_usercontents_upload_terms"] !=
"yes")
834 string[] items =
new string[3] {
"readTerms",
"agree",
"disagree" };
835 Dialog.List(
"dialogTermsOfUse".lang(), items, (
string j) => j, delegate(
int c,
string d)
843 ini.Global[
"agreed_usercontents_upload_terms"] =
"yes";
List< Action > actionsNextFrame
List< Action > actionsLateUpdate
RenderDataObjDummy rendererObjDummy
void OnChangeResolution()
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
static HashSet< string > assemblies
static CoreConfig TryLoadConfig()
void OnChangeResolution()
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)
override void FreezeScreen(float duration=0.3f)
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 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 Dictionary< string, LangSetting > langs
static List< FileInfo > listMaps
static List< FileInfo > listPartialMaps
static bool IsInitialized
override void Init(string path, string defaultPackage="_Elona")
IEnumerator RefreshMods(Action onComplete, bool syncMods)
static List< object > ListPluginObject
GameScreenNoMap screenNoMap
static SourcePrefInspector Instance
static Dictionary< string, SpawnList > allList
static Dictionary< string, SpriteData > dict
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()