Beispiel #1
0
		PerlinNoise::PerlinNoise(SeedT seed) {
			std::mt19937 rng(seed);

			std::uniform_int_distribution<int> byte_distribution(0, 256);
			auto r256 = std::bind(byte_distribution, rng);

			std::uniform_real_distribution<RealT> real_distribution(0.0, 1.0);
			auto r01 = std::bind(real_distribution, rng);

			for (std::size_t i = 0; i < 256; ++i) _indicies[i] = i;

			/* Mix it up! */
			for (std::size_t i = 0; i < 256; ++i) {
				std::size_t w = r256() % 256;
				
				std::swap(_indicies[w], _indicies[i]);
			}

			for (std::size_t i = 0; i < 256; ++i) _table[i] = (RealT)r01();
		}
Beispiel #2
0
sanguis::server::world::pickup_spawner::pickup_spawner(
	sanguis::random_generator &_random_generator,
	sanguis::server::weapons::common_parameters const &_weapon_parameters,
	sanguis::server::environment::object &_env
)
:
	random_generator_(
		_random_generator
	),
	weapon_parameters_{
		_weapon_parameters
	},
	env_(
		_env
	),
	distributor_(
		sanguis::server::world::pickup_spawner::distributor::vector{
			std::make_pair(
				sanguis::server::pickup_probability(
					4.f
				),
				sanguis::server::world::pickup_spawner::spawn_function(
					std::bind(
						&sanguis::server::world::pickup_spawner::spawn_health,
						this,
						std::placeholders::_1,
						std::placeholders::_2
					)
				)
			),
			std::make_pair(
				sanguis::server::pickup_probability(
					1.f
				),
				this->make_spawn_weapon(
					sanguis::weapon_type(
						sanguis::primary_weapon_type::pistol
					)
				)
			),
			std::make_pair(
				sanguis::server::pickup_probability(
					0.8f
				),
				this->make_spawn_weapon(
					sanguis::weapon_type(
						sanguis::primary_weapon_type::shotgun
					)
				)
			),
			std::make_pair(
				sanguis::server::pickup_probability(
					1.f
				),
				this->make_spawn_weapon(
					sanguis::weapon_type(
						sanguis::primary_weapon_type::rocket_launcher
					)
				)
			),
			std::make_pair(
				sanguis::server::pickup_probability(
					4.f
				),
				this->make_spawn_weapon(
					sanguis::weapon_type(
						sanguis::secondary_weapon_type::grenade
					)
				)
			),
			std::make_pair(
				sanguis::server::pickup_probability(
					0.5f
				),
				this->make_spawn_weapon(
					sanguis::weapon_type(
						sanguis::secondary_weapon_type::sentry
					)
				)
			),
			std::make_pair(
				sanguis::server::pickup_probability(
					0.5f
				),
				this->make_spawn_weapon(
					sanguis::weapon_type(
						sanguis::secondary_weapon_type::spider
					)
				)
			)
		}
	),
	spawn_prob_(
		real_distribution(
			real_distribution::param_type::min(
				0.f
			),
			real_distribution::param_type::sup(
				1.f
			)
		)
	)
{
}