Beispiel #1
0
    internal void SetComponent <T>(ECSEntityIndex index, T component) where T : struct, IECSComponent
    {
        Type type = typeof(T);
        ECSComponentBuffer <T> buffer = this[type] as ECSComponentBuffer <T>;

        buffer.SetComponent(index, component);
    }
Beispiel #2
0
    internal T GetComponent <T>(ECSEntityIndex index) where T : struct, IECSComponent
    {
        Type type = typeof(T);
        ECSComponentBuffer <T> buffer = this[type] as ECSComponentBuffer <T>;
        T component = buffer.GetComponent(index);

        return(component);
    }
Beispiel #3
0
    internal ECSEntityIndex AddComponent <T>(ECSEntity entity, T component) where T : struct, IECSComponent
    {
        Type type = typeof(T);
        ECSComponentBuffer <T> buffer = this[type] as ECSComponentBuffer <T>;
        ECSEntityIndex         index  = buffer.AddComponent(component);

        return(index);
    }
Beispiel #4
0
    internal void RegisterComponent <T>() where T : struct, IECSComponent
    {
        Type type = typeof(T);

        if (!this.ContainsKey(type))
        {
            IECSComponentBuffer buffer = new ECSComponentBuffer <T>();
            this.Add(type, buffer);
        }
    }