Beispiel #1
0
 void AppendPartsInParent <T>(IWhole target, List <T> list) where T : class, IPart
 {
     AppendParts <T>(target, list);
     if (target.parent != null)
     {
         AppendPartsInParent <T>(target.parent, list);
     }
 }
Beispiel #2
0
 void AppendPartsInChildren <T>(IWhole target, List <T> list) where T : class, IPart
 {
     AppendParts <T>(target, list);
     for (int i = 0; i < target.children.Count; ++i)
     {
         AppendPartsInChildren <T>(target.children[i], list);
     }
 }
Beispiel #3
0
 public void AddChild(IWhole whole)
 {
     if (_children.Contains(whole))
     {
         return;
     }
     _children.Add(whole);
     whole.parent = this;
 }
Beispiel #4
0
 void AppendParts <T>(IWhole target, List <T> list) where T : class, IPart
 {
     for (int i = 0; i < target.parts.Count; ++i)
     {
         if (target.parts[i] is T)
         {
             list.Add(target.parts[i] as T);
         }
     }
 }
Beispiel #5
0
    public void RemoveChild(IWhole whole)
    {
        int index = _children.IndexOf(whole);

        if (index != -1)
        {
            _children.RemoveAt(index);
            whole.parent = null;
        }
    }
Beispiel #6
0
    void CheckEnabledInParent()
    {
        bool   shouldEnable = allowed;
        IWhole next         = parent;

        while (shouldEnable && next != null)
        {
            shouldEnable = next.allowed;
            next         = next.parent;
        }
        running = shouldEnable;
    }
Beispiel #7
0
    public void Destroy()
    {
        if (_didDestroy)
        {
            return;
        }

        _didDestroy = true;
        allowed     = false;
        parent      = null;

        for (int i = _parts.Count - 1; i >= 0; i--)
        {
            _parts[i].Disassemble();
        }

        for (int i = _children.Count - 1; i >= 0; i--)
        {
            _children[i].Destroy();
        }
    }