Created
August 17, 2018 16:13
-
-
Save jeffvella/7e5f6daf75a5347a2c03ff9a3cfcd2c7 to your computer and use it in GitHub Desktop.
Monobehavior for use with Svelto ECS and Odin Inspectors to explore entity data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using Sirenix.OdinInspector; | |
using Svelto.ECS; | |
using Svelto.ECS.Example.Survive; | |
using Svelto.ECS.Internal; | |
using UnityEngine; | |
public class EntitiesViewer : MonoBehaviour | |
{ | |
private MainContext _context; | |
private Dictionary<int, Dictionary<Type, ITypeSafeDictionary>> _db; | |
void Start () | |
{ | |
_context = GetComponent<MainContext>(); | |
_db = _context._applicationRoot._enginesRoot._groupEntityDB; | |
} | |
[ShowInInspector] | |
public Dictionary<int, Dictionary<int, List<IEntityStruct>>> Data = new Dictionary<int, Dictionary<int, List<IEntityStruct>>>(); | |
void Update () | |
{ | |
foreach (var group in _db) | |
{ | |
var gid = group.Key; | |
var entityTypeContainers = group.Value; | |
var groupDictionary = new Dictionary<int, List<IEntityStruct>>(); | |
Data[gid] = groupDictionary; | |
foreach (var entity in entityTypeContainers) | |
{ | |
var components = entity.Value.GetEntityStructs(); | |
foreach (var component in components) | |
{ | |
if (!groupDictionary.ContainsKey(component.Key)) | |
{ | |
groupDictionary[component.Key] = new List<IEntityStruct>(); | |
} | |
groupDictionary[component.Key].Add(component.Value); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires Changes to TypeSafeDictionary.cs
ITypeSafeDictionary
TypeSafeDictionary