public IEnumerator<T> GetEnumerator() { List<int> indx; var all = GetAllObjs(out indx); for (var i = 0; i < all.Count; i++) { var e = all[i]; if (QcSharp.IsDefaultOrNull(e)) continue; currentEnumerationIndex = indx[i]; yield return e; } }
public static bool Inspect <TG, T>(TG countless, ref int inspected) where TG : CountlessCfg <T> where T : ICfg, IPEGI, new() { var changed = false; if (inspected > -1) { var e = countless[inspected]; if (QcSharp.IsDefaultOrNull(e) || icon.Back.ClickUnFocus()) { inspected = -1; } else { pegi.Try_Nested_Inspect(e).changes(ref changed); } } var deleted = -1; if (inspected == -1) { List <int> indexes; var all = countless.GetAllObjs(out indexes); for (int i = 0; i < all.Count; i++) { var el = all[i]; var ind = indexes[i]; if (icon.Delete.Click()) { countless[ind] = default(T); } "{0}: ".F(ind).write(35); if (pegi.InspectValueInCollection(ref el, null, ind, ref inspected).nl(ref changed) && typeof(T).IsValueType) { countless[indexes[i]] = el; } } } if (deleted != -1) { countless[deleted] = default(T); } pegi.newLine(); return(changed); }
public static void TryChangeObjectType(IList list, int index, Type type, TaggedTypesCfg cfg, ListMetaData ld = null) { var previous = QcSharp.TryGetObj(list, index); var el = previous; var iTag = el as IGotClassTag; var std = (el as ICfg); var ed = ld.TryGetElement(index); if (ed != null && ld.keepTypeData && iTag != null) { ed.ChangeType(ref el, type, cfg, ld.keepTypeData); } else { el = std.TryDecodeInto <object>(type); StdExtensions.TryCopy_Std_AndOtherData(previous, el); } list[index] = el; }
public int GetReferenceIndex(Object obj) => QcSharp.TryGetIndexOrAdd(nestedReferences, obj);
protected virtual void Set(int ind, T obj) { if (ind >= max) { if (QcSharp.IsDefaultOrNull(obj)) { return; } while (ind >= max) { depth++; max *= BranchSize; var newBranch = GetNewBranch(); newBranch.br[0] = br; newBranch.value++; br = newBranch; } path = new VariableBranch[depth]; pathInd = new int[depth]; } var d = depth; var vb = br; var subSize = max; if (!QcSharp.IsDefaultOrNull(obj)) { while (d > 0) { subSize /= BranchSize; var no = ind / subSize; ind -= no * subSize; if (vb.br[no] == null) { vb.br[no] = GetNewBranch(); vb.value++; } d--; vb = vb.br[no]; } if (vb.br[ind] == null) { vb.br[ind] = GetNewFruit(); vb.value += 1; var cnt = objs.Length; while (_firstFreeObj < cnt && !QcSharp.IsDefaultOrNull(objs[_firstFreeObj])) { _firstFreeObj++; } if (_firstFreeObj >= cnt) { Expand(ref objs, BranchSize); } objs[_firstFreeObj] = obj; vb.br[ind].value = _firstFreeObj; } else { objs[vb.br[ind].value] = obj; } } else { while (d > 0) { subSize /= BranchSize; var no = ind / subSize; ind -= no * subSize; if (vb.br[no] == null) { return; } d--; path[d] = vb; pathInd[d] = no; vb = vb.br[no]; } if (vb.br[ind] == null) { return; } var ar = vb.br[ind].value; objs[ar] = default; _firstFreeObj = Mathf.Min(_firstFreeObj, ar); DiscardFruit(vb, ind); while (d < depth) { if (vb.value > 0) { return; } vb = path[d]; DiscardBranch(vb, pathInd[d]); d++; } TryReduceDepth(); } }
public List<T> GetAllObjsNoOrder() => objs.Where(t => !QcSharp.IsDefaultOrNull(t)).ToList();
public IEnumerator GetEnumerator() => _objs.Where(e => !QcSharp.IsDefaultOrNull(e)).GetEnumerator();
public static bool InspectInspector() { var changed = false; if ("Coroutines [{0}]".F(QcAsync.GetActiveCoroutinesCount).enter(ref inspectedSection, 0).nl()) { QcAsync.InspectManagedCoroutines().nl(ref changed); } "Screen Shots".enter_Inspect(screenShots, ref inspectedSection, 1).nl(ref changed); "Json Inspector".enter_Inspect(jsonInspector, ref inspectedSection, 2).nl(); if ("ICfg Inspector".enter(ref inspectedSection, 3).nl()) { iCfgExplorer.Inspect(null).nl(ref changed); } if ("Gui Styles".enter(ref inspectedSection, 4).nl()) { PEGI_Styles.Inspect().nl(); } if ("Data".enter(ref inspectedSection, 5).nl()) { if (inspectedData == -1) { if ("Player Data Folder".Click().nl()) { QcFile.Explorer.OpenPersistentFolder(); pegi.SetCopyPasteBuffer(Application.persistentDataPath, sendNotificationIn3Dview: true); } if (Application.isEditor && "Editor Data Folder".Click().nl()) { QcFile.Explorer.OpenPath( "C:/Users/{0}/AppData/Local/Unity/Editor/Editor.log".F(Environment.UserName)); } } if ("Cache".enter(ref inspectedData, 1).nl()) { if ("Caching.ClearCache() [{0}]".F(Caching.cacheCount).ClickConfirm("clCach").nl()) { if (Caching.ClearCache()) { pegi.GameView.ShowNotification("Bundles were cleared"); } else { pegi.GameView.ShowNotification("ERROR: Bundles are being used"); } } List <string> lst = new List <string>(); Caching.GetAllCachePaths(lst); "Caches".edit_List(ref lst, path => { var c = Caching.GetCacheByPath(path); if (icon.Delete.Click()) { if (Caching.RemoveCache(c)) { pegi.GameView.ShowNotification("Bundle was cleared"); } else { pegi.GameView.ShowNotification("ERROR: Bundle is being used"); } } if (icon.Folder.Click()) { QcFile.Explorer.OpenPath(path); } if (icon.Copy.Click()) { pegi.SetCopyPasteBuffer(path); } path.write(); return(path); }); } } if ("Profiler".enter(ref inspectedSection, 6).nl()) { "Mono Heap Size Long {0}".F(Profiler.GetMonoHeapSizeLong().ToMegabytes()).nl(); "Mono Used Size Long {0}".F(Profiler.GetMonoUsedSizeLong().ToMegabytes()).nl(); "Temp Allocated Size {0}".F(Profiler.GetTempAllocatorSize().ToMegabytes()).nl(); "Total Allocated Memmory Long {0}".F(Profiler.GetTotalAllocatedMemoryLong().ToMegabytes()).nl(); "Total Unused Reserved Memmory Long {0}".F(Profiler.GetTotalUnusedReservedMemoryLong().ToMegabytes()).nl(); if ("Unload Unused Assets".Click().nl()) { Resources.UnloadUnusedAssets(); } } if ("Time & Audio".enter(ref inspectedSection, 7).nl()) { "Time.time: {0}".F(QcSharp.SecondsToReadableString(Time.time)).nl(); "AudioSettings.dspTime: {0}".F(QcSharp.SecondsToReadableString(AudioSettings.dspTime)).nl(); "Use it to schedule Audio Clips: audioSource.PlayScheduled(AudioSettings.dspTime + 0.5);".writeHint(); "Clip Duration: double duration = (double)AudioClip.samples / AudioClip.frequency;".writeHint(); "Time.unscaled time: {0}".F(QcSharp.SecondsToReadableString(Time.unscaledTime)).nl(); "Time.frameCount: {0}".F(Time.frameCount).nl(); var tScale = Time.timeScale; if ("Time.timescale".edit(ref tScale, 0f, 4f)) { Time.timeScale = tScale; } if (tScale != 1 && icon.Refresh.Click()) { Time.timeScale = 1; } pegi.nl(); "Time.deltaTime: {0}".F(QcSharp.SecondsToReadableString(Time.deltaTime)).nl(); "Time.realtimeSinceStartup {0}".F(QcSharp.SecondsToReadableString(Time.realtimeSinceStartup)).nl(); var fr = Application.targetFrameRate; if ("Frame-Rate".edit(ref fr).nl() && fr > 0) { Application.targetFrameRate = fr; } } return(changed); }