summaryrefslogtreecommitdiff
path: root/bowshock/source/server/ServerInstance/generate_system.cxx
blob: 8372161deac97576972d2676c41e79dd13b22686 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2022-2023 Gabriel Bjørnager Jensen.

#include <bow/logic.hxx>
#include <bow/server.hxx>

#include <cstdint>
#include <format>
#include <string>

using namespace ::std::literals::string_literals;

auto bow::ServerInstance::generate_system(::bow::ObjectRoot& system, ::std::uint64_t const identifier, ::std::uint64_t const time) -> void {
	::bow::log("server"s, ::std::format("generating system ({:x})", identifier));

	if (system.has_objects()) [[likely]] {
		system.~ObjectRoot();
	}

	// Note: The following code is only temporary;

	system.add([]() -> ::bow::Star {
		auto star = ::bow::Star();

		star.mass = 0x1p0,
		star.type = ::bow::StarType::G;

		return star;
	}());

	system.add([]() -> ::bow::World {
		auto world = ::bow::World();

		world.position.y            = 0x1.F76F144Dp-1;
		world.positional_velocity.x = 0x1.B2D06FF3p-23 * ::bow::TIME_MODIFIER;
		world.rotational_velocity.z = 0x1.31DB66BBp-15;
		world.mass                  = 0x1.931AFC649369998Fp-19,
		world.type                  = ::bow::WorldType::RockyWorld;

		return world;
	}());

	this->simulate(system, time);
}