当前位置: 首页>>代码示例>>C#>>正文


C# EntityManager.Add方法代码示例

本文整理汇总了C#中EntityManager.Add方法的典型用法代码示例。如果您正苦于以下问题:C# EntityManager.Add方法的具体用法?C# EntityManager.Add怎么用?C# EntityManager.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntityManager的用法示例。


在下文中一共展示了EntityManager.Add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnLoad

        protected override void OnLoad(EventArgs e)
        {
            StartJobThread();
            StartJobThread();
            StartJobThread();
            StartJobThread();
            StartJobThread();
            StartJobThread();
            StartJobThread();
            StartJobThread();

            _stopwatch = new Stopwatch();
            _stopwatch.Start();

            _keyboardInputObservable.SubscribeKey(KeyCombination.LeftAlt && KeyCombination.Enter, CombinationDirection.Down, ToggleFullScren);

            _keyboardInputObservable.SubscribeKey(KeyCombination.Esc, CombinationDirection.Down, Exit);
            _keyboardInputObservable.SubscribeKey(KeyCombination.P, CombinationDirection.Down, () => _camera.Projection = ProjectionMode.Perspective);
            _keyboardInputObservable.SubscribeKey(KeyCombination.O, CombinationDirection.Down, () => _camera.Projection = ProjectionMode.Orthographic);
            _keyboardInputObservable.SubscribeKey(KeyCombination.F, CombinationDirection.Down, () => _synchronizeCameras = !_synchronizeCameras);

            _entityManager = new EntityManager();

            var terrainSystem = new TerrainSystem(FractalBrownianMotionSettings.Default);
            _systems = new List<IEntitySystem>
            {
                terrainSystem,
                new FreeCameraSystem(_keyboardInputProcessor, _mouseInputProcessor,_camera),
                new LightMoverSystem(),
                new OceanSystem(),
                new CubeMeshSystem(),
                new InputSystem(_keyboardInputProcessor)
                //new ChunkedLODSystem(_lodCamera),
                //new RenderSystem(_camera),
            };

            var light = new Entity(Guid.NewGuid().ToString());
            _entityManager.Add(light);
            _entityManager.AddComponentToEntity(light, new PositionalLightComponent { Position = new Vector3d(0, 20, 0) });
            _entityManager.AddComponentToEntity(light, new InputComponent(Key.J, Key.L, Key.M, Key.N, Key.U, Key.I));

            const int numberOfChunksX = 20;
            const int numberOfChunksY = 20;
            for (var i = 0; i < numberOfChunksX; i++)
            {
                for (var j = 0; j < numberOfChunksY; j++)
                {
                    var entity = new Entity(Guid.NewGuid().ToString());
                    _entityManager.Add(entity);
                    _entityManager.AddComponentToEntity(entity, new ChunkComponent(i, j));
                    _entityManager.AddComponentToEntity(entity, new StaticMesh());
                }
            }

            var settingsViewModel = new SettingsViewModel(new NoiseFactory.NoiseParameters());
            settingsViewModel.SettingsChanged += () =>
            {
                var settings = settingsViewModel.Assemble();
                terrainSystem.SetTerrainSettings(new NoiseFactory.RidgedMultiFractal().Create(settings));
            };

            _terrain = new Terrain(new ChunkedLod());
            _cube = new Cube();
        }
开发者ID:smoothdeveloper,项目名称:ProceduralGeneration,代码行数:64,代码来源:OpenGlWindow.cs

