예제 #1
0
        public ActorNode(Actor actor, BSPCollisionNode node)
        {
            this.actor = actor;
            this.node = node;
            ActorNode first = BSPCollisionChecker.GetNodeForActor(actor);
            this.next = first;
            BSPCollisionChecker.SetNodeForActor(actor, this);
            if (this.next != null)
            {
                this.next.prev = this;
            }

            this.mark = true;
        }
예제 #2
0
        public bool ContainsActor(Actor actor)
        {
            ActorNode anode = (ActorNode)CollectionUtils.Get(actors, actor);

            if (anode != null)
            {
                anode.Mark();
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
 public void Removed()
 {
     if (this.prev == null)
     {
         BSPCollisionChecker.SetNodeForActor(this.actor, this.next);
     }
     else
     {
         this.prev.next = this.next;
     }
     if (this.next != null)
     {
         this.next.prev = this.prev;
     }
 }
예제 #4
0
 public void Removed()
 {
     if (this.prev == null)
     {
         BSPCollisionChecker.SetNodeForActor(this.actor, this.next);
     }
     else
     {
         this.prev.next = this.next;
     }
     if (this.next != null)
     {
         this.next.prev = this.prev;
     }
 }
예제 #5
0
        public ActorNode(Actor actor, BSPCollisionNode node)
        {
            this.actor = actor;
            this.node  = node;
            ActorNode first = BSPCollisionChecker.GetNodeForActor(actor);

            this.next = first;
            BSPCollisionChecker.SetNodeForActor(actor, this);
            if (this.next != null)
            {
                this.next.prev = this;
            }

            this.mark = true;
        }
예제 #6
0
 public void Dispose()
 {
     if (node != null)
     {
         node = null;
     }
     if (next != null)
     {
         next.Dispose();
         next = null;
     }
     if (prev != null)
     {
         prev.Dispose();
         prev = null;
     }
 }
예제 #7
0
 public static void SetNodeForActor(Actor o, ActorNode node)
 {
     o.data = node;
 }
예제 #8
0
        private void UpdateObject(Actor o)
        {
            ActorNode node = GetNodeForActor(o);

            if (node != null)
            {
                RectBox          newBounds = this.GetActorBounds(o);
                BSPCollisionNode bspNode;
                if (!this.bspTree.GetArea().Contains(newBounds))
                {
                    for (; node != null;)
                    {
                        bspNode = node.GetBSPNode();
                        node.Remove();
                        this.CheckRemoveNode(bspNode);
                        node = node.GetNext();
                    }
                    this.AddObject(o);
                }
                else
                {
                    RectBox bspArea;
                    RectBox result1 = new RectBox();
                    RectBox result2 = new RectBox();
                    while (node != null)
                    {
                        bspNode = node.GetBSPNode();
                        bspArea = bspNode.GetArea();
                        if (bspArea.Contains(newBounds))
                        {
                            for (ActorNode rNode2 = GetNodeForActor(o); rNode2 != null; rNode2 = rNode2
                                                                                                 .GetNext())
                            {
                                if (rNode2 != node)
                                {
                                    BSPCollisionNode rNode1 = rNode2.GetBSPNode();
                                    rNode2.Remove();
                                    this.CheckRemoveNode(rNode1);
                                }
                            }
                            return;
                        }
                        if (!bspArea.Intersects(newBounds))
                        {
                            BSPCollisionNode rNode = node.GetBSPNode();
                            node.Remove();
                            this.CheckRemoveNode(rNode);
                        }
                        node.ClearMark();
                        node = node.GetNext();
                    }
                    node = GetNodeForActor(o);
                    if (node != null)
                    {
                        for (bspNode = node.GetBSPNode(); bspNode != null &&
                             !bspNode.GetArea().Contains(newBounds); bspNode = bspNode
                                                                               .GetParent())
                        {
                            ;
                        }
                        if (bspNode == null)
                        {
                            while (node != null)
                            {
                                bspNode = node.GetBSPNode();
                                node.Remove();
                                this.CheckRemoveNode(bspNode);
                                node = node.GetNext();
                            }

                            this.AddObject(o);
                            return;
                        }
                    }
                    else
                    {
                        bspNode = this.bspTree;
                    }

                    bspArea = bspNode.GetArea();
                    this.InsertObject(o, newBounds, newBounds, bspArea,
                                      bspNode, result1, result2);
                    for (node = GetNodeForActor(o); node != null; node = node
                                                                         .GetNext())
                    {
                        if (!node.CheckMark())
                        {
                            bspNode = node.GetBSPNode();
                            node.Remove();
                            this.CheckRemoveNode(bspNode);
                        }
                    }
                }
            }
        }
예제 #9
0
 public static void SetNodeForActor(Actor o, ActorNode node)
 {
     o.data = node;
 }
예제 #10
0
        public void Dispose()
        {
            if (node != null)
            {
                node = null;
            }
            if (next != null)
            {
                next.Dispose();
                next = null;
            }
            if (prev != null)
            {
                prev.Dispose();
                prev = null;
            }

        }