public override void Shoot(UpdateContext updateContext, EntityWorld entityWorld, Entity playerEntity) { float boosterAttackSpeedMultiplier = BoosterHelper.GetPlayerAttackSpeedMultiplier(entityWorld.Services.Get<IBoosterState>()); float passiveAttackSpeedMultiplier = entityWorld.Services.Get<IPlayerPassiveStats>().FireRateMultiplier; float attackSpeedMultiplier = boosterAttackSpeedMultiplier * passiveAttackSpeedMultiplier; if (this.CanShoot) { _ammoRemaining -= updateContext.DeltaSeconds * attackSpeedMultiplier * Laser.AmmoUsedPerSecond; if (_ammoRemaining < 0) { _ammoRemaining = 0; } this.LaserSegment = this.GetLaserSegment(playerEntity.Transform, entityWorld); IZombieSpatialMap zombieSpatialMap = entityWorld.Services.Get<IZombieSpatialMap>(); foreach (Entity zombie in zombieSpatialMap.GetAllIntersecting(this.LaserSegment, Laser.MaxHitDistance)) { if (zombie.Get<CHealth>().IsAlive && ZombieHelper.TakeDamage(zombie, Laser.DamagePerSecond * attackSpeedMultiplier * updateContext.DeltaSeconds, null)) { ZombieHelper.TriggerBloodExplosion(zombie.Transform, this.LaserSegment.Direction * SkypieaConstants.PixelsPerMeter * 10f); } } this.IsShooting = true; } else { this.IsShooting = false; } }
public ScoreTracker(AchievementManager achievementManager, EntityWorld entityWorld, string achievementName, int scoreTarget) : base(achievementManager, entityWorld, achievementName) { Ensure.Is<BooleanProgression>(_achievement.Progression); _scoreTarget = scoreTarget; _playerInfo = entityWorld.FindEntityByName(EntityNames.Player).Get<CPlayerInfo>(); }
protected override void BuildEntity(EntityWorld entityWorld, Entity entity, ParameterCollection parameters) { entity.Transform.Position = parameters.Get<Vector2>(0); entity.AddFromPool<CDrop>().Initialize(DropType.BlackBox); entity.AddFromPool<CLifeTime>().Initialize(100f); entity.Tag = EntityTags.Drop; }
public LivesAtAnyPointOfGameTracker(AchievementManager achievementManager, EntityWorld entityWorld, string achievementName, int lives) : base(achievementManager, entityWorld, achievementName) { Ensure.Is<BooleanProgression>(_achievement.Progression); _lives = lives; _playerInfo = entityWorld.FindEntityByName(EntityNames.Player).Get<CPlayerInfo>(); }
protected override void ShootInner(UpdateContext updateContext, EntityWorld entityWorld, Entity playerEntity) { const float AngleOffset = 0.125f; entityWorld.CreateEntityFromPrefab<BouncerBulletPrefab>(playerEntity.Transform, this, -AngleOffset); entityWorld.CreateEntityFromPrefab<BouncerBulletPrefab>(playerEntity.Transform, this, AngleOffset); this.DecreaseBulletCount(); }
public RealProject(string name) { Name = name; Files = new List<FileInfo>(); Scene = new EntityWorld(); Saved = false; }
/// <summary> /// Creates a new GroupManager instance in the provided <see cref="EntityWorld"/>. /// </summary> /// <param name="world">The <see cref="EntityWorld"/> instance in which the manager will be created.</param> public GroupManager(EntityWorld world) { _world = world; _emptyBag = new List<Entity>(); _entitiesByGroup = new Dictionary<string, Dictionary<int, Entity>>(); _groupsByEntity = new Dictionary<int, string>(); }
public EntityTrackerManager(EntityWorld entityWorld) { _entityWorld = entityWorld; _entityWorld.EntityAdded += this.OnEntityAdded; // .. _entityWorld.EntityChanged += this.OnEntityChanged; // .. _entityWorld.EntityRemoved += this.OnEntityRemoved; // .. }
public override sealed void Shoot(UpdateContext updateContext, EntityWorld entityWorld, Entity playerEntity) { if (this.CanShoot && !this.IsFinished) { this.ShootInner(updateContext, entityWorld, playerEntity); _bulletTimer.Restart(); } }
public override sealed void Update(UpdateContext updateContext, EntityWorld entityWorld) { float boosterAttackSpeedMultiplier = BoosterHelper.GetPlayerAttackSpeedMultiplier(entityWorld.Services.Get<IBoosterState>()); float passiveAttackSpeedMultiplier = entityWorld.Services.Get<IPlayerPassiveStats>().FireRateMultiplier; _bulletTimer.Update(updateContext.DeltaSeconds * boosterAttackSpeedMultiplier * passiveAttackSpeedMultiplier); this.UpdateInner(updateContext); }
public SurviveWithoutMovingTracker(AchievementManager achievementManager, EntityWorld entityWorld, string achievementName, float seconds) : base(achievementManager, entityWorld, achievementName) { Ensure.Is<BooleanProgression>(_achievement.Progression); _targetSeconds = seconds; _playerTransform = entityWorld.FindEntityByName(EntityNames.Player).Transform; _previousPosition = _playerTransform.Position; }
public PersistentRunningTracker(AchievementManager achievementManager, EntityWorld entityWorld, string achievementName) : base(achievementManager, entityWorld, achievementName) { Ensure.Is<FloatProgression>(_achievement.Progression); _progression = (FloatProgression)_achievement.Progression; _playerTransform = _entityWorld.FindEntityByName(EntityNames.Player).Transform; _previousPosition = _playerTransform.Position; }
protected override void BuildEntity(EntityWorld entityWorld, Entity entity, ParameterCollection parameters) { entity.Transform.Position = parameters.Get<Vector2>(0); entity.AddFromPool<CDrop>().Initialize(DropType.Weapon); entity.AddFromPool<CWeaponDrop>().Initialize(parameters.Get<WeaponType>(1)); entity.AddFromPool<CLifeTime>().Initialize(WeaponDropPrefab.LifeTime); entity.Tag = EntityTags.Drop; }
protected override void BuildEntity(EntityWorld entityWorld, Entity entity, ParameterCollection parameters) { entity.Transform.Position = parameters.Get<Vector2>(0); entity.AddFromPool<CRusherZombieAI>(); entity.AddFromPool<CZombieInfo>().Initialize(ZombieType.Rusher, RusherZombiePrefab.Size); entity.AddFromPool<CHealth>().Initialize(10); entity.Tag = EntityTags.Zombie; }
private World(bool isSimulation) { _entityWorld = new EntityWorld(); _particleEngine = new ParticleEngine(); _entityWorld.Services.Add<IParticleEngine>(_particleEngine); this.CreateSystems(isSimulation); }
protected override void BuildEntity(EntityWorld entityWorld, Entity entity, ParameterCollection parameters) { entity.Transform.Position = parameters.Get<Vector2>(0); entity.Add(new CPlayerInfo(2)); entity.Add<CCamera2D>(new CPlayerCamera2D()); entity.Add<CWeapon>().Weapon = WeaponFactory.CreateDefaultWeapon(); entity.Tag = EntityTags.Player; }
protected EntityRenderer(EntityWorld entityWorld, Aspect aspect) { _entityWorld = entityWorld; _entityTracker = EntityTracker.FromAspect(aspect); _entityTracker.EntityAdded += this.OnEntityAdded; _entityTracker.EntityRemoved += this.OnEntityRemoved; entityWorld.AddEntityTracker(_entityTracker); }
public PersistentKillZombiesTracker(AchievementManager achievementManager, EntityWorld entityWorld, string achievementName) : base(achievementManager, entityWorld, achievementName) { Ensure.Is<IntegerProgression>(_achievement.Progression); if (!_achievement.IsUnlocked) { entityWorld.SubscribeToMessage<ZombieKilledMessage>(this.OnZombieKilled); } }
public SurviveWithoutKillingTracker(AchievementManager achievementManager, EntityWorld entityWorld, string achievementName, float time) : base(achievementManager, entityWorld, achievementName) { Ensure.Is<BooleanProgression>(_achievement.Progression); _time = time; if (!_achievement.IsUnlocked) { entityWorld.SubscribeToMessage<ZombieKilledMessage>(this.OnZombieKilled); } }
public Entity Fetch(EntityWorld entityWorld, string name) { Entity entity = _availableEntities.RemoveLast() ?? new Entity(entityWorld, _nextEntityID++); entity.Name = name.TrimIfNotNull().NullIfEmpty(); // hmm.. should this trim? since that can cause errors if editor doesnt trim.. hmm.. entity.UniqueID = _nextUniqueID++; entity.Transform = entity.AddFromPool<DefaultTransformComponent>(); return entity; }
public RenderSystem(EntityWorld entityWorld) : base(entityWorld, new Type[] { typeof(TransformComponent), typeof(SpatialFormComponent) }, GameLoopType.Draw) { // Load entries from the blackboard. contentManager = BlackBoard.GetEntry<ContentManager>("ContentManager"); projectionMatrix = BlackBoard.GetEntry<Matrix>("ProjectionMatrix"); viewMatrix = BlackBoard.GetEntry<Matrix>("ViewMatrix"); models = new Dictionary<string, Model>(); }
public Entity BuildEntity(Entity entity, EntityWorld entityWorld, params object[] args) { entity.Group = "BULLETS"; entity.AddComponentFromPool <TransformComponent>(); entity.AddComponent(new SpatialFormComponent("Missile")); entity.AddComponent(new VelocityComponent()); entity.AddComponent(new ExpiresComponent(2000)); return(entity); }
public Entity BuildEntity(Entity entity, EntityWorld entityWorld, params object[] args) { entity.AddComponent(new Player()); AddNewPlayerInventory(entity); AddCreatureComponent(entity); AddLocationComponent(entity); AddEntityDataComponent(entity); return(entity); }
public KillEnemiesWithSingleRocket(AchievementManager achievementManager, EntityWorld entityWorld, string achievementName, int killsNeeded) : base(achievementManager, entityWorld, achievementName) { Ensure.Is<BooleanProgression>(_achievement.Progression); _killsNeeded = killsNeeded; if (!_achievement.IsUnlocked) { entityWorld.SubscribeToMessage<RocketExplodedMessage>(this.OnRocketExploded); } }
public override void Initialise() { HUD.Instance.ScreenSize = new Point(_gdm.GraphicsDevice.Viewport.Width, _gdm.GraphicsDevice.Viewport.Height); Player.Instance.SetScreen(this); this._camera = new BoundedCamera(new Vector2(_gdm.GraphicsDevice.Viewport.Width, _gdm.GraphicsDevice.Viewport.Height), new Vector2(0, 0), new PointPair(new Vector2i(-10000, -10000), new Vector2i(10000, 10000))); this._entityEngine = new EntityWorld(); EntitySystem.BlackBoard.SetEntry <BoundedCamera>("BoundedCamera", this._camera); this._entityEngine.InitializeAll(true); // ENTITIES Entity planet = this._entityEngine.CreateEntity(); planet.Group = "PLANETS"; planet.Tag = "PLANET1"; planet.AddComponent(new PositionComponent(new Vector2(100, 100))); planet.AddComponent(new RotationComponent(50, 0f, false)); planet.AddComponent(new TextureComponent(new Coord(0, 0), "blue1", new Vector2(550, 550))); //planet.AddComponent(new ShadowComponent(new Coord(1, 0), "blue1", new Vector2(266, 266))); Entity playerShip = this._entityEngine.CreateEntity(); playerShip.Group = "PLAYER"; playerShip.Tag = "PLAYER"; playerShip.AddComponent(new PositionComponent(new Vector2(50, 50))); playerShip.AddComponent(new RotationComponent(0, 2f, false)); playerShip.AddComponent(new TextureComponent(new Coord(0, 0), "ships", new Vector2(64, 64))); playerShip.AddComponent(new InertiaComponent()); playerShip.AddComponent(new PlayerControlComponent()); playerShip.AddComponent(new ThrustComponent()); playerShip.AddComponent(new NavigationComponent()); this.playerEntityID = playerShip.Id; Player.Instance.Flagship = playerShip; Entity enemyShip = this._entityEngine.CreateEntity(); enemyShip.Group = "TARGETS"; enemyShip.Tag = "ENEMY1"; enemyShip.AddComponent(new PositionComponent(new Vector2(-100, -100))); enemyShip.AddComponent(new RotationComponent(0, 2f, false)); enemyShip.AddComponent(new TextureComponent(new Coord(1, 0), "ships", new Vector2(64, 64))); enemyShip.AddComponent(new InertiaComponent()); enemyShip.AddComponent(new NavigationComponent()); enemyShip.AddComponent(new ThrustComponent()); this.Active = true; this.Initialised = true; }
/// <summary>The build entity.</summary> /// <param name="entity">The entity.</param> /// <param name="entityWorld">The entityWorld.</param> /// <param name="args">The args.</param> /// <returns>The <see cref="Entity" />.</returns> public Entity BuildEntity(Entity entity, EntityWorld entityWorld, params object[] args) { entity.AddComponentFromPool <Enchantment>(); entity.AddComponentFromPool <Team>(); entity.AddComponentFromPool <Position>(); entity.AddComponentFromPool <Appearance>(); entity.Refresh(); return(entity); }
public override void Enchant(Entity enchantment, EntityWorld entityWorld) { foreach (Entity e in entityWorld.EntityManager.GetEntities(Aspect.One(typeof(Damage)))) { if (e.GetComponent <Team>().team == enchantment.GetComponent <Team>().team) { e.GetComponent <Damage>().currentDamage = e.GetComponent <Damage>().damage + 1; e.GetComponent <Velocity>().currentMoveSpeed = e.GetComponent <Velocity>().moveSpeed + 1; } } }
public void TestRenderMultiHealthBarSystem() { Debug.WriteLine("Initialize EntityWorld: "); HealthBag.Clear(); ComponentPool.Clear(); HealthBag.Add(new TestHealthComponent()); HealthBag.Add(new TestHealthComponent()); ComponentPool.Add(typeof(TestHealthComponent), HealthBag); EntityWorld entityWorld = new EntityWorld(); entityWorld.EntityManager.RemovedComponentEvent += RemovedComponent; entityWorld.EntityManager.RemovedEntityEvent += RemovedEntity; entityWorld.SystemManager.SetSystem(new TestRenderHealthBarMultiSystem(), GameLoopType.Update); entityWorld.InitializeAll(); Debug.WriteLine("OK"); Debug.WriteLine("Fill EntityWorld with " + Load + " entities: "); List <Entity> entities = new List <Entity>(); for (int index = Load - 1; index >= 0; --index) { Entity entity = TestEntityFactory.CreateTestHealthEntity(entityWorld); entities.Add(entity); } Debug.WriteLine("OK"); const int Passes = 9; Stopwatch stopwatch = Stopwatch.StartNew(); for (int index = 0; index < Passes; ++index) { entityWorld.Update(); entityWorld.Draw(); } stopwatch.Stop(); Debug.WriteLine("Update (" + Passes + " passes) duration: {0}", FastDateTime.ToString(stopwatch.Elapsed)); int expectedPoints = 100 - (Passes * 10); if (expectedPoints < 0) { expectedPoints = 0; } int df = entities.Count(item => Math.Abs((int)(item.GetComponent <TestHealthComponent>().Points - expectedPoints)) < float.Epsilon); Assert.AreEqual(Load, df); Debug.WriteLine("Found {0} entities with health of {1}.", df, expectedPoints); }
public KillZombiesInTimeTracker(AchievementManager achievementManager, EntityWorld entityWorld, string achievementName, int count, float time) : base(achievementManager, entityWorld, achievementName) { Ensure.Is<BooleanProgression>(_achievement.Progression); // no progression because not persistent _count = count; _time = time; if (!_achievement.IsUnlocked) { entityWorld.SubscribeToMessage<ZombieKilledMessage>(this.OnZombieKilled); } }
public static void KillAllZombies(EntityWorld entityWorld) { foreach (Entity zombie in entityWorld.FindEntitiesWithTag(EntityTags.Zombie)) { if (zombie.Get<CHealth>().IsAlive && zombie.Get<CZombieInfo>().Type != ZombieType.GoldenGoblin) // meh "hard-coded" GG ignore... { ZombieHelper.Kill(zombie, Vector2.Zero); entityWorld.BroadcastMessage(entityWorld.FetchMessage<ZombieKilledMessage>().Initialize(zombie)); zombie.Delete(); } } }
public void TransferEntityStateFromOneWorldToAnother() { EntityWorld target1 = EmptyWorld(); Entity entity = target1.CreateEntity(); entity.Enabled = false; EntityWorld target2 = EmptyWorld(); target2.RestoreState(target1.GetState()); Assert.False(target2.GetEntities().First().Enabled); }
/// <summary>The build entity.</summary> /// <param name="entity">The entity.</param> /// <param name="entityWorld">The entityWorld.</param> /// <param name="args">The args.</param> /// <returns>The <see cref="Entity" />.</returns> public Entity BuildEntity(Entity entity, EntityWorld entityWorld, params object[] args) { entity.AddComponentFromPool <Position>(); entity.AddComponentFromPool <Pickupable>(); entity.GetComponent <Pickupable>().currentValue = 0.2f; entity.GetComponent <Pickupable>().maxValue = 0; entity.AddComponentFromPool <Appearance>(); entity.Refresh(); return(entity); }
public void Initialize() { world = new EntityWorld(); system = new RandomComputerSystem(); randomMock = new Mock <IRandom>(); randomMock.Setup(m => m.Next(It.IsAny <int>(), It.IsAny <int>())).Returns(2); system.Random = randomMock.Object; world.SystemManager.SetSystem(system, Artemis.Manager.GameLoopType.Update); entity = world.CreateEntity(); entity.AddComponent(new RandomComputer()); }
/// <summary>The build entity.</summary> /// <param name="entity">The entity.</param> /// <param name="entityWorld">The entityWorld.</param> /// <param name="args">The args.</param> /// <returns>The <see cref="Entity" />.</returns> public Entity BuildEntity(Entity entity, EntityWorld entityWorld, params object[] args) { entity.AddComponentFromPool <Health>(); entity.AddComponentFromPool <ScreenPosition>(); entity.AddComponentFromPool <PlatformPosition>(); entity.AddComponentFromPool <PlayerNumber>(); entity.AddComponentFromPool <Input>(); entity.Refresh(); return(entity); }
private ArmyAi PrepareArmyAi(EntityWorld entityWorld) { ArmyAi armyAi = entityWorld.GetComponentFromPool <ArmyAi>(); armyAi.DefaultDecisionThinker = new DefaultDecisionThinker(); armyAi.DecisionThinkers.Add(ArmyState.Idle, new IdleDecisionThinker()); armyAi.DecisionThinkers.Add(ArmyState.SearchForResource, new SearchForResourceDecisionThinker()); armyAi.DecisionThinkers.Add(ArmyState.SearchForStructure, new SearchForStructureDecisionThinker()); armyAi.DecisionThinkers.Add(ArmyState.SearchForEnemy, new ArmyEncounterDecisionThinker()); return(armyAi); }
public KillWithInvulnerabilityBoosterTracker(AchievementManager achievementManager, EntityWorld entityWorld, string achievementName, int count) : base(achievementManager, entityWorld, achievementName) { Ensure.Is<BooleanProgression>(_achievement.Progression); _targetKills = count; _boosterState = entityWorld.Services.Get<IBoosterState>(); if (!_achievement.IsUnlocked) { entityWorld.SubscribeToMessage<ZombieKilledMessage>(this.OnZombieKilled); } }
protected override void ShootInner(UpdateContext updateContext, EntityWorld entityWorld, Entity playerEntity) { entityWorld.CreateEntityFromPrefab<FlamethrowerBulletPrefab>(playerEntity.Transform, this); entityWorld.CreateEntityFromPrefab<FlamethrowerBulletPrefab>(playerEntity.Transform, this); _bulletCounter += 0.33333f; if (_bulletCounter > 1) { _bulletCounter -= 1; this.DecreaseBulletCount(); } }
// todo: instead of doing something like this, how about make a callback "OnCollided(Entity entity (or Vector2 position tms))" and then the weapon itself (whos callback it will be calling) decides the damage etc. this.. could be A LOT better! protected override void BuildEntity(EntityWorld entityWorld, Entity entity, ParameterCollection parameters) { const float Speed = SkypieaConstants.PixelsPerMeter * 25; CTransform2D transform = parameters.Get<CTransform2D>(0); entity.Transform.Position = transform.Position; entity.Transform.Rotation = transform.Rotation; entity.AddFromPool<CBullet>().Initialize(RocketLauncherBulletPrefab.BulletSize, parameters.Get<RocketLauncher>(1)); entity.AddFromPool<CVelocity2D>().Initialize(FlaiMath.GetAngleVector(transform.Rotation), Speed); entity.AddFromPool<CParticleEmitter2D>().Initialize(ParticleEffectID.RocketSmoke, new BurstTriggerController(0.01f, entity.Transform)); }
/// <summary>Creates the test power1 entity.</summary> /// <param name="entityWorld">The entity world.</param> /// <returns>The specified entity.</returns> public static Entity CreateTestPowerEntity(EntityWorld entityWorld) { Entity entity = entityWorld.CreateEntity(); entity.AddComponent(new TestHealthComponent()); entity.AddComponent(new TestPowerComponent()); entity.GetComponent <TestHealthComponent>().Points = 100.0f; entity.GetComponent <TestPowerComponent>().Power = 100; return(entity); }
public EntityFactory(EntityWorld entityWorld) { rnd = new Random(); this.entityWorld = entityWorld; //this.LayerManager = new LayerManager(); this.LayerManager = new BitVectorManager <string>(); this.LayerManager.Add("None"); //this.LayerManager.AddLayer(GameConfig.Spaceship.CollisionLayer); //this.LayerManager.AddLayer(GameConfig.Projectile.CollisionLayer); //this.LayerManager.AddLayer(GameConfig.Asteroid.CollisionLayer); //this.LayerManager.AddLayer(GameConfig.Border.CollisionLayer); }
/// <summary>Initializes a new instance of the <see cref="EntityManager" /> class.</summary> /// <param name="entityWorld">The entity world.</param> public EntityManager(EntityWorld entityWorld) { Debug.Assert(entityWorld != null, "EntityWorld must not be null."); this.uniqueIdToEntities = new Dictionary <long, Entity>(); this.removedAndAvailable = new Bag <Entity>(); this.componentsByType = new Bag <Bag <IComponent> >(); this.ActiveEntities = new Bag <Entity>(); this.RemovedEntitiesRetention = 100; this.entityWorld = entityWorld; this.RemovedComponentEvent += this.EntityManagerRemovedComponentEvent; }
public void TestCreateLazyRunner() { var entityWorld = new EntityWorld(false, true, false); var runner = GenericOpenHeroesRunner.CreateInstance(null, entityWorld); entityWorld.InitializeAll(true); for (int i = 0; i < 10; i++) { runner.Draw(); runner.Update(); } }
/// <summary> /// Creates a new EntityManager instance in the provided <see cref="EntityWorld"/>. /// </summary> /// <param name="world"><see cref="EntityWorld"/> instance in which the manager will be created.</param> public EntityManager(EntityWorld world) { if (world == null) { throw new ArgumentNullException("world"); } _world = world; _removedAndAvailable = new Queue <Entity>(); _componentsByType = new Dictionary <int, Dictionary <int, IComponent> >(); _activeEntityTable = new Dictionary <int, Entity>(); }
public REALGame(int resolutionWidth, int resolutionHeight, bool fullscreen, EntityWorld startingScene) { _graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; _graphics.PreferredBackBufferWidth = resolutionWidth; _graphics.PreferredBackBufferHeight = resolutionHeight; _graphics.IsFullScreen = fullscreen; _graphics.ApplyChanges(); _currentScene = startingScene; }
protected override void ShootInner(UpdateContext updateContext, EntityWorld entityWorld, Entity playerEntity) { const int Bullets = 6; const float SpreadAngle = 0.3f; for (int i = 0; i < Bullets; i++) { float angle = -SpreadAngle / 2f + i / (float)Bullets * SpreadAngle; entityWorld.CreateEntityFromPrefab<NormalBulletPrefab>(playerEntity.Transform, this, angle); } this.DecreaseBulletCount(); }
public T AddEntityComponent <T>() where T : ComponentBase, new() { var comp = new T(); if (_componentDic.ContainsKey(typeof(T))) { Debug.LogError("Only one component can be added to a entity for a certain Type!"); return(null); } _componentDic[typeof(T)] = comp; EntityWorld.OnEntityAddComponent(comp); return(comp); }
public void IsNotExecutedForOnlyOneOfTwoComponentsOfInterest() { var target = new FakeComponent1And2System(); var world = new EntityWorld(); world.AddSystem(target); var component1 = new FakeComponent1(); Entity entity = world.CreateEntity(); entity.AddComponent(component1); world.Update(TimeSpan.Zero); Assert.False(component1.Processed); }
public void Initialize() { world = new EntityWorld(); system = new PlayerInputSystem(); consoleMock = new Mock <IConsole>(); consoleMock.Setup(m => m.ReadChar()).Returns('1'); consoleMock.Setup(m => m.WindowHeight).Returns(25); consoleMock.Setup(m => m.WindowWidth).Returns(80); system.Console = consoleMock.Object; world.SystemManager.SetSystem(system, Artemis.Manager.GameLoopType.Update); humanEntity = world.CreateEntity(); humanEntity.AddComponent(new Human()); }
/// <summary>Initializes a new instance of the <see cref="SystemManager" /> class.</summary> /// <param name="entityWorld">The entity world.</param> internal SystemManager(EntityWorld entityWorld) { this.mergedBag = new Bag <EntitySystem>(); #if FULLDOTNET this.drawLayers = new SortedDictionary <int, SystemLayer>(); this.updateLayers = new SortedDictionary <int, SystemLayer>(); #else this.drawLayers = new Dictionary <int, SystemLayer>(); this.updateLayers = new Dictionary <int, SystemLayer>(); #endif this.systems = new Dictionary <Type, IList>(); this.entityWorld = entityWorld; }
public ToolsetGameService( EntityWorld world, SpriteBatch spriteBatch, Camera2D camera, IScreenService screenService, IInputService inputService) { _world = world; _camera = camera; _screenService = screenService; _spriteBatch = spriteBatch; _inputService = inputService; }
public Entity BuildEntity(Entity entity, EntityWorld entityWorld, params object[] args) { entity.Group = "SHIPS"; entity.AddComponentFromPool <TransformComponent>(); entity.AddComponent(new SpatialFormComponent("EnemyShip")); entity.AddComponent(new HealthComponent(10)); entity.AddComponent(new WeaponComponent()); entity.AddComponent(new EnemyComponent()); entity.AddComponent(new VelocityComponent()); return(entity); }
public void Initialize() { _networkAgent = new NetworkAgent(AgentRole.Server, "Umbra"); _networkAgent.OnPlayerConnect += OnPlayerConnect; _networkAgent.OnPlayerDisconnect += OnPlayerDisconnect; EntitySystem.BlackBoard.SetEntry("NetworkAgent", _networkAgent); _entityWorld = new EntityWorld(); _entityWorld.InitializeAll(new[] { GetType().Assembly }); CrawEntityManager.Instance.Initialize(_entityWorld, new ServerEntityFactory(_entityWorld)); }
public static ReverieState CreateCache(EntityWorld world) { if (cache.ContainsKey(world)) { throw new ArgumentException("New world key already exists in WorldCache."); } ReverieState newState = new ReverieState(); cache.Add(world, newState); return(newState); }
public void GetScriptName_ShouldReturnValue() { EntityWorld world = TestHelpers.CreateEntityWorld(); Entity entity = world.CreateEntity(); ScriptGroup scriptGroup = new ScriptGroup(); scriptGroup.Add(ScriptEvent.OnAreaEnter, "TestScriptName"); entity.AddComponent(scriptGroup); string result = _scriptingMethods.GetScriptName(entity, ScriptEvent.OnAreaEnter); Assert.AreEqual(result, "TestScriptName"); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); SpriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, Matrix.CreateScale(Scale)); EntitySystem.BlackBoard.SetEntry("delta", (float)gameTime.ElapsedGameTime.TotalSeconds); EntityWorld.Draw(); SpriteBatch.End(); base.Draw(gameTime); }
public void ReusesPooledEntities() { var target = new EntityWorld(new EntityWorldConfiguration { InitialEntityPoolCapacity = 1 }); Entity entity1 = target.CreateEntity(); entity1.Dispose(); Entity entity2 = target.CreateEntity(); Assert.Equal(entity1, entity2); }
public static void HybridQueueSystemTeste() { EntityWorld world = new EntityWorld(); SystemManager systemManager = world.SystemManager; HybridQueueSystemTest HybridQueueSystemTest = new ArtemisTest.HybridQueueSystemTest(); EntitySystem hs = systemManager.SetSystem(HybridQueueSystemTest, ExecutionType.Update); systemManager.InitializeAll(); List <Entity> l = new List <Entity>(); for (int i = 0; i < 100; i++) { Entity et = world.CreateEntity(); et.AddComponent(new Health()); et.GetComponent <Health>().HP += 100; et.Refresh(); l.Add(et); } for (int i = 0; i < 100; i++) { Entity et = world.CreateEntity(); et.AddComponent(new Health()); et.GetComponent <Health>().HP += 100; HybridQueueSystemTest. AddToQueue(et); l.Add(et); } int j = 0; while (HybridQueueSystemTest.QueueCount > 0) { j++; DateTime dt = DateTime.Now; world.LoopStart(); systemManager.UpdateSynchronous(ExecutionType.Update); Console.WriteLine((DateTime.Now - dt).TotalMilliseconds); } for (int i = 0; i < 100; i++) { Debug.Assert(l[i].GetComponent <Health>().HP == 100 - (10 * j)); } for (int i = 100; i < 200; i++) { Debug.Assert(l[i].GetComponent <Health>().HP == 90); } }
public void TransferComponentFromOneWorldToAnother() { EntityWorld target1 = EmptyWorld(); Entity entity = target1.CreateEntity(); entity.AddComponent(new FakeComponent1 { Processed = true }); EntityWorld target2 = EmptyWorld(); target2.RestoreState(target1.GetState()); Assert.True(target2.GetEntities().First().GetComponent <FakeComponent1>().Processed); }
public void TransferDeepCopyOfComponentFromOneWorldToAnother() { EntityWorld target1 = EmptyWorld(); Entity entity = target1.CreateEntity(); var component = new FakeComponent1(); entity.AddComponent(component); EntityWorld target2 = EmptyWorld(); target2.RestoreState(target1.GetState()); component.Processed = true; Assert.False(target2.GetEntities().First().GetComponent <FakeComponent1>().Processed); }
public void GetScriptName_ShouldReturnValue() { EntityWorld world = TestHelpers.CreateEntityWorld(); Entity entity = world.CreateEntity(); Script scriptComponent = new Script { FilePath = "TestScriptName" }; entity.AddComponent(scriptComponent); string result = _miscellaneousMethods.GetScriptName(entity); Assert.AreEqual(result, "TestScriptName"); }