TODOFix: clean up some todos

master
Nicole Collings 2020-02-02 13:13:10 -08:00
parent 99d26ed71f
commit 3bbae8a371
8 changed files with 28 additions and 34 deletions

View File

@ -55,6 +55,4 @@ void Client::loop() {
Client::~Client() {
sceneManager.cleanupScene();
if (localServer) localServer->stop();
//TODO: Kill local server
}

View File

@ -36,7 +36,6 @@ namespace Api {
auto displayObject = luaEntity.get<sol::optional<std::string>>("display_object");
auto displayTexture = luaEntity.get<sol::optional<std::string>>("display_texture");
//TODO: Move these checks to register_entity
if (!displayType) throw "entity '" + *identifier + "' is missing the display property.";
if (!displayObject) throw "entity '" + *identifier + "' is missing the display_object property.";
if (strncmp(displayType->data(), "model", 5) == 0 && !displayTexture) throw "entity '" + *identifier + "' is missing the display_texture property.";
@ -75,7 +74,6 @@ namespace Api {
auto displayObject = luaEntity.get<sol::optional<std::string>>("display_object");
auto displayTexture = luaEntity.get<sol::optional<std::string>>("display_texture");
//TODO: Move these checks to register_entity
if (!displayType) throw "entity '" + *identifier + "' is missing the display property.";
if (!displayObject) throw "entity '" + *identifier + "' is missing the display_object property.";
if (strncmp(displayType->data(), "model", 5) == 0 && !displayTexture) throw "entity '" + *identifier + "' is missing the display_texture property.";

View File

@ -19,6 +19,11 @@ namespace Api {
if (identifier->compare(0, modname.length() + 1, modname + ":")) throw
"identifier '" + *identifier + "' must begin with the calling mod's prefix, '" + modname + "'.";
if (!data->get<sol::optional<std::string>>("display")) throw "entity '" + *identifier + "' is missing the display property.";
if (!data->get<sol::optional<std::string>>("display_object")) throw "entity '" + *identifier + "' is missing the display_object property.";
if (strncmp(data->get<std::string>("display_object").data(), "model", 5) == 0 && !data->get<sol::optional<std::string>>("display_texture"))
throw "entity '" + *identifier + "' is missing the display_texture property.";
(*data)["__index"] = *data;
core["registered_entities"][*identifier] = *data;
});

View File

@ -9,34 +9,36 @@
#include "../../../game/scene/world/LocalWorld.h"
namespace Api {
//TODO: Clean method
static void remove_entity_c(sol::state& lua, sol::table& core, LocalDefs& defs, LocalWorld& world) {
core.set_function("remove_entity", [&](sol::table entity) {
auto object = entity.get<sol::optional<std::shared_ptr<LocalLuaEntity>>>("object");
if (!object) throw "Attempting to remove an invalid entity object.";
std::shared_ptr<LocalLuaEntity> object = entity.get<std::shared_ptr<LocalLuaEntity>>("object");
sol::optional<sol::table> luaEntTable = core["entities"][object->id];
sol::optional<sol::table> luaEntTable = core["entities"][(*object)->id];
if (!luaEntTable) return;
sol::optional<sol::function> onDestruct = (*luaEntTable)["on_destroy"];
if (onDestruct) (*onDestruct)();
core["entities"][object->id] = sol::nil;
world.dimension.removeLocalEntity(object);
core["entities"][(*object)->id] = sol::nil;
world.dimension.removeLocalEntity(*object);
});
}
static void remove_entity_s(sol::state& lua, sol::table& core, ServerDefs& defs, ServerWorld& world) {
core.set_function("remove_entity", [&](sol::table entity) {
auto object = entity.get<sol::optional<std::shared_ptr<ServerLuaEntity>>>("object");
if (!object) throw "Attempting to remove an invalid entity object.";
// sptr<LocalLuaEntity> object = entity.get<sptr<LocalLuaEntity>>("object");
// sol::optional<sol::table> luaEntTable = core["entities"][object->id];
// if (!luaEntTable) return;
//
// sol::optional<sol::function> onDestruct = (*luaEntTable)["on_destroy"];
// if (onDestruct) (*onDestruct)();
//
// core["entities"][object->id] = sol::nil;
// world.dimension.removeLocalEntity(object);
sol::optional<sol::table> luaEntTable = core["entities"][(*object)->id];
if (!luaEntTable) return;
sol::optional<sol::function> onDestruct = (*luaEntTable)["on_destroy"];
if (onDestruct) (*onDestruct)();
core["entities"][(*object)->id] = sol::nil;
// TODO: Tell the client when entities are deleted.
world.dimension.removeLuaEntity(*object);
});
}
}

View File

@ -190,7 +190,6 @@ namespace RegisterBlocks {
if (atlas) {
std::vector<std::shared_ptr<AtlasRef>> refs;
for (auto i = 0; i < lowdef_textures.size(); i++) {
// TODO: Make biome tint work on LD models
std::string texture = lowdef_textures[i];
if (strncmp(texture.data(), "biometint(", 10) == 0) {
texture = texture.substr(10, texture.length() - 11);

View File

@ -16,7 +16,6 @@ unsigned int ServerClient::getConnectID() {
void ServerClient::initPlayer() {
delete player;
//TODO: IMPLEMENT USERNAME
player = new ServerPlayer({0, 0, 0}, connectID, "TEMPORARY");
}

View File

@ -6,8 +6,8 @@
#include <glm/glm.hpp>
#include "ServerWorld.h"
const static int MB_GEN_H = 6;
const static int MB_GEN_V = 4;
const static int MB_GEN_H = 2;
const static int MB_GEN_V = 2;
ServerWorld::ServerWorld(unsigned int seed, ServerDefs& defs, ServerClients& clients) :
clientList(clients),

View File

@ -10,25 +10,18 @@ zepha.register_entity("zeus:default:test", {
-- self.object:snap_scale(1/4)
end,
on_update = function(self, delta)
-- local pos = self.object.pos
-- pos.z = pos.z + 1 * delta
-- if pos.z > 13 then
-- pos.z = 0
-- end
-- self.object:int_pos(pos)
-- self.object.yaw = self.object.yaw + 1;
self.object:set_pos({
x = self.object.pos.x + 0.08 * math.sin(math.rad(self.object.yaw)),
y = self.object.pos.y,
z = self.object.pos.z + 0.08 * math.cos(math.rad(self.object.yaw))})
self.object:set_yaw(self.object.yaw + 2)
-- self.object:set_pitch(self.object.pitch + 2)
-- self.object:set_yaw(math.deg(math.atan2(zepha.player.pos.x - self.object.pos.x, zepha.player.pos.z - self.object.pos.z)) + 180)
end
})
if zepha.server then
zepha.add_entity("zeus:default:test", {x = 10, y = -29, z = 0})
local entity = zepha.add_entity("zeus:default:test", {x = 10, y = 0, z = 0})
zepha.delay(function()
zepha.remove_entity(entity)
end, 10)
end