49 lines
2.3 KiB
C++
49 lines
2.3 KiB
C++
#include "./Core.hpp"
|
|
|
|
using namespace world::module;
|
|
using namespace world::module::core;
|
|
using namespace world::generator;
|
|
|
|
Core* Core::sInstance = nullptr;
|
|
static world::module::model::data PLAYER_MODEL = {24,0,0,0,0,0,0,0,0,0,1,0,2,0,0,0,5,0,1,0,0,0,2,0,4,0,0,0,4,0,5,0,1,0,3,0,2,0,5,0,3,0,1,0,2,0,3,0,4,0,4,0,3,0,5,0,6,0,0,0,0,0,0,0,0,60,0,0,0,0,-128,-128,0,60,0,0,0,0,0,0,0,0,0,60,0,0,-128,-128,0,0,0,60,0,0,0,0,0,0,0,0,0,60,-128,-128,0,0,0,0,0,60,0,0,0,-68,0,0,0,0,-128,-128,0,-68,0,0,0,0,0,0,0,0,0,-68,0,0,-128,-128,0,0,0,-68,0,0,0,0,0,0,0,0,0,-68,-128,-128,0,0,0,0,0,-68,0,0};
|
|
|
|
#ifndef LIGHT_CLIENT
|
|
#include "./PlanetGenerator.hpp"
|
|
owner<Abstract*> RoundPlanetFactory(generator::params p) {
|
|
return new RoundPlanet(*(const RoundPlanet::Params*)p);
|
|
}
|
|
owner<Abstract*> CubicPlanetFactory(generator::params p) {
|
|
return new CubicPlanet(*(const CubicPlanet::Params*)p);
|
|
}
|
|
#endif
|
|
|
|
void Core::setup(Registry::Loader reg) {
|
|
reg.reserveMaterials(16);
|
|
ids.AIR = reg.addMaterial(material("Air", "Debug", 0, true, true, false)).val;
|
|
ids.DIRT = reg.addMaterial(material("Dirt")).val;
|
|
ids.GRASS = reg.addMaterial(material("Grass")).val;
|
|
ids.SAND = reg.addMaterial(material("Sand")).val;
|
|
ids.ROCK = reg.addMaterial(material("Rock", "Rough_rock")).val;
|
|
reg.addMaterial(material("Wall", "Stone_wall"));
|
|
reg.addMaterial(material("Path", "Stone_path", -1));
|
|
const auto ALIEN = reg.addMaterial(material("Alien metal", "Alien", .8));
|
|
ids.WATER = reg.addMaterial(material("Water", "Water", 0, false, true, false)).val;
|
|
|
|
{ // Replace -128,-128 with alien texture
|
|
const uint16_t ALIEN_TEX = reg.reg->findTextureId(ALIEN).value().val;
|
|
char const* ALIEN_CHARS = reinterpret_cast<const char *>(&ALIEN_TEX);
|
|
for (size_t i = 1; i < PLAYER_MODEL.size(); i++) {
|
|
if (PLAYER_MODEL[i-1] == -128 && PLAYER_MODEL[i] == -128) {
|
|
PLAYER_MODEL[i-1] = *ALIEN_CHARS;
|
|
PLAYER_MODEL[i] = *(ALIEN_CHARS+1);
|
|
}
|
|
}
|
|
ids.PLAYER = reg.addModel(model("Player", PLAYER_MODEL, geometry::faabb::FromCenter(glm::vec3(0), glm::vec3(.5)))).val;
|
|
}
|
|
|
|
sInstance = this;
|
|
#ifndef LIGHT_CLIENT
|
|
reg.addGenerator(generator("round_planet", RoundPlanetFactory));
|
|
reg.addGenerator(generator("cubic_planet", CubicPlanetFactory));
|
|
#endif
|
|
} |