private void AddType(System.Type t, string group) { if (MonoMain.lockLoading) { MonoMain.loadingLocked = true; while (MonoMain.lockLoading) { Thread.Sleep(10); } } MonoMain.loadingLocked = false; if (group == "survival") { return; } if (group == "") { Main.SpecialCode = "creating " + t.AssemblyQualifiedName; Thing typeInstance = Editor.GetOrCreateTypeInstance(t); Main.SpecialCode = "accessing " + t.AssemblyQualifiedName; IReadOnlyPropertyBag bag = ContentProperties.GetBag(t); if (bag.GetOrDefault <bool>("isInDemo", false)) { this._filteredThings.Add(typeInstance); } if (bag.GetOrDefault <bool>("isOnlineCapable", true)) { this._onlineFilteredThings.Add(typeInstance); } this._things.Add(typeInstance); this._types.Add(t); Editor.MapThing(typeInstance); ++MonoMain.lazyLoadyBits; Main.SpecialCode = "finished " + t.AssemblyQualifiedName; } else { string[] groupName = group.Split('|'); EditorGroup editorGroup = this.SubGroups.FirstOrDefault <EditorGroup>((Func <EditorGroup, bool>)(x => x.Name == groupName[0])); if (editorGroup == null) { editorGroup = new EditorGroup(); editorGroup.Name = groupName[0]; this.SubGroups.Add(editorGroup); } string str = group; string group1 = ((IEnumerable <string>)groupName).Count <string>() <= 1 ? str.Remove(0, groupName[0].Length) : str.Remove(0, groupName[0].Length + 1); editorGroup.AddType(t, group1); } }
public void ApplySpawnerData(string data) { this.spawners.Clear(); this.numPermanentWeapons = 0; this.numPermanentSuperWeapons = 0; this.numPermanentFatalWeapons = 0; string str = data; char[] chArray = new char[1] { '|' }; foreach (string name in str.Split(chArray)) { if (name != "") { try { System.Type type = Editor.GetType(name); if (!this.spawners.ContainsKey(type)) { this.spawners[type] = 0; } Dictionary <System.Type, int> spawners; System.Type key; (spawners = this.spawners)[key = type] = spawners[key] + 1; ++this.numPermanentWeapons; IReadOnlyPropertyBag bag = ContentProperties.GetBag(type); if (bag.GetOrDefault <bool>("isSuperWeapon", false)) { ++this.numPermanentSuperWeapons; } if (bag.GetOrDefault <bool>("isFatal", true)) { ++this.numPermanentFatalWeapons; } } catch { } } } }
public void UpdateGrayout() { this.greyOut = false; if (Editor.onlineMode && this.willOnlineGrayout) { this.greyOut = true; } foreach (ContextMenu contextMenu in this._items) { if (contextMenu is EditorGroupMenu) { (contextMenu as EditorGroupMenu).UpdateGrayout(); } else if (contextMenu.contextThing != null) { contextMenu.greyOut = false; IReadOnlyPropertyBag bag = ContentProperties.GetBag(contextMenu.contextThing.GetType()); if (Editor.onlineMode && !bag.GetOrDefault <bool>("isOnlineCapable", true)) { contextMenu.greyOut = true; } } } }
public ContextBackgroundTile(Thing thing, IContextListener owner, bool placement = true) : base(owner) { this._placement = placement; this._thing = thing; this._image = thing.GetEditorImage(); this.itemSize.x = 180f; this.itemSize.y = 16f; this._text = thing.editorName; this.itemSize.x = (float)(this._text.Length * 8 + 16); this._canExpand = true; this.depth = new Depth(0.8f); if (this._thing is CustomBackground) { this._file = new ContextFile("BURG", (IContextListener)this, new FieldBinding((object)this._thing, "customBackground0" + (object)((thing as CustomBackground).customIndex + 1)), ContextFileType.Background); } IReadOnlyPropertyBag bag = ContentProperties.GetBag(thing.GetType()); if (!Main.isDemo || bag.GetOrDefault <bool>("isInDemo", false)) { return; } this.greyOut = true; }
public void InitializeGroups( EditorGroup group, FieldBinding radioBinding = null, EditorGroup scriptingGroup = null) { ++EditorGroupMenu.deep; this._text = group.Name; this.itemSize.x = (float)(this._text.Length * 8 + 16); foreach (EditorGroup subGroup in group.SubGroups) { EditorGroupMenu editorGroupMenu = new EditorGroupMenu((IContextListener)this); editorGroupMenu.fancy = this.fancy; editorGroupMenu.InitializeGroups(subGroup, radioBinding); if (!editorGroupMenu.greyOut) { this.greyOut = false; } if (!editorGroupMenu.willOnlineGrayout) { this.willOnlineGrayout = false; } this.AddItem((ContextMenu)editorGroupMenu); } if (scriptingGroup != null) { EditorGroupMenu editorGroupMenu = new EditorGroupMenu((IContextListener)this); editorGroupMenu.InitializeGroups(scriptingGroup, radioBinding); if (!editorGroupMenu.greyOut) { this.greyOut = false; } if (!editorGroupMenu.willOnlineGrayout) { this.willOnlineGrayout = false; } this.AddItem((ContextMenu)editorGroupMenu); } foreach (Thing allThing in group.AllThings) { IReadOnlyPropertyBag bag = ContentProperties.GetBag(allThing.GetType()); if (Main.isDemo && bag.GetOrDefault <bool>("isInDemo", false)) { this.greyOut = false; } if (bag.GetOrDefault <bool>("isOnlineCapable", true)) { this.greyOut = false; this.willOnlineGrayout = false; } switch (allThing) { case BackgroundTile _: case ForegroundTile _: case SubBackgroundTile _: ContextBackgroundTile contextBackgroundTile = new ContextBackgroundTile(allThing, (IContextListener)this); contextBackgroundTile.contextThing = allThing; this.AddItem((ContextMenu)contextBackgroundTile); continue; default: if (radioBinding != null) { if (radioBinding.value is IList) { if (radioBinding.value is List <TypeProbPair> ) { ContextSlider contextSlider = new ContextSlider(allThing.editorName, (IContextListener)this, radioBinding, 0.05f, myType: allThing.GetType()); contextSlider.greyOut = Main.isDemo && !bag.GetOrDefault <bool>("isInDemo", false); contextSlider.contextThing = allThing; if (!bag.Contains("isOnlineCapable") || bag.Get <bool>("isOnlineCapable")) { this.willOnlineGrayout = false; } this.AddItem((ContextMenu)contextSlider); continue; } ContextCheckBox contextCheckBox = new ContextCheckBox(allThing.editorName, (IContextListener)this, radioBinding, allThing.GetType()); contextCheckBox.greyOut = Main.isDemo && !bag.GetOrDefault <bool>("isInDemo", false); contextCheckBox.contextThing = allThing; if (!bag.Contains("isOnlineCapable") || bag.Get <bool>("isOnlineCapable")) { this.willOnlineGrayout = false; } this.AddItem((ContextMenu)contextCheckBox); continue; } ContextRadio contextRadio = new ContextRadio(allThing.editorName, false, (object)allThing.GetType(), (IContextListener)this, radioBinding); contextRadio.greyOut = Main.isDemo && !bag.GetOrDefault <bool>("isInDemo", false); contextRadio.contextThing = allThing; if (!bag.Contains("isOnlineCapable") || bag.Get <bool>("isOnlineCapable")) { this.willOnlineGrayout = false; } this.AddItem((ContextMenu)contextRadio); continue; } ContextObject contextObject = new ContextObject(allThing, (IContextListener)this); contextObject.contextThing = allThing; this.AddItem((ContextMenu)contextObject); continue; } } --EditorGroupMenu.deep; if (EditorGroupMenu.deep != 0) { return; } this.UpdateGrayout(); }
/// <summary> /// Gets a read-only property bag associated with the type. /// </summary> /// <typeparam name="T">The type to get the bag from</typeparam> /// <returns>The property bag</returns> public static IReadOnlyPropertyBag GetBag <T>() => ContentProperties.GetBag(typeof(T));
public void Load(float x, float y, Level level, bool symmetric) { if (symmetric && this.isMirrored) { symmetric = false; } if (!symmetric && this.flip) { Level.flipH = true; } if (this.symmetry || symmetric) { Level.symmetry = true; } if (this.data != null) { foreach (BinaryClassChunk node in this.data) { Thing t1 = Thing.LoadThing(node); if (t1 != null && (ContentProperties.GetBag(t1.GetType()).GetOrDefault <bool>("isOnlineCapable", true) || !Network.isActive)) { Level.leftSymmetry = true; Level.loadingOppositeSymmetry = false; this.mainLoad = true; Thing t2 = this.ProcessThing(t1, x, y, level); this.mainLoad = false; if (t2 != null && Network.isActive && t2.isStateObject) { GhostManager.context.MakeGhost(t2, initLevel: true); t2.ghostType = Editor.IDToType[t2.GetType()]; if (DuckNetwork.hostDuckIndex >= 0 && DuckNetwork.hostDuckIndex < 4 && DuckNetwork.profiles[DuckNetwork.hostDuckIndex].connection != null) { t2.connection = DuckNetwork.profiles[DuckNetwork.hostDuckIndex].connection; } } if (!(t1 is ThingContainer)) { if (t2 != null && Level.symmetry && ((double)this.posBeforeTranslate.x - 8.0 < 80.0 || (double)this.posBeforeTranslate.x - 8.0 > 96.0)) { this.mainLoad = false; Level.leftSymmetry = false; Level.loadingOppositeSymmetry = true; Thing t3 = this.ProcessThing(Thing.LoadThing(node, false), x, y, level); if (t3 != null && Network.isActive && t3.isStateObject) { GhostManager.context.MakeGhost(t3, initLevel: true); t3.ghostType = Editor.IDToType[t3.GetType()]; if (DuckNetwork.hostDuckIndex >= 0 && DuckNetwork.hostDuckIndex < 4 && DuckNetwork.profiles[DuckNetwork.hostDuckIndex].connection != null) { t3.connection = DuckNetwork.profiles[DuckNetwork.hostDuckIndex].connection; } } } } else { foreach (Thing thing in (t1 as ThingContainer).things) { if (thing is BackgroundTile || thing is ForegroundTile) { Thing t3 = this.ProcessThing(thing, x, y, level); if (t3 != null && Network.isActive && t3.isStateObject) { GhostManager.context.MakeGhost(t3, initLevel: true); t3.ghostType = Editor.IDToType[t3.GetType()]; if (DuckNetwork.hostDuckIndex >= 0 && DuckNetwork.hostDuckIndex < 4 && DuckNetwork.profiles[DuckNetwork.hostDuckIndex].connection != null) { t3.connection = DuckNetwork.profiles[DuckNetwork.hostDuckIndex].connection; } } } } } } } level.things.RefreshState(); } Level.flipH = false; Level.symmetry = false; }