1
This commit is contained in:
parent
49a2f32ae5
commit
8e38d882c2
@ -7,6 +7,7 @@
|
||||
#include "room.h"
|
||||
#include "skill.h"
|
||||
#include "human.h"
|
||||
#include "collider.h"
|
||||
|
||||
void InternalShot(Creature* c,
|
||||
MetaData::Equip* weapon_meta,
|
||||
@ -814,11 +815,6 @@ bool Creature::CanSee(const Creature* c) const
|
||||
return room->grid_service->InView(GetGridId(), c->GetGridId());
|
||||
}
|
||||
|
||||
bool Creature::CanSee(int grid_id) const
|
||||
{
|
||||
return room->grid_service->InView(GetGridId(), grid_id);
|
||||
}
|
||||
|
||||
float Creature::GetAttrAbs(int attr_id)
|
||||
{
|
||||
float attr_abs_val = GetBuffAttrAbs(attr_id);
|
||||
@ -1116,3 +1112,72 @@ void Creature::DecInventory(int slot_id, int num)
|
||||
}
|
||||
inventory_[slot_id] -= num;
|
||||
}
|
||||
|
||||
void Creature::CheckSpecObject()
|
||||
{
|
||||
std::set<ColliderComponent*> colliders;
|
||||
room->map_service->GetSpecColliders(SPEC_MAP_OBJECT_FLAGS, room, GetPos().x, GetPos().y, colliders);
|
||||
|
||||
#ifdef DEBUG
|
||||
long long old_cell_flags = cell_flags_;
|
||||
#endif
|
||||
cell_flags_ = 0;
|
||||
for (const ColliderComponent* collider : colliders) {
|
||||
switch (collider->owner->GetEntityType()) {
|
||||
case ET_Obstacle:
|
||||
case ET_Building:
|
||||
{
|
||||
if (TestCollision(room, (ColliderComponent*)collider)) {
|
||||
cell_flags_ |= collider->tag;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (IsPlayer()) {
|
||||
if (old_cell_flags != cell_flags_) {
|
||||
std::string msg = "地形变化 old:";
|
||||
{
|
||||
if (a8::HasBitFlag(old_cell_flags, kColliderTag_Grass)) {
|
||||
msg += " 草:1";
|
||||
} else {
|
||||
msg += " 草:0";
|
||||
}
|
||||
if (a8::HasBitFlag(old_cell_flags, kColliderTag_Water)) {
|
||||
msg += " 水:1";
|
||||
} else {
|
||||
msg += " 水:0";
|
||||
}
|
||||
if (a8::HasBitFlag(old_cell_flags, kColliderTag_Ice)) {
|
||||
msg += " 灰:1";
|
||||
} else {
|
||||
msg += " 灰:0";
|
||||
}
|
||||
}
|
||||
{
|
||||
msg += " new:";
|
||||
if (a8::HasBitFlag(cell_flags_, kColliderTag_Grass)) {
|
||||
msg += " 草:1";
|
||||
} else {
|
||||
msg += " 草:0";
|
||||
}
|
||||
if (a8::HasBitFlag(cell_flags_, kColliderTag_Water)) {
|
||||
msg += " 水:1";
|
||||
} else {
|
||||
msg += " 水:0";
|
||||
}
|
||||
if (a8::HasBitFlag(cell_flags_, kColliderTag_Ice)) {
|
||||
msg += " 灰:1";
|
||||
} else {
|
||||
msg += " 灰:0";
|
||||
}
|
||||
}
|
||||
msg += a8::Format(" o:%d n:%d", {old_cell_flags, cell_flags_});
|
||||
SendDebugMsg(msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -79,8 +79,6 @@ class Creature : public MoveableEntity
|
||||
Skill* CurrentSkill();
|
||||
MetaData::SkillPhase* GetCurrSkillPhase();
|
||||
bool CanSee(const Creature* c) const;
|
||||
bool CanSee(int grid_id) const;
|
||||
|
||||
virtual std::string GetName() { return "";};
|
||||
virtual void SendDebugMsg(const std::string& debug_msg);
|
||||
virtual void DropItems(Obstacle* obstacle) {};
|
||||
@ -113,6 +111,9 @@ class Creature : public MoveableEntity
|
||||
void DecInventory(int slot_id, int num);
|
||||
std::array<int, IS_END - 1>& GetInventoryData() { return inventory_; };
|
||||
virtual void _UpdateMove(int speed) {};
|
||||
|
||||
void CheckSpecObject();
|
||||
|
||||
private:
|
||||
|
||||
virtual void AddBuffPostProc(Creature* caster, Buff* buff);
|
||||
@ -137,6 +138,8 @@ protected:
|
||||
int action_item_id = 0;
|
||||
int action_target_id = 0;
|
||||
|
||||
long long cell_flags_ = 0;
|
||||
|
||||
private:
|
||||
CreatureWeakPtrChunk weak_ptr_chunk_;
|
||||
std::array<float, kHAT_End> buff_attr_abs_ = {};
|
||||
|
@ -109,6 +109,9 @@ float Human::GetSpeed()
|
||||
}
|
||||
float speed = meta->i->move_speed();
|
||||
speed = (speed + GetBuffAttrAbs(kHAT_Speed)) * (1 + GetBuffAttrRate(kHAT_Speed));
|
||||
if (a8::HasBitFlag(cell_flags_, kColliderTag_Water)) {
|
||||
speed *= 0.5f;
|
||||
}
|
||||
return std::max(speed, 1.0f);
|
||||
}
|
||||
}
|
||||
@ -3309,50 +3312,6 @@ void Human::DoGetOnWithCar(Car* car)
|
||||
car->GetOn(this);
|
||||
}
|
||||
|
||||
void Human::CheckSpecObject()
|
||||
{
|
||||
std::set<ColliderComponent*> colliders;
|
||||
room->map_service->GetSpecColliders(SPEC_MAP_OBJECT_FLAGS, room, GetPos().x, GetPos().y, colliders);
|
||||
|
||||
long long flags = 0;
|
||||
for (const ColliderComponent* collider : colliders) {
|
||||
switch (collider->owner->GetEntityType()) {
|
||||
case ET_Obstacle:
|
||||
case ET_Building:
|
||||
{
|
||||
if (TestCollision(room, (ColliderComponent*)collider)) {
|
||||
flags |= collider->tag;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const int spec_tag_array[kColliderSpecTag_End + 1] =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
kBET_InGrass, //kColliderTag_Grass
|
||||
kBET_InWater, //kColliderTag_Water
|
||||
kBET_InIce //kColliderTag_Ice
|
||||
};
|
||||
for (int i = kColliderSpecTag_Begin; i <= kColliderSpecTag_End; ++i) {
|
||||
SpecMapObject& map_obj = spec_map_objects_[i - kColliderSpecTag_Begin];
|
||||
int buff_effect = spec_tag_array[i];
|
||||
if (a8::HasBitFlag(flags, i)) {
|
||||
if (!HasBuffEffect(buff_effect)) {
|
||||
OnEnterSpecMapArea(i, map_obj);
|
||||
}
|
||||
} else {
|
||||
if (HasBuffEffect(buff_effect)) {
|
||||
OnLeaveSpecMapArea(i, map_obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Human::OnEnterSpecMapArea(int tag, SpecMapObject& map_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
@ -277,7 +277,6 @@ private:
|
||||
void NextReload(int prev_weapon_id, int prev_weapon_idx);
|
||||
void DoGetOnWithLoot(Loot* loot_entity);
|
||||
void DoGetOnWithCar(Car* car);
|
||||
void CheckSpecObject();
|
||||
void OnEnterSpecMapArea(int tag, SpecMapObject& map_obj);
|
||||
void OnLeaveSpecMapArea(int tag, SpecMapObject& map_obj);
|
||||
void ClearSpecMapAreaTimer(SpecMapObject& map_obj);
|
||||
|
Loading…
x
Reference in New Issue
Block a user