protected override void Execute(int execID, EntityID entity, ref ProjectileSpawnerComponent spawner, ref TransformComponent trans) { const int SHOTS_PER_BURST = 5; const float COOLDOWN_AFTER_BURST = 1.5f; const float COOLDOWN_BETWEEN_SHOTS = .05f; spawner.Cooldown -= deltaTime.Value; if (spawner.Cooldown > 0f) //Still cooling down so early out { return; } if (spawner.Target != null && context.HasEntity(spawner.Target.Value) && !context.HasTags(spawner.Target.Value, disabledMask)) { FireProjectile(ref spawner, ref trans); } spawner.Cooldown = COOLDOWN_BETWEEN_SHOTS; spawner.ShotsRemaining--; //If there are no shots-remaining then start cooling down if (spawner.ShotsRemaining <= 0) { spawner.ShotsRemaining = SHOTS_PER_BURST; spawner.Cooldown = COOLDOWN_AFTER_BURST; EntityID target; if (colliderManager.Intersect(AABox.FromCenterAndExtents(trans.Matrix.Position, new Vector3(75f, 125f, 75f)), out target)) { spawner.Target = target; } } }
protected override void Execute(int execID, EntityID entity, ref ColliderComponent collider, ref TransformComponent trans) { Vector3 pos = trans.Matrix.Position; AABox box = AABox.FromCenterAndExtents(pos, collider.Size); colliderManager.Add(box, entity); }