예제 #1
0
        public DefaultDirectionalLightEntity(
            IEditorQuery <DefaultDirectionalLightEntity> editorQuery,
            StandardDirectionalLightComponent standardDirectionalLightComponent)
        {
            if (editorQuery.Mode != EditorQueryMode.BakingSchema)
            {
                RegisterComponent(standardDirectionalLightComponent);

                editorQuery.MapTransform(this, Transform.Assign);
                editorQuery.MapCustom(this, "diffuse", "diffuse", x => standardDirectionalLightComponent.LightColor = x, Color.White);
            }
        }
        public DefaultDirectionalLightEntity(
            IEditorQuery<DefaultDirectionalLightEntity> editorQuery,
            StandardDirectionalLightComponent standardDirectionalLightComponent)
        {
            if (editorQuery.Mode != EditorQueryMode.BakingSchema)
            {
                RegisterComponent(standardDirectionalLightComponent);

                editorQuery.MapTransform(this, Transform.Assign);
                editorQuery.MapCustom(this, "diffuse", "diffuse", x => standardDirectionalLightComponent.LightColor = x, Color.White);
            }
        }
        public DefaultPointLightEntity(
            IEditorQuery <DefaultPointLightEntity> editorQuery,
            StandardPointLightComponent standardPointLightComponent)
        {
            if (editorQuery.Mode != EditorQueryMode.BakingSchema)
            {
                RegisterComponent(standardPointLightComponent);

                editorQuery.MapTransform(this, Transform.Assign);
                editorQuery.MapCustom(this, "diffuse", "diffuse", x => standardPointLightComponent.LightColor             = x, Color.White);
                editorQuery.MapCustom(this, "attenuation", "attenuation", x => standardPointLightComponent.LightIntensity = x.Length(), Vector3.UnitY);
                editorQuery.MapCustom(this, "range", "range", x => standardPointLightComponent.LightRadius = x, 1f);
            }
        }
예제 #4
0
        public EntityGroup(INode node, IEditorQuery <EntityGroup> editorQuery)
        {
            _node     = node;
            Transform = new DefaultTransform();

            // EditorGroup is used to represent game groups in the editor
            // and we need to map the transform to this object.
            if (editorQuery.Mode == EditorQueryMode.LoadingConfiguration)
            {
                editorQuery.MapTransform(this, x => this.Transform.Assign(x));

                _node.ChildrenChanged    += ChildrenChanged;
                _node.DescendantsChanged += DescendantsChanged;
                ChildrenChanged(null, null);
                DescendantsChanged(null, null);
            }
        }
예제 #5
0
        public LocatorEntity(
            IEditorQuery <LocatorEntity> editorQuery,
            IAssetManagerProvider assetManagerProvider,
            Render3DModelComponent modelComponent)
        {
            if (editorQuery.Mode != EditorQueryMode.BakingSchema)
            {
                _modelComponent = modelComponent;
                RegisterComponent(_modelComponent);

                var assetManager = assetManagerProvider.GetAssetManager();
                editorQuery.MapTransform(this, Transform.Assign);

                var modelUri = editorQuery.GetRawResourceUris().FirstOrDefault();
                if (modelUri != null)
                {
                    var extIndex = modelUri.LastIndexOf(".", StringComparison.InvariantCulture);
                    if (extIndex != -1)
                    {
                        modelUri = modelUri.Substring(0, extIndex);
                    }
                    var pathComponents = modelUri.Split('/').ToList();
                    while (pathComponents[0] == "..")
                    {
                        pathComponents.RemoveAt(0);
                    }

                    while (pathComponents.Count > 0)
                    {
                        var attemptAsset = string.Join(".", pathComponents);
                        var resultAsset  = assetManager.TryGet <ModelAsset>(attemptAsset);
                        if (resultAsset == null)
                        {
                            pathComponents.RemoveAt(0);
                        }
                        else
                        {
                            _modelComponent.Model = resultAsset;
                            break;
                        }
                    }
                }
            }
        }