示例#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);
     }
 }
示例#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);
     }
 }
示例#3
0
 public void AddChild(IWhole whole)
 {
     if (_children.Contains(whole))
     {
         return;
     }
     _children.Add(whole);
     whole.parent = this;
 }
示例#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);
         }
     }
 }
示例#5
0
    public void RemoveChild(IWhole whole)
    {
        int index = _children.IndexOf(whole);

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

        while (shouldEnable && next != null)
        {
            shouldEnable = next.allowed;
            next         = next.parent;
        }
        running = shouldEnable;
    }
示例#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();
        }
    }