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?.LoadPref();
462 foreach (PCC.Part value2 in
pccs.allParts.Values)
470 for (
int i = 0; i < array.Length; i++)
476 EInput.dragHack = 0f;
484 Widget[] componentsInChildren = ui.widgets.GetComponentsInChildren<
Widget>(includeInactive:
true);
485 foreach (
Widget widget
in componentsInChildren)
487 if (widget.gameObject !=
null)
489 UnityEngine.Object.Destroy(widget.gameObject);
496 Debug.Log(
"Exception:" + ex);
500 if (SteamAPI.IsSteamRunning())
505 catch (Exception ex2)
507 Debug.Log(
"Exception:" + ex2);
514 catch (Exception ex3)
516 Debug.Log(
"Exception:" + ex3);
522 BaseCore.resetRuntime =
false;
523 BiomeProfile.forceInitialize =
true;
524 WidgetHotbar.registering =
false;
525 WidgetHotbar.registeringItem =
null;
526 WordGen.initialized =
false;
527 RecipeManager.rebuild =
true;
528 BookList.dict =
null;
529 BottleMessageList.list =
null;
535 Debug.Log(
"Initializing:" + langCode +
"/" + forceLangCode);
536 StartCoroutine(
"OnEndOfFrame");
537 InvokeRepeating(
"Update100ms", 0.1f, 0.1f);
538 UnityEngine.Object.DestroyImmediate(ui.layoutLang.gameObject);
541 if (config.
lang.IsEmpty())
545 SetLang(config.
lang);
552 PCCManager.current.Init();
553 SpriteVariationManager.current.Init();
557 SoundManager.current.Reset();
591 Instance = _current ?? UnityEngine.Object.FindObjectOfType<
Core>();
592 BaseCore.Instance = Instance;
602 return Instance ?? SetCurrent();
608 SourceData.dataPath = CorePath.packageCore +
"/Data/Source/";
609 Instance = (EClass.core = (EMono.core =
this));
610 SkinManager._Instance = skins;
611 PathManager.Instance = pathManager;
612 EffectManager.Instance = effects;
618 if (releaseMode != m)
621 debug = Resources.Load<
CoreDebug>(
"_Debug " + releaseMode);
629 yield
return new WaitForEndOfFrame();
630 if ((
bool)screen.
guide)
652 lastScreenWidth = Screen.width;
653 lastScreenHeight = Screen.height;
655 for (
int i = 0; i < componentsInChildren.Length; i++)
668 ui.FreezeScreen(duration);
681 public override void StopEventSystem(Component c, Action action,
float duration = 0.12f)
683 eventSystem.enabled =
false;
684 c.transform.DOScale(
new Vector3(1f, 0f, 1f), duration).OnKill(delegate
686 eventSystem.enabled =
true;
687 }).OnComplete(delegate
691 .SetEase(Ease.Linear);
696 eventSystem.enabled =
false;
697 TweenUtil.Tween(duration,
null, delegate
699 eventSystem.enabled =
true;
703 public void SetLang(
string langCode,
bool force =
false)
708 AliasGen.list =
null;
710 WordGen.initialized =
false;
712 if (game !=
null && !IsGameStarted)
728 if (
string.IsNullOrEmpty(str))
730 return Array.Empty<
int>();
732 string[] array = str.Replace(
"\n",
"").Split(
',');
733 int[] array2 =
new int[array.Length * 2];
734 for (
int i = 0; i < array.Length; i++)
736 string[] array3 = array[i].Split(
'/');
737 array2[i * 2] = GetElement(array3[0]);
738 array2[i * 2 + 1] = ((!
int.TryParse(array3.TryGet(1, returnNull:
true), out var result)) ? 1 : result);
746 if (sourceElement ==
null)
748 sourceElement = UnityEngine.Object.FindObjectOfType<
SourceManager>().GetComponent<SourceManager>().
elements;
750 if (!sourceElement.initialized)
752 sourceElement.Init();
754 id =
id?.Trim() ??
"_void";
755 if (!sourceElement.alias.TryGetValue(
id, out var value))
757 if (sourceElement.
fuzzyAlias.TryGetValue(
id, out var value2))
759 Debug.Log(
"#element lookup: '" +
id +
"' -> '" + value2 +
"'");
760 value = sourceElement.alias[value2];
764 Debug.LogWarning(
"#element not found: '" +
id +
"'");
765 value = sourceElement.rows[0];
773 IUISkin[] componentsInChildren = ui.GetComponentsInChildren<
IUISkin>(includeInactive:
true);
774 for (
int i = 0; i < componentsInChildren.Length; i++)
783 string ie =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
786 FileIniDataParser fileIniDataParser =
new FileIniDataParser();
787 if (!File.Exists(pathIni))
789 File.CreateText(pathIni).Close();
791 IniData iniData = fileIniDataParser.ReadFile(pathIni, Encoding.UTF8);
792 if (iniData.GetKey(
"pass").IsEmpty())
795 for (
int i = 0; i < 4; i++)
797 text += ie.RandomItem();
799 iniData.Global[
"pass"] = text;
800 fileIniDataParser.WriteFile(pathIni, iniData);
804 catch (Exception message)
807 Debug.Log(
"exception: Failed to parse:" + pathIni);
808 IO.DeleteFile(pathIni);
809 File.CreateText(pathIni).Close();
819 public static void TryWarnMod(Action action,
bool warn =
true)
823 IniData ini = GetElinIni();
824 if (ini.Global[
"agreed_usercontens_usage_terms"] !=
"yes")
826 string[] items =
new string[3] {
"readTerms",
"agree",
"disagree" };
827 Dialog.List(
"dialogTermsOfUseUGC".lang(), items, (
string j) => j, delegate(
int c,
string d)
835 ini.Global[
"agreed_usercontens_usage_terms"] =
"yes";
850 IniData ini = GetElinIni();
851 if (ini.Global[
"agreed_usercontents_upload_terms"] !=
"yes")
853 string[] items =
new string[3] {
"readTerms",
"agree",
"disagree" };
854 Dialog.List(
"dialogTermsOfUse".lang(), items, (
string j) => j, delegate(
int c,
string d)
862 ini.Global[
"agreed_usercontents_upload_terms"] =
"yes";
List< Action > actionsNextFrame
List< Action > actionsLateUpdate
static void PublishEvent(string eventId, object data=null)
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)
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
GameScreenNoMap screenNoMap
Dictionary< string, string > fuzzyAlias
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()