예제 #1
0
        public bool AddChild(object child)
        {
            if (child.Is <IGameObject>() || child.Is <IGameObjectFolder>())
            {
                return(false);
            }

            if (EnvSettingsFolder.AddChild(child))
            {
                return(true);
            }

            if (PlacementsFolder.AddChild(child))
            {
                return(true);
            }

            var domNode = child.As <DomNode>();

            if (domNode != null)
            {
                foreach (var type in domNode.Type.Lineage)
                {
                    if (domNode.Type == Schema.placementsFolderType.Type)
                    {
                        SetChild(Schema.xleGameType.placementsChild, domNode);
                        return(true);
                    }

                    if (domNode.Type == Schema.envSettingsFolderType.Type)
                    {
                        SetChild(Schema.xleGameType.environmentChild, domNode);
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #2
0
        public bool AddChild(object child)
        {
            if (EnvSettingsFolder.AddChild(child))
            {
                return(true);
            }

            var domNode = child.As <DomNode>();

            if (domNode != null)
            {
                foreach (var type in domNode.Type.Lineage)
                {
                    if (domNode.Type == Schema.placementsFolderType.Type)
                    {
                        SetChild(Schema.xleGameType.placementsChild, domNode);
                        return(true);
                    }

                    if (type == Schema.abstractPlacementObjectType.Type)
                    {
                        // We need to look for the appropriate placement cell to put this placement in...
                        // If there are no placement cells, or if there isn't a cell that can contain this
                        // object, then we have to abort
                        var plc      = domNode.As <ITransformable>();
                        var keyPoint = (plc != null) ? plc.Translation : new Sce.Atf.VectorMath.Vec3F(0.0f, 0.0f, 0.0f);

                        var placementsFolder = GetChild <PlacementsFolder>(Schema.xleGameType.placementsChild);
                        if (placementsFolder != null)
                        {
                            foreach (var cellRef in placementsFolder.Cells)
                            {
                                if (cellRef.IsResolved() &&
                                    keyPoint.X >= cellRef.CaptureMins.X && keyPoint.X < cellRef.CaptureMaxs.X &&
                                    keyPoint.Y >= cellRef.CaptureMins.Y && keyPoint.Y < cellRef.CaptureMaxs.Y &&
                                    keyPoint.Z >= cellRef.CaptureMins.Z && keyPoint.Z < cellRef.CaptureMaxs.Z &&
                                    cellRef.Target.CanAddChild(domNode))
                                {
                                    var hierarchical = cellRef.Target.AsAll <IHierarchical>();
                                    foreach (var h in hierarchical)
                                    {
                                        if (h.AddChild(domNode))
                                        {
                                            return(true);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (domNode.Type == Schema.envSettingsFolderType.Type)
                    {
                        SetChild(Schema.xleGameType.environmentChild, domNode);
                        return(true);
                    }
                }
            }

            return(false);
        }