public void Update_with_runner_Should_call_update() { using SystemRunner <int> runner = new SystemRunner <int>(2); using World world = new World(3); Entity entity1 = world.CreateEntity(); entity1.Set <bool>(); Entity entity2 = world.CreateEntity(); entity2.Set <bool>(); Entity entity3 = world.CreateEntity(); entity3.Set <bool>(); using (ISystem <int> system = new System(world, runner)) { system.Update(0); } Check.That(entity1.Get <bool>()).IsTrue(); Check.That(entity2.Get <bool>()).IsTrue(); Check.That(entity3.Get <bool>()).IsTrue(); }
public DefaultGame() { _deviceManager = new GraphicsDeviceManager(this); IsFixedTimeStep = true; _deviceManager.GraphicsProfile = GraphicsProfile.HiDef; _deviceManager.IsFullScreen = false; _deviceManager.PreferredBackBufferWidth = 800; _deviceManager.PreferredBackBufferHeight = 600; _deviceManager.ApplyChanges(); GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; GraphicsDevice.BlendState = BlendState.AlphaBlend; Content.RootDirectory = "Content"; _batch = new SpriteBatch(GraphicsDevice); using (Stream stream = File.OpenRead(@"Content\square.png")) { _square = Texture2D.FromStream(GraphicsDevice, stream); } _breakSound = Content.Load <SoundEffect>("Slap"); _bounceSound = Content.Load <SoundEffect>("Jump"); _world = new World(1000); _runner = new SystemRunner <float>(Environment.ProcessorCount); _system = new SequentialSystem <float>( new GameSystem(_world), new PlayerSystem(Window, _world), new BallToBarSystem(Window, _world), new VelocitySystem(_world, _runner), new CollisionSystem(_world), new BallBoundSystem(_world), new PositionSystem(_world, _runner), new DrawSystem(_batch, _square, _world)); _world.Subscribe(this); Level1.CreatePlayer(_world); }
public void Update_with_runner_Should_call_update_on_all_systems() { bool done1 = false; bool done2 = false; bool done3 = false; bool done4 = false; using (SystemRunner <int> runner = new SystemRunner <int>(2)) using (ISystem <int> system = new ParallelSystem <int>( runner, new ActionSystem <int>(_ => done1 = true), new ActionSystem <int>(_ => done2 = true), new ActionSystem <int>(_ => done3 = true), new ActionSystem <int>(_ => done4 = true))) { system.Update(0); } Check.That(done1).IsTrue(); Check.That(done2).IsTrue(); Check.That(done3).IsTrue(); Check.That(done4).IsTrue(); }
public void Setup() { _defaultWorld = new DefaultWorld(EntityCount); _defaultEntitySet = _defaultWorld.GetEntities().With <DefaultComponent>().Build(); _defaultSystem = new DefaultEcsSystem(_defaultWorld); _defaultRunner = new SystemRunner <int>(Environment.ProcessorCount); _defaultMultiSystem = new DefaultEcsSystem(_defaultWorld, _defaultRunner); _defaultComponentSystem = new DefaultEcsComponentSystem(_defaultWorld); _defaultComponentMultiSystem = new DefaultEcsComponentSystem(_defaultWorld, _defaultRunner); _entitasWorld = new Context <EntitasEntity>(1, () => new EntitasEntity()); _entitasSystem = new EntitasSystem(_entitasWorld); _entitasMultiSystem = new EntitasSystem(_entitasWorld, Environment.ProcessorCount); for (int i = 0; i < EntityCount; ++i) { DefaultEntity defaultEntity = _defaultWorld.CreateEntity(); defaultEntity.Set <DefaultComponent>(); EntitasEntity entitasEntity = _entitasWorld.CreateEntity(); entitasEntity.AddComponent(0, new EntitasComponent()); } }
private async void btnSim_Click(object sender, EventArgs e) { if (_currentSimSystemDef == null) { _msgDisplay.Error("System definition not loaded."); return; } edtSimDataLog.Clear(); while (tcSimulationCharts.TabCount > 2) { tcSimulationCharts.TabPages.RemoveAt(tcSimulationCharts.TabCount - 1); } paramsSim.SaveParams(_currentSimSystemDef.SystemParams); //using (var frm = new FormLongLastingWork()) // await frm.Execute("Processing simulation...", "Simulation error", () => // { // _currentSimSystemState = new SystemState() { InitialCash = (float)edtInitialCash.Value, Cash = (float)edtInitialCash.Value }; // SystemRunner runner = new SystemRunner(_dataProvider, _systemDataLoader); // runner.Run(_currentSimSystemDef, _currentSimSystemState, dtpSimFrom.Value.Date, dtpSimTo.Value.Date); // _currentSimSystemSummary = SystemStateSummaryCalculator.Calculate(_currentSimSystemState); // //ShowSimulationResult(_currentSimSystemState, _currentSimSystemSummary); // }); //ShowSimulationResult(_currentSimSystemState, _currentSimSystemSummary); _currentSimSystemState = new SystemState() { InitialCash = (float)edtInitialCash.Value, Cash = (float)edtInitialCash.Value }; SystemRunner runner = new SystemRunner(_dataProvider, _systemDataLoader); runner.Run(_currentSimSystemDef, _currentSimSystemState, dtpSimFrom.Value.Date, dtpSimTo.Value.Date); _currentSimSystemSummary = SystemStateSummaryCalculator.Calculate(_currentSimSystemState); ShowSimulationResult(_currentSimSystemState, _currentSimSystemSummary); }
public VelocitySystem(World world, SystemRunner <float> runner) : base(world.GetEntities().With <Velocity>().With <Position>().Build(), runner) { }
public TestSystem(World world, SystemRunner <float> runner) : base(world.GetEntities().With <Position>().With <Speed>().Build(), runner) { }
public AISystem(World world, SystemRunner <float> runner) : base(world.GetEntities().With <PositionFloat>().With <TargetPosition>().With <Speed>().Build(), runner) { _random = new ThreadLocal <Random>(() => new Random()); }
public DefaultEcsSystem(DefaultWorld world, SystemRunner <int> runner) : base(world.GetEntities().With <DefaultComponent>().Build(), runner) { }
public PositionSystem(World world, SystemRunner <float> runner) : base(world.GetEntities().WhenAdded <Position>().WhenChanged <Position>().With <DrawInfo>().Build(), runner) { }
/// <summary> /// Initialise a new instance of the <see cref="ASystem{T}"/> class with the given <see cref="SystemRunner{T}"/>. /// </summary> /// <param name="runner">The <see cref="SystemRunner{T}"/> used to process the update in parallel if not null.</param> protected ASystem(SystemRunner <T> runner) { _runner = runner ?? SystemRunner <T> .Default; IsEnabled = true; }
public VelocitySystem(World world, SystemRunner <float> runner) : base(world, runner) { }
public DefaultEcsSystem(DefaultWorld world, SystemRunner <float> runner) : base(world.GetEntities().With <DefaultSpeed>().With <DefaultPosition>().Build(), runner) { }
public PositionSystem(World world, SystemRunner <float> runner) : base(world, runner) { }
public DefaultEcsComponentSystem(DefaultWorld world, SystemRunner <int> runner) : base(world, runner) { }
public System(EntitySet set, SystemRunner <int> runner) : base(set, runner) { }
public System(World world, SystemRunner <int> runner) : base(world, runner) { }
protected ASystem(SystemRunner <TState> runner) { this.runner = runner ?? SystemRunner <TState> .Default; }