Inheritance: BaseObject, IContainerObject
コード例 #1
0
ファイル: MovableObject.cs プロジェクト: Fulborg/dwarrowdelf
        public void MoveTo(ContainerObject dst, IntPoint3 dstLoc)
        {
            var src = this.Parent;
            var srcLoc = this.Location;

            if (src != dst)
            {
                if (src != null)
                    src.RemoveChild(this);

                this.Parent = dst;
            }

            if (srcLoc != dstLoc)
            {
                this.Location = dstLoc;
                if (dst != null && src == dst)
                    dst.MoveChild(this, srcLoc, dstLoc);
            }

            if (src != dst)
            {
                if (dst != null)
                    dst.AddChild(this);
            }

            if (src != dst || srcLoc != dstLoc)
                if (ObjectMoved != null)
                    ObjectMoved(this, this.Parent, this.Location);
        }