Beispiel #1
0
        protected override void ApplicationStarted()
        {
            var defaultPool = EntityCollectionManager.GetCollection();
            var entity      = defaultPool.CreateEntity();

            entity.AddComponent <SayHelloWorldComponent>();
        }
Beispiel #2
0
        protected override void ApplicationStarted()
        {
            var defaultPool = EntityCollectionManager.GetCollection();
            var viewEntity  = defaultPool.CreateEntity();

            viewEntity.AddComponents(new CustomViewComponent(), new PlayerControlledComponent(), new CameraFollowsComponent());
        }
Beispiel #3
0
        protected override void ApplicationStarted()
        {
            _componentTypeLookup          = Container.Resolve <IComponentTypeLookup>();
            _componentDatabase            = Container.Resolve <IComponentDatabase>();
            _batchBuilderFactory          = Container.Resolve <IBatchBuilderFactory>();
            _referenceBatchBuilderFactory = Container.Resolve <IReferenceBatchBuilderFactory>();
            _collection = EntityCollectionManager.GetCollection();

            ClassComponent1TypeId  = _componentTypeLookup.GetComponentType(typeof(ClassComponent));
            ClassComponent2TypeId  = _componentTypeLookup.GetComponentType(typeof(ClassComponent2));
            StructComponent1TypeId = _componentTypeLookup.GetComponentType(typeof(StructComponent));
            StructComponent2TypeId = _componentTypeLookup.GetComponentType(typeof(StructComponent2));

            var name = GetType().Name;

            Console.WriteLine($"{name} - {Description}");
            var timer = Stopwatch.StartNew();

            SetupEntities();
            timer.Stop();
            Console.WriteLine($"{name} - Setting up {EntityCount} entities in {timer.ElapsedMilliseconds}ms");

            timer.Reset();
            timer.Start();
            for (var update = 0; update < SimulatedUpdates; update++)
            {
                RunProcess();
            }
            timer.Stop();
            var totalProcessTime = TimeSpan.FromMilliseconds(timer.ElapsedMilliseconds);

            Console.WriteLine($"{name} - Simulating {SimulatedUpdates} updates - Processing {EntityCount} entities in {totalProcessTime.TotalMilliseconds}ms");
            Console.WriteLine();
        }
Beispiel #4
0
        protected override void ApplicationStarted()
        {
            var defaultPool = EntityCollectionManager.GetCollection();

            defaultPool.CreateEntity(new PlayerBlueprint("Player One"));
            defaultPool.CreateEntity(new PlayerBlueprint("Player Two", 150.0f));
        }
Beispiel #5
0
        //protected override void StartSystems()
        //{
        //    this.BindAllSystemsWithinApplicationScope();
        //    this.StartAllBoundSystems();
        //}

        protected override void ApplicationStarted()
        {
            defaultCollection = EntityCollectionManager.GetCollection();

            var levelBlueprint  = new LevelBlueprint();
            var levelEntity     = defaultCollection.CreateEntity(levelBlueprint);
            var player          = defaultCollection.CreateEntity(new PlayerBlueprint(_gameConfiguration.StartingFoodPoints));
            var playerView      = player.GetComponent <ViewComponent>();
            var playerComponent = player.GetComponent <PlayerComponent>();
            var levelComponent  = levelEntity.GetComponent <LevelComponent>();

            levelComponent.Level.DistinctUntilChanged()
            .Subscribe(x =>
            {
                var gameObject = playerView.View as GameObject;
                gameObject.transform.position = Vector3.zero;
                SetupLevel(levelComponent);
            });

            EventSystem.Receive <PlayerKilledEvent>()
            .Delay(TimeSpan.FromSeconds(_gameConfiguration.IntroLength))
            .Subscribe(x =>
            {
                levelBlueprint.UpdateLevel(levelComponent, 1);
                playerComponent.Food.Value = _gameConfiguration.StartingFoodPoints;
                SetupLevel(levelComponent);
            });
        }
Beispiel #6
0
        protected override void ApplicationStarted()
        {
            var defaultPool = EntityCollectionManager.GetCollection();
            var entity      = defaultPool.CreateEntity();

            entity.AddComponents(new ViewComponent());
        }
Beispiel #7
0
        protected override void ApplicationStarted()
        {
            var defaultPool = EntityCollectionManager.GetCollection();

            _enemy = defaultPool.CreateEntity(new EnemyBlueprint(100));

            HandleInput();
        }
Beispiel #8
0
        protected override void ApplicationStarted()
        {
            var defaultPool = EntityCollectionManager.GetCollection();
            var entity      = defaultPool.CreateEntity();

            var existingGameObject = GameObject.Find("ExistingGameObject");

            existingGameObject.LinkEntity(entity, defaultPool);
        }
Beispiel #9
0
        protected override void ApplicationStarted()
        {
            var collection = EntityCollectionManager.GetCollection();

            for (var i = 0; i < _cubeCount; i++)
            {
                var viewEntity = collection.CreateEntity();
                viewEntity.AddComponents(new ViewComponent(), new RandomColorComponent());
            }
        }
