Esempio n. 1
0
    public void AddComponent(WTComponent newComponent)
    {
        if (GetComponentWithName(newComponent.name) != null)
        {
            throw new FutileException("can't add component since there's already one called " + newComponent.name);
        }

        newComponent.HandleAddedToEntity(this);
        newComponent.SignalComponentDestroyed += HandleComponentDestroyed;
        components.Add(newComponent);
    }
Esempio n. 2
0
    private void HandleComponentDestroyed(WTComponent component)
    {
        int componentIndex = -1;

        for (int i = 0; i < components.Count; i++)
        {
            if (components[i] == component)
            {
                componentIndex = i;
                break;
            }
        }

        if (componentIndex == -1)
        {
            throw new FutileException("component not found on entity");
        }

        components.RemoveAt(componentIndex);
    }