1
This commit is contained in:
parent
892f492662
commit
bff2024067
@ -60,7 +60,8 @@ class Entity
|
||||
void BroadcastDeleteState(Room* room);
|
||||
void RemoveFromAroundPlayers(Room* room);
|
||||
void AddEntityCollider(ColliderComponent* collider);
|
||||
Position GetPos() { return pos_; };
|
||||
const Position& GetPos() { return pos_; };
|
||||
Position& GetMutablePos() { return pos_; };
|
||||
virtual void SetPos(Position pos) { pos_ = pos; }
|
||||
EntityWeakPtrChunk* GetEntityWeakPtrChunk() { return &entity_weak_ptr_chunk_; };
|
||||
EntityWeakPtr AllocEntityWeakPtr();
|
||||
|
@ -97,7 +97,7 @@ void MoveHelper::CalcTargetPos(float distance)
|
||||
}
|
||||
#endif
|
||||
glm::vec3 start = owner_->GetPos().ToGlmVec3();
|
||||
glm::vec3 end = owner_->GetPos().AddVec2(owner_->GetMoveDir() * distance).ToGlmVec3();
|
||||
glm::vec3 end = owner_->GetMutablePos().AddVec2(owner_->GetMoveDir() * distance).ToGlmVec3();
|
||||
|
||||
bool hit_result = false;
|
||||
MovePathPoint point;
|
||||
|
@ -514,16 +514,16 @@ int Room::CreateLootEx(int equip_id, Position born_pos, Position pos, int count,
|
||||
#if 1
|
||||
{
|
||||
if (entity->GetPos().GetX() >= map_meta_->pb->map_width()) {
|
||||
entity->GetPos().SetX(map_meta_->pb->map_width() - 1);
|
||||
entity->GetMutablePos().SetX(map_meta_->pb->map_width() - 1);
|
||||
}
|
||||
if (entity->GetPos().GetX() < 1.0f) {
|
||||
entity->GetPos().SetX(1.0f);
|
||||
entity->GetMutablePos().SetX(1.0f);
|
||||
}
|
||||
if (entity->GetPos().GetY() >= map_meta_->pb->map_height()) {
|
||||
entity->GetPos().SetY(map_meta_->pb->map_height() - 1);
|
||||
entity->GetMutablePos().SetY(map_meta_->pb->map_height() - 1);
|
||||
}
|
||||
if (entity->GetPos().GetY() < 1.0f) {
|
||||
entity->GetPos().SetY(1.0f);
|
||||
entity->GetMutablePos().SetY(1.0f);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -5,32 +5,32 @@
|
||||
#include "metamgr.h"
|
||||
#include "human.h"
|
||||
|
||||
float Position::Distance2D(a8::Vec2 pos)
|
||||
float Position::Distance2D(a8::Vec2 pos) const
|
||||
{
|
||||
return pos.Distance(ToVec2());
|
||||
}
|
||||
|
||||
float Position::Distance2D2(const Position& pos)
|
||||
float Position::Distance2D2(const Position& pos) const
|
||||
{
|
||||
return pos.ToVec2().Distance(ToVec2());
|
||||
}
|
||||
|
||||
float Position::ManhattanDistance2D(const Position& target_pos)
|
||||
float Position::ManhattanDistance2D(const Position& target_pos) const
|
||||
{
|
||||
return ToVec2().ManhattanDistance(target_pos.ToVec2());
|
||||
}
|
||||
|
||||
a8::Vec2 Position::CalcDir2D(const Position& target_pos)
|
||||
a8::Vec2 Position::CalcDir2D(const Position& target_pos) const
|
||||
{
|
||||
return a8::Vec2(target_pos.x, target_pos.z) - a8::Vec2(x, z);
|
||||
}
|
||||
|
||||
a8::Vec2 Position::CalcDir2DEx(const a8::Vec2& target_pos)
|
||||
a8::Vec2 Position::CalcDir2DEx(const a8::Vec2& target_pos) const
|
||||
{
|
||||
return target_pos - ToVec2();
|
||||
}
|
||||
|
||||
a8::Vec2 Position::CalcDirGlm2DEx(const glm::vec2& target_pos)
|
||||
a8::Vec2 Position::CalcDirGlm2DEx(const glm::vec2& target_pos) const
|
||||
{
|
||||
return a8::Vec2(target_pos.x, target_pos.y) - ToVec2();
|
||||
}
|
||||
|
@ -72,12 +72,12 @@ struct Position
|
||||
float GetZ() const { return z; };
|
||||
int GetLayer() const { return layer; };
|
||||
|
||||
float Distance2D(a8::Vec2 pos);
|
||||
float Distance2D2(const Position& pos);
|
||||
float ManhattanDistance2D(const Position& target_pos);
|
||||
a8::Vec2 CalcDir2D(const Position& target_pos);
|
||||
a8::Vec2 CalcDir2DEx(const a8::Vec2& target_pos);
|
||||
a8::Vec2 CalcDirGlm2DEx(const glm::vec2& target_pos);
|
||||
float Distance2D(a8::Vec2 pos) const;
|
||||
float Distance2D2(const Position& pos) const;
|
||||
float ManhattanDistance2D(const Position& target_pos) const;
|
||||
a8::Vec2 CalcDir2D(const Position& target_pos) const;
|
||||
a8::Vec2 CalcDir2DEx(const a8::Vec2& target_pos) const;
|
||||
a8::Vec2 CalcDirGlm2DEx(const glm::vec2& target_pos) const;
|
||||
|
||||
void FromVec2(const a8::Vec2 v);
|
||||
void FromVec2Ex(const a8::Vec2 v);
|
||||
|
Loading…
x
Reference in New Issue
Block a user