Beispiel #10
0
        protected override void ApplicationStarted()
        {
            var defaultPool = EntityCollectionManager.GetCollection();

            // create 5k entities
            for (var i = 0; i < 4000; i++)
            {
                var entity = defaultPool.CreateEntity();

                entity.AddComponents(new Component1(), new Component2(), new Component3());
            }
        }
Beispiel #11
0
        protected override void ApplicationStarted()
        {
            var collection = EntityCollectionManager.GetCollection();
            var entity     = collection.CreateEntity();

            var helloComponent = new SayHelloComponent
            {
                Name = "Bob"
            };

            entity.AddComponent(helloComponent);
        }
        protected override void ApplicationStarted()
        {
            var defaultPool = EntityCollectionManager.GetCollection();
            var entity      = defaultPool.CreateEntity();

            var canTalkComponent = new CanTalkComponent {
                Message = "Hello world"
            };

            entity.AddComponents(canTalkComponent);

            HandleInput();
        }
        protected override void ApplicationStarted()
        {
            var blueprint = new MoveableBlueprint();

            var defaultPool = EntityCollectionManager.GetCollection();

            for (var i = 0; i < _entityCount; i++)
            {
                defaultPool.CreateEntity(blueprint);
            }

            HandleInput();
        }
Beispiel #14
0
        protected override void ApplicationStarted()
        {
            var collection = EntityCollectionManager.GetCollection();

            for (var i = 0; i < _cubeCount; i++)
            {
                var viewEntity = collection.CreateEntity();
                viewEntity.AddComponents(new ViewComponent(), new RandomColorComponent());
            }

            var group = EntityCollectionManager.GetObservableGroup(new Group(typeof(ViewComponent), typeof(RandomColorComponent)));

            Debug.Log($"There are {group.Count} entities out of {collection.Count} matching");
        }
Beispiel #15
0
        protected override void ApplicationStarted()
        {
            _collection = EntityCollectionManager.GetCollection();
            _system     = new ExampleReactToGroupSystem();

            for (var i = 0; i < EntityCount; i++)
            {
                var entity = _collection.CreateEntity();
                entity.AddComponents(new SimpleReadComponent(), new SimpleWriteComponent());
            }

            RunSingleThread();
            RunMultiThreaded();
        }
Beispiel #16
0
        protected override void ApplicationStarted()
        {
            var entityCollection = EntityCollectionManager.GetCollection();

            var cubeEntity = entityCollection.CreateEntity();

            cubeEntity.AddComponent <ViewComponent>();
            cubeEntity.AddComponent <CubeComponent>();

            var sphereEntity = entityCollection.CreateEntity();

            sphereEntity.AddComponent <ViewComponent>();
            sphereEntity.AddComponent <SphereComponent>();
        }
        protected override void ApplicationStarted()
        {
            var defaultPool = EntityCollectionManager.GetCollection();

            defaultPool.CreateEntity(new CharacterBlueprint("Bob", 200));
            defaultPool.CreateEntity(new CharacterBlueprint("Tom", 150));
            defaultPool.CreateEntity(new CharacterBlueprint("Rolf", 150));
            defaultPool.CreateEntity(new CharacterBlueprint("Mez", 100));
            defaultPool.CreateEntity(new CharacterBlueprint("TP", 1000));
            defaultPool.CreateEntity(new CharacterBlueprint("MasterChief", 100));
            defaultPool.CreateEntity(new CharacterBlueprint("Weakling", 20));

            HandleInput();
        }
Beispiel #18
0
        protected override void ApplicationStarted()
        {
            Observable.Start(() =>
            {
                var defaultPool = EntityCollectionManager.GetCollection();

                // create 5k entities
                for (var i = 0; i < 50000; i++)
                {
                    var entity = defaultPool.CreateEntity();

                    entity.AddComponents(new Component1(), new Component2(), new Component3());
                }
            }, EcsScheduler.EventLoopScheduler);
        }
Beispiel #19
0
        protected override void ApplicationStarted()
        {
            var collection = EntityCollectionManager.GetCollection();


            var stopwatch = new Stopwatch();

            stopwatch.Start();
            for (var i = 0; i < EntityCount; i++)
            {
                var entity = collection.CreateEntity();
                entity.AddComponents(new SimpleReadComponent(), new SimpleWriteComponent());
            }
            stopwatch.Stop();
            Console.WriteLine($"Finished In: {stopwatch.ElapsedMilliseconds}ms");
        }
