Exemplo n.º 1
0
        private void DetachObject(GameObjectReference index, ref GameObject gameObject)
        {
            if (index.Uid != gameObject.Uid)
            {
                return;
            }

            if (gameObject.Parent == 0)
            {
                return;
            }

            // TODO: update world position by don't notify yet
            this.UpdateWorldPositionAndNotifyComponents(ref gameObject);

            gameObject.DetachNode(index.Index, this);

            gameObject.Origin.UpdateLocalPositionByWorldPosition();

            this.EnqueuePositionChanged(index.Index, ref gameObject);
        }
Exemplo n.º 2
0
        private void Destroy(int index, ref GameObject gameObject)
        {
            if (!gameObject.IsOccupied)
            {
                return;
            }

            while (gameObject.FirstChild != 0)
            {
                this.Destroy(gameObject.FirstChild, ref this.Objects[gameObject.FirstChild]);
            }

            gameObject.DetachNode(index, this);

            for (int i = 0; i < gameObject.Slots.Length; ++i)
            {
                this.DestroyComponent(ref gameObject.Slots[i]);
            }

            this.MakeGarbageFromOccupied(index, ref gameObject);
            ++gameObject.Uid;
        }
Exemplo n.º 3
0
        private void AttachObject(
            GameObjectReference child, ref GameObject childObject, GameObjectReference parent, ref GameObject parentObject)
        {
            if (child.Uid != childObject.Uid)
            {
                return;
            }

            if (parent.Uid != parentObject.Uid)
            {
                return;
            }

            // TODO: update world position by don't notify yet
            if (childObject.IsMoved)
            {
                this.UpdateWorldPositionAndNotifyComponents(ref childObject);
            }

            if (childObject.Parent != 0)
            {
                childObject.DetachNode(child.Index, this);
            }

            // TODO: update world position by don't notify yet
            if (parentObject.IsMoved)
            {
                this.UpdateWorldPositionAndNotifyComponents(ref parentObject);
            }

            childObject.AttachNodeTail(child.Index, parent.Index, ref parentObject, this);

            childObject.Origin.UpdateLocalPosition(parentObject.Origin);

            this.EnqueuePositionChanged(child.Index, ref childObject);
        }