X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fworld.cpp;h=528bc40c1b242358cd6026d81969e8c53ab62463;hb=cdcfdb33e9b625976909a9fb604b756a1a057788;hp=f0f9496c4eff11fbcf31c892eb3c0ef484179580;hpb=dcd54cacda98c2c0f7cf0c7a9131fb858d8ee10a;p=blank.git diff --git a/src/world/world.cpp b/src/world/world.cpp index f0f9496..528bc40 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -136,7 +136,7 @@ glm::mat4 Entity::ViewTransform(const glm::ivec3 &reference) const noexcept { Ray Entity::Aim(const ExactLocation::Coarse &chunk_offset) const noexcept { glm::mat4 transform = ViewTransform(chunk_offset); - Ray ray{ glm::vec3(transform[3]), -glm::vec3(transform[2]) }; + Ray ray{ glm::vec3(transform[3]), -glm::vec3(transform[2]), { } }; ray.Update(); return ray; } @@ -274,7 +274,7 @@ void Entity::OrientBody(float dt) noexcept { } } -void Entity::OrientHead(float dt) noexcept { +void Entity::OrientHead(float) noexcept { // maximum yaw of head (60°) constexpr float max_head_yaw = PI / 3.0f; // use local Y as up @@ -394,7 +394,7 @@ bool Player::SuitableSpawn(BlockLookup &spawn_block) const noexcept { return true; } -void Player::Update(int dt) { +void Player::Update(int) { chunks.Rebase(entity.ChunkCoords()); } @@ -623,7 +623,7 @@ glm::vec3 Steering::Wander(const EntityState &state) const noexcept { return TargetVelocity(state, glm::normalize(entity.Heading() * wander_dist + wander_pos) * speed); } -glm::vec3 Steering::ObstacleAvoidance(const EntityState &state) const noexcept { +glm::vec3 Steering::ObstacleAvoidance(const EntityState &) const noexcept { return obstacle_dir; } @@ -764,6 +764,26 @@ Entity &World::ForceAddEntity(std::uint32_t id) { } +Player *World::FindPlayer(const std::string &name) { + for (Player &p : players) { + if (p.Name() == name) { + return &p; + } + } + return nullptr; +} + +Entity *World::FindEntity(const std::string &name) { + // TODO: this may get inefficient + for (Entity &e : entities) { + if (e.Name() == name) { + return &e; + } + } + return nullptr; +} + + namespace { struct Candidate { @@ -1103,7 +1123,7 @@ void World::RenderDebug(Viewport &viewport) { PrimitiveMesh debug_mesh; PlainColor &prog = viewport.WorldColorProgram(); for (const Entity &entity : entities) { - debug_buf.OutlineBox(entity.Bounds(), TVEC4(255, 0, 0, 255)); + debug_buf.OutlineBox(entity.Bounds(), PrimitiveMesh::Color(255, 0, 0, 255)); debug_mesh.Update(debug_buf); prog.SetM(entity.Transform(players.front().GetEntity().ChunkCoords())); debug_mesh.DrawLines();