Beispiel #20
0
        protected override IDependencyContainer DependencyContainer => new NinjectDependencyContainer();//throw new NotImplementedException();

        protected override void ApplicationStarted()
        {
            RegisterAllBoundSystems();
            var defaultPool = EntityCollectionManager.GetCollection();
            var _enemy      = defaultPool.CreateEntity();

            _enemy.AddComponent <mjsg.CS_Script>();

            ReadAllSettings();

            Console.Title = ConfigurationManager.AppSettings["Name"];

            //LogManager.Configuration = new XmlLoggingConfiguration("NLog.config");

            ////            var config = LogManager.Configuration;// new LoggingConfiguration();



            //var consoleTarget = new ColoredConsoleTarget("target12")
            //{
            //    Layout = @"${date:format=HH\:mm\:ss} ${level} ${message} ${exception}"
            //};
            //LogManager.Configuration.AddTarget(consoleTarget);
            ////var fileTarget = new FileTarget("target2")
            ////{
            ////    FileName = "${basedir}/file.txt",
            ////    Layout = "${longdate} ${level} ${message}  ${exception}"
            ////};
            ////config.AddTarget(fileTarget);

            ////config.AddRuleForOneLevel(LogLevel.Error, fileTarget); // only errors to file
            //LogManager.Configuration.AddRuleForAllLevels(consoleTarget); // all to console
            ////LogManager.Configuration = config;
            //Logger logger = LogManager.GetLogger("Name.Space.Class2");
            //logger.Trace("trace log message");
            //logger.Debug("debug log message");
            //logger.Info("info log message");
            //logger.Warn("warn log message");
            //logger.Error(CharFormat);
            //logger.Fatal(fas);
            // TNet.Log.TraceLog.WriteError("fafa");
            TNet.Log.TraceLog.WriteInfo(CharFormat);
            ConsoleColor currentForeColor = Console.BackgroundColor;
            //  SetColor(ConsoleColor.Cyan);

            //    SetColor(currentForeColor);
        }
        private TimeSpan ProcesEntities(int amount)
        {
            var defaultPool = EntityCollectionManager.GetCollection();

            EntityCollectionManager.Pools.ForEachRun(x => x.RemoveAllEntities());
            var startTime = DateTime.Now;

            for (var i = 0; i < amount; i++)
            {
                var entity = defaultPool.CreateEntity();
                entity.AddComponents(_availableComponents);
                entity.RemoveComponents(_availableComponents);
            }

            var endTime = DateTime.Now;

            return(endTime - startTime);
        }
        private TimeSpan ProcessEntities(int amount)
        {
            var defaultPool = EntityCollectionManager.GetCollection();

            EntityCollectionManager.Collections.ForEachRun(x => x.RemoveAllEntities());
            GC.Collect();

            var timer = Stopwatch.StartNew();

            for (var i = 0; i < amount; i++)
            {
                var entity = defaultPool.CreateEntity();
                entity.AddComponents(_availableComponents);
                entity.RemoveComponents(_availableComponentTypeIds);
            }

            timer.Stop();
            return(TimeSpan.FromMilliseconds(timer.ElapsedMilliseconds));
        }
Beispiel #23
0
        protected override void ApplicationStarted()
        {
            const string enemiesCollectionName = "enemies";

            var enemiesCollection = EntityCollectionManager.CreateCollection(enemiesCollectionName);
            var enemiesGroup      = EntityCollectionManager.GetObservableGroup(new Group(typeof(MoveComponent)), enemiesCollectionName);
            var temp = EntityCollectionManager.GetObservableGroup(new Group(typeof(DrawEnemyComponent)), enemiesCollectionName);

            Executor.AddSystem(new GameUpdateSystem(EventSystem));
            Executor.AddSystem(new NewEnemyWaveWarningSystem(EventSystem, TimeSpan.FromSeconds(20.0d)));
            Executor.AddSystem(new DisplayWaveWarningSystem(EventSystem));
            Executor.AddSystem(new NewEnemyWaveEmitterSystem(EventSystem, enemiesCollection));
            Executor.AddSystem(new EnemyMoveSystem(enemiesGroup));
            Executor.AddSystem(new EnemyDrawSystem(EventSystem, temp));

            this.StartAllBoundSystems();

            var manager = EntityCollectionManager.GetCollection();
            var game    = manager.CreateEntity();

            GameComponent = game.AddComponent <GameComponent>();
        }
Beispiel #24
0
        protected override void ApplicationStarted()
        {
            var namedHealthGroup    = EntityCollectionManager.GetObservableGroup(new Group(typeof(HasHealthComponent), typeof(HasNameComponent)));
            var computedGroup       = new LowestHealthComputedGroup(namedHealthGroup);
            var displayHealthSystem = new DisplayLowestHealthSystem(computedGroup);

            SystemExecutor.AddSystem(displayHealthSystem);

            this.StartAllBoundSystems();

            var defaultPool = EntityCollectionManager.GetCollection();

            defaultPool.CreateEntity(new CharacterBlueprint("Bob", 200));
            defaultPool.CreateEntity(new CharacterBlueprint("Tom", 150));
            defaultPool.CreateEntity(new CharacterBlueprint("Rolf", 150));
            defaultPool.CreateEntity(new CharacterBlueprint("Mez", 100));
            defaultPool.CreateEntity(new CharacterBlueprint("TP", 1000));
            defaultPool.CreateEntity(new CharacterBlueprint("MasterChief", 100));
            defaultPool.CreateEntity(new CharacterBlueprint("Weakling", 20));

            HandleInput();
        }
        protected override void ApplicationStarted()
        {
            var defaultCollection = EntityCollectionManager.GetCollection();

            var shipEntity = defaultCollection.CreateEntity(new ShipBlueprint());
        }