public CustomDecoration Select(int idx)
        {
            if (!setupMode)
            {
                return(null);
            }

            if (currentSelect != null)
            {
                return(currentSelect.GetComponent <CustomDecoration>());
            }

            if (idx < 1 || idx > group[CurrentGroup].Length)
            {
                return(null);
            }

            string     poolname = group[CurrentGroup][idx - 1];
            GameObject go       = ObjectLoader.CloneDecoration(poolname);

            currentSelect = go;
            CustomDecoration cd = go?.GetComponent <CustomDecoration>();

            go?.SetActive(true);

            OnChanged?.Invoke(cd);
            return(cd);
        }
示例#2
0
            public override GameObject CopySelf(object self = null)
            {
                var item_clone = item.Clone() as Item;

                ((PointItem)item_clone).seq = 0;
                var clone = ObjectLoader.CloneDecoration(item.pname, item_clone);

                return(clone);
            }
示例#3
0
        // Spawn Object from Json files
        private void SpawnFromSettings(Scene arg0, LoadSceneMode arg1)
        {
            //Logger.LogDebug($"Item Count:{ItemData.items.Count}");
            if (arg0.name.Contains("Menu_Title"))
            {
                return;
            }

            IEnumerator SpawnGlobal(Scene arg0)
            {
                int count = 0;

                Logger.LogDebug("Try to spawn setting");
                string sceneName = arg0.name;

                yield return(new WaitUntil(() => (arg0.isLoaded)));

                var spawnlist = ItemData.items.Where(x => x.sceneName == sceneName).ToArray();

                foreach (var r in spawnlist)
                {
                    try
                    {
                        if (ObjectLoader.CloneDecoration(r.pname, r) != null)
                        {
                            count++;
                        }
                    }
                    catch
                    {
                        Logger.LogError($"Spawn Failed When Try to Spawn {r?.pname}");
                    }
                }
                Modding.Logger.LogDebug($"All Fine,Spawn {count} in {sceneName}");
                yield break;
            }

            IEnumerator SpawnLocal(Scene arg0, ItemSettings setting)
            {
                int count = 0;

                Logger.LogDebug("Try to spawn setting");
                string sceneName = arg0.name;

                yield return(new WaitUntil(() => (arg0.isLoaded)));

                var spawnlist = setting.items;

                foreach (var r in spawnlist)
                {
                    try
                    {
                        if (ObjectLoader.CloneDecoration(r.pname, r) != null)
                        {
                            count++;
                        }
                    }
                    catch
                    {
                        Logger.LogError($"Spawn Failed When Try to Spawn {r?.pname}");
                    }
                }
                Modding.Logger.LogDebug($"All Fine,Spawn {count} in {sceneName}");
                yield break;
            }

            if (ItemData.items.Count > 0)
            {
                GameManager.instance.StartCoroutine(SpawnGlobal(arg0));
            }
            if (SceneItemData.TryGetValue(arg0.name, out var sceneSetting))
            {
                GameManager.instance.StartCoroutine(SpawnLocal(arg0, sceneSetting));
            }
            else
            {
                var _scene_setting = SerializeHelper.LoadSceneSettings <ItemSettings>(arg0.name);
                if (_scene_setting != null)
                {
                    SceneItemData.Add(arg0.name, _scene_setting);
                    GameManager.instance.StartCoroutine(SpawnLocal(arg0, _scene_setting));
                }
            }
        }