Ejemplo n.º 1
0
        public LogicComponent GetClosestComponent(int x, int y, LogicComponentFilter filter)
        {
            LogicArrayList <LogicComponent> components = this.m_components[(int)filter.GetComponentType()];
            LogicComponent closestComponent            = null;

            int closestDistance = 0;

            for (int i = 0, size = components.Size(); i < size; i++)
            {
                LogicComponent component = components[i];

                if (filter.TestComponent(component))
                {
                    int distance = component.GetParent().GetPosition().GetDistanceSquaredTo(x, y);

                    if (distance < closestDistance || closestComponent == null)
                    {
                        closestDistance  = distance;
                        closestComponent = component;
                    }
                }
            }

            return(closestComponent);
        }
Ejemplo n.º 2
0
        public void RemoveComponent(LogicComponent component)
        {
            LogicArrayList <LogicComponent> components = this.m_components[(int)component.GetComponentType()];

            for (int i = 0, j = components.Size(); i < j; i++)
            {
                if (components[i] == component)
                {
                    components.Remove(i);
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public void Tick()
        {
            bool isInCombatState = this.m_level.IsInCombatState();

            for (int i = 0; i < LogicComponent.COMPONENT_TYPE_COUNT; i++)
            {
                LogicArrayList <LogicComponent> components = this.m_components[i];

                for (int j = 0, size = components.Size(); j < size; j++)
                {
                    LogicComponent component = components[j];

                    if (component.IsEnabled())
                    {
                        component.Tick();
                    }
                }

                if (i == 0 && !isInCombatState)
                {
                    i = 1;
                }
            }
        }
Ejemplo n.º 4
0
 public void AddComponent(LogicComponent component)
 {
     this.m_components[(int)component.GetComponentType()].Add(component);
 }