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();
231 Component component =
item as Component;
237 GameObject obj = component.gameObject;
238 obj.SendMessage(
"OnStartCore");
239 Component[] componentsInChildren = obj.GetComponentsInChildren<Component>();
240 foreach (Component component2
in componentsInChildren)
242 Debug.Log(component2.GetType().Assembly.GetName().Name);
254 Debug.Log(
"Config doesn't exist.");
259 BookList.dict =
null;
263 string currentGameLanguage = SteamApps.GetCurrentGameLanguage();
264 if (!(currentGameLanguage ==
"chinese"))
266 if (!(currentGameLanguage ==
"japanese"))
268 BookList.dict =
null;
279 catch (Exception message)
286 ui.ShowSceneSelector();
302 SoundManager.requestCount = 0;
304 EInput.uiMousePosition = Input.mousePosition /
ui.canvasScaler.scaleFactor;
318 Canvas.GetDefaultCanvasMaterial().CopyPropertiesFromMaterial(
matUI);
321 delta = Time.smoothDeltaTime;
326 EInput.delta = (ButtonState.delta =
delta);
329 int width = Display.main.systemWidth;
330 int height = Display.main.systemHeight;
336 if (Screen.fullScreen)
338 Screen.SetResolution(width, height, fullscreen:
true);
349 if (Screen.width != w || Screen.height != h)
351 Screen.SetResolution(w, h, Screen.fullScreen);
394 UIButton.actionTooltip =
null;
409 Resources.UnloadUnusedAssets();
417 AudioListener.volume = 1f;
421 AudioListener.volume = 0f;
438 WidgetMinimap.Instance.Reload();
442 if (row.replacer.hasChacked && row.replacer.data != null)
444 row.replacer.data.GetSprite();
453 foreach (PCC.Part value in
pccs.allParts.Values)
461 for (
int i = 0; i < array.Length; i++)
467 EInput.dragHack = 0f;
475 Widget[] componentsInChildren = ui.widgets.GetComponentsInChildren<
Widget>(includeInactive:
true);
476 foreach (
Widget widget
in componentsInChildren)
478 if (widget.gameObject !=
null)
480 UnityEngine.Object.Destroy(widget.gameObject);
487 Debug.Log(
"Exception:" + ex);
491 if (SteamAPI.IsSteamRunning())
496 catch (Exception ex2)
498 Debug.Log(
"Exception:" + ex2);
505 catch (Exception ex3)
507 Debug.Log(
"Exception:" + ex3);
513 BaseCore.resetRuntime =
false;
514 BiomeProfile.forceInitialize =
true;
515 WidgetHotbar.registering =
false;
516 WidgetHotbar.registeringItem =
null;
517 WordGen.initialized =
false;
518 RecipeManager.rebuild =
true;
519 BookList.dict =
null;
525 Debug.Log(
"Initializing:" + langCode +
"/" + forceLangCode);
526 StartCoroutine(
"OnEndOfFrame");
527 InvokeRepeating(
"Update100ms", 0.1f, 0.1f);
528 UnityEngine.Object.DestroyImmediate(ui.layoutLang.gameObject);
530 if (config.
lang.IsEmpty())
534 SetLang(config.
lang);
546 PCCManager.current.Init();
547 SpriteVariationManager.current.Init();
551 SoundManager.current.Reset();
585 Instance = _current ?? UnityEngine.Object.FindObjectOfType<
Core>();
586 BaseCore.Instance = Instance;
596 return Instance ?? SetCurrent();
602 SourceData.dataPath = CorePath.packageCore +
"/Data/Source/";
603 Instance = (EClass.core = (EMono.core =
this));
604 SkinManager._Instance = skins;
605 PathManager.Instance = pathManager;
606 EffectManager.Instance = effects;
612 if (releaseMode != m)
615 debug = Resources.Load<
CoreDebug>(
"_Debug " + releaseMode);
623 yield
return new WaitForEndOfFrame();
624 if ((
bool)screen.
guide)
646 lastScreenWidth = Screen.width;
647 lastScreenHeight = Screen.height;
649 for (
int i = 0; i < componentsInChildren.Length; i++)
662 ui.FreezeScreen(duration);
675 public override void StopEventSystem(Component c, Action action,
float duration = 0.12f)
677 eventSystem.enabled =
false;
678 c.transform.DOScale(
new Vector3(1f, 0f, 1f), duration).OnKill(delegate
680 eventSystem.enabled =
true;
681 }).OnComplete(delegate
685 .SetEase(Ease.Linear);
690 eventSystem.enabled =
false;
691 TweenUtil.Tween(duration,
null, delegate
693 eventSystem.enabled =
true;
697 public void SetLang(
string langCode,
bool force =
false)
702 AliasGen.list =
null;
704 WordGen.initialized =
false;
706 if (game !=
null && !IsGameStarted)
716 if (
string.IsNullOrEmpty(str))
720 string[] array = str.Replace(
"\n",
"").Split(
',');
721 int[] array2 =
new int[array.Length * 2];
722 for (
int i = 0; i < array.Length; i++)
724 string[] array3 = array[i].Split(
'/');
725 array2[i * 2] = GetElement(array3[0]);
726 array2[i * 2 + 1] = ((array3.Length == 1) ? 1 :
int.Parse(array3[1]));
734 if (sourceElement ==
null)
736 sourceElement = UnityEngine.Object.FindObjectOfType<
SourceManager>().GetComponent<SourceManager>().
elements;
738 if (!sourceElement.initialized)
740 sourceElement.Init();
742 if (!sourceElement.alias.TryGetValue(
id ??
"_void", out var value))
744 Debug.LogError(
"exception:" +
id);
745 value = sourceElement.rows[0];
752 IUISkin[] componentsInChildren = ui.GetComponentsInChildren<
IUISkin>(includeInactive:
true);
753 for (
int i = 0; i < componentsInChildren.Length; i++)
762 string ie =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
765 FileIniDataParser fileIniDataParser =
new FileIniDataParser();
766 if (!File.Exists(pathIni))
768 File.CreateText(pathIni).Close();
770 IniData iniData = fileIniDataParser.ReadFile(pathIni, Encoding.UTF8);
771 if (iniData.GetKey(
"pass").IsEmpty())
774 for (
int i = 0; i < 4; i++)
776 text += ie.RandomItem();
778 iniData.Global[
"pass"] = text;
779 fileIniDataParser.WriteFile(pathIni, iniData);
783 catch (Exception message)
786 Debug.Log(
"exception: Failed to parse:" + pathIni);
787 IO.DeleteFile(pathIni);
788 File.CreateText(pathIni).Close();
798 public static void TryWarnMod(Action action,
bool warn =
true)
802 IniData ini = GetElinIni();
803 if (ini.Global[
"agreed_usercontens_usage_terms"] !=
"yes")
805 string[] items =
new string[3] {
"readTerms",
"agree",
"disagree" };
806 Dialog.List(
"dialogTermsOfUseUGC".lang(), items, (
string j) => j, delegate(
int c,
string d)
814 ini.Global[
"agreed_usercontens_usage_terms"] =
"yes";
829 IniData ini = GetElinIni();
830 if (ini.Global[
"agreed_usercontents_upload_terms"] !=
"yes")
832 string[] items =
new string[3] {
"readTerms",
"agree",
"disagree" };
833 Dialog.List(
"dialogTermsOfUse".lang(), items, (
string j) => j, delegate(
int c,
string d)
841 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()