public static void SetModelPreviewObjectType(TableBlock block) { ArchetypeInfo info = GetModelPreviewInfo(block.Block); if (info != null) { block.Archetype = info; block.ObjectType = info.Type; } }
protected override TreeViewItem BuildRoot() { foreach (var info in archetypeInfoById.Values) { info.Dispose(); } archetypeInfoById.Clear(); var currentNonChunkId = -1; var currentChunkIndex = 0; var root = new TreeViewItem { id = currentNonChunkId--, depth = -1, displayName = "Root" }; if (!chunkArray.IsCreated) { root.children = new List <TreeViewItem>(); } else { var currentArchetype = new EntityArchetype(); TreeViewItem currentArchetypeItem = null; foreach (var chunk in chunkArray) { if (chunk.Archetype != currentArchetype) { currentArchetype = chunk.Archetype; var stats = new ArchetypeInfo() { archetype = currentArchetype, control = new EntityQueryGUIControl(currentArchetype.GetComponentTypes(), true), counts = new int[currentArchetype.ChunkCapacity], firstChunkIndex = currentChunkIndex }; archetypeInfoById.Add(currentNonChunkId, stats); currentArchetypeItem = new TreeViewItem() { id = currentNonChunkId--, depth = 0 }; root.AddChild(currentArchetypeItem); } archetypeInfoById[currentArchetypeItem.id].IncrementCount(chunk.Count); archetypeInfoById[currentArchetypeItem.id].lastChunkIndex = currentChunkIndex; if (Mode == ViewMode.Chunks) { var chunkItem = new TreeViewItem() { id = currentChunkIndex, depth = 1, displayName = chunk.Count.ToString() }; currentArchetypeItem.AddChild(chunkItem); } ++currentChunkIndex; } if (!root.hasChildren) { root.children = new List <TreeViewItem>(); } } foreach (var info in archetypeInfoById.Values) { info.UpdateHistogram(); } SetupDepthsFromParentsAndChildren(root); return(root); }
private Table <int, ConnectionPart> GetConnections(int id, string file) { if (!File.Exists(file)) { return(null); } FileManager fileManager = new FileManager(file); EditorIniData iniContent; try { iniContent = fileManager.Read(FileEncoding.Automatic, this.SystemTemplate); } catch { // FileManager could throw an exception if the file can't be opened return(null); } Table <int, ConnectionPart> connections = new Table <int, ConnectionPart>(); foreach (EditorIniBlock block in iniContent.Blocks) { if (block.Name.Equals("object", StringComparison.OrdinalIgnoreCase)) { string archetypeString = null; string gotoString = null; foreach (EditorIniOption option in block.Options) { if (option.Values.Count > 0) { string value = option.Values[0].Value.ToString(); switch (option.Name.ToLowerInvariant()) { case "archetype": archetypeString = value; break; case "goto": gotoString = value; break; } } } if (archetypeString != null && gotoString != null) { ArchetypeInfo archetypeInfo = this.Archetype.TypeOf(archetypeString); if (archetypeInfo != null) { ConnectionPart connection = new ConnectionPart { Id = this.GetConnectionId(BeforeSeperator(gotoString, ",")) }; switch (archetypeInfo.Type) { case ContentType.JumpGate: connection.JumpGate = true; break; case ContentType.JumpHole: connection.JumpHole = true; break; } ConnectionPart existingConnection; if (connections.TryGetValue(connection.Id, out existingConnection)) { if (connection.JumpGate) { existingConnection.JumpGate = true; } if (connection.JumpHole) { existingConnection.JumpHole = true; } } else if (id != connection.Id && connection.Id != -1) { connections.Add(connection); } } } } } return(connections); }