示例2: CreateNode

        private Node CreateNode(Box3D bounds, int level, EntityManager entityManager)
        {
            var mesh = MeshCreator.CreateXZGrid(10, 10);
            var staticMesh = new StaticMesh
            {
                Color = new Vector4(0f, 0f, 1f, 1f),
                ModelMatrix = Matrix4.Identity,
            };

            var size = bounds.Max - bounds.Min;
            var mesh3V3N = mesh.Transformed(Matrix4.CreateScale((float)size.X, 1, (float)size.Z) * Matrix4.CreateTranslation((Vector3)bounds.Center));
            var improvedPerlinNoise = new ImprovedPerlinNoise(4711);
            for (int i = 0; i < mesh3V3N.Vertices.Length; i++)
            {
                var vertex = mesh3V3N.Vertices[i];
                var height = improvedPerlinNoise.Noise(vertex.Position.X, vertex.Position.Z) * 0.2;
                mesh3V3N.Vertices[i] = new Vertex3V3N
                {
                    Normal = new Vector3(0, 1, 0),
                    Position = new Vector3(vertex.Position.X, (float)height, vertex.Position.Z)
                };
            }

            staticMesh.Update(mesh3V3N);

            var entity = new Entity(Guid.NewGuid().ToString());
            entityManager.Add(entity);
            entityManager.AddComponentToEntity(entity, staticMesh);

            if (level == 0)
            {
                return new Node(bounds, new Node[] { }, entity, 1);
            }

            var min = bounds.Min;
            var max = bounds.Max;
            var center = bounds.Center;

            return new Node(bounds,
                new[]
                {
                    CreateNode(new Box3D(bounds.Min, center), level -1, entityManager),
                    CreateNode(new Box3D(new Vector3d(center.X, 0, min.Z), new Vector3d(max.X, 0, center.Z)), level -1, entityManager),
                    CreateNode(new Box3D(new Vector3d(min.X, 0, center.Z), new Vector3d(center.X, 0, max.Z)), level - 1, entityManager),
                    CreateNode(new Box3D(center, max), level - 1, entityManager)
                }, entity, Math.Pow(2, level));
        }
开发者ID:smoothdeveloper,项目名称:ProceduralGeneration,代码行数:47,代码来源:ChunkedLODSystem.cs

示例3: Main

        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Syntax: ImportBatchCreator filepath");
                return;
            }
            var filePath = args[0];
            var em = new EntityManager("RichardK", "RichardK");
            var objects = new List<Object>();
            foreach (var line in File.ReadLines(filePath))
            {
                var pieces = new String[0];
                if (line != null)
                    pieces = line.Split(',');
                if (pieces.Length < 3)
                {
                    Console.WriteLine("Line not valid: " + line);
                    return;
                }
                var comboOrder = BuildComboOrder(pieces[0], Decimal.Parse(pieces[1]), pieces[2]);
                objects.Add(comboOrder);
            }

            var batchName = String.Format(CultureInfo.CurrentCulture, "Import batch {0}.xml", DateTime.Now.ToString("s", CultureInfo.CurrentCulture).Replace(':', '-'));
            var batch = new ImportBatchData { Batch = objects, Name = batchName };
            var addResults = em.Add(batch);
            if (!addResults.IsValid)
                Console.WriteLine("Results not valid: " + addResults.ValidationResults.Summary);
            else
                Console.WriteLine("Import batch created.");
        }
开发者ID:Advsol,项目名称:RiSE-SDK-Examples,代码行数:32,代码来源:ImportBatchCreator.cs

示例4: CreateColumn

        /// <summary>
        /// Creates a new column with recycled components.
        /// </summary>
        /// <param name="column">The column.</param>
        /// <param name="zPosition">The z position.</param>
        /// <returns></returns>
        public Entity CreateColumn(Column column, float zPosition, EntityManager eManager)
        {
            Entity entityColumn = null;

            // Column Cache
            if (this.columnCache.Count > 0)
            {
                entityColumn = this.columnCache.Dequeue();
            }
            else
            {
                entityColumn = new Entity()
                    {
                        Tag = COLUMNTAG
                    }
                    .AddComponent(new Transform3D());

                eManager.Add(entityColumn);
            }

            var transform = entityColumn.FindComponent<Transform3D>();
            Vector3 positiontemp = transform.Position;
            positiontemp.Z = zPosition;
            transform.Position = positiontemp;
            entityColumn.IsVisible = true;

            // column element iteration to block entity Creation
            for (int i = 0; i < column.Count; i++)
            {
                var position = new Vector3(0, i * this.Scale.Z, 0);
                Color color = Color.Black;

                switch (column[i])
                {
                    case BlockTypeEnum.GROUND:
                        color = Color.WhiteSmoke;
                        break;
                    case BlockTypeEnum.BOX:
                        color = Color.BlueViolet;
                        break;
                    case BlockTypeEnum.PYRAMID:
                        color = Color.Red;
                        break;
                    case BlockTypeEnum.SPEEDERBLOCK:
                        color = Color.Yellow;
                        break;
                    case BlockTypeEnum.EMPTY:
                    default:
                        break;
                }

                // add child to column
                if (column[i] != BlockTypeEnum.EMPTY)
                {
                    entityColumn.AddChild(this.CreateBlock(position, color, this.Scale, column[i]));
                }
            }

            return entityColumn;
        }
开发者ID:gergy008,项目名称:QuickStarters,代码行数:66,代码来源:ModelFactoryService.cs


注:本文中的EntityManager.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。