private void Spawn() { // TODO: parenting of particles to enable transforms for children, let them be like unity so world or local space for (int i = 0; i < settings.spawnCount; i++) { if (particles.Count >= settings.capacity) { return; } Particle p = particles.Pop(); p.position.X = settings.position.RandomX(); p.position.Y = settings.position.RandomY(); p.velocity.X = settings.velocity.RandomX(); p.velocity.Y = settings.velocity.RandomY(); Vector2 startScale = settings.startScale.Random(); p.startScale.X = startScale.X; p.startScale.Y = startScale.Y; Vector2 endScale = settings.endScale.Random(); p.endScale.X = endScale.X; p.endScale.Y = endScale.Y; p.scale.X = p.startScale.X; p.scale.Y = p.startScale.Y; p.source = settings.RandomSource(); p.rotation = settings.rotation.Random(); p.current = 0f; p.duration = settings.lifeTime.Random(); p.startColor = settings.startColor.Random(); p.endColor = settings.endColor.Random(); p.color = p.startColor; spawned++; } spawnTimer.Set(settings.frequency.Random()); }
private void SetState(AiState state, float duration) { _state = state; _timer.Set(duration); }