This commit is contained in:
aozhiwei 2021-04-04 12:30:03 +08:00
parent e2d4f8a28e
commit fb5b05513d
4 changed files with 40 additions and 38 deletions

View File

@ -8,6 +8,7 @@
#include "skill.h"
#include "human.h"
#include "collider.h"
#include "roomobstacle.h"
void InternalShot(Creature* c,
MetaData::Equip* weapon_meta,
@ -1203,3 +1204,40 @@ void Creature::CheckSpecObject()
}
#endif
}
RoomObstacle* Creature::SummonObstacle(int id, const a8::Vec2& pos)
{
RoomObstacle* obstacle = room->CreateObstacle(id, pos.x, pos.y);
if (obstacle) {
obstacle->master.Attach(this);
room->xtimer.AddRepeatTimerAndAttach
(
SERVER_FRAME_RATE,
a8::XParams()
.SetSender(obstacle),
[] (const a8::XParams& param)
{
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
obstacle->ActiveTimerFunc();
},
&obstacle->xtimer_attacher.timer_list_
);
room->xtimer.AddRepeatTimerAndAttach
(
SERVER_FRAME_RATE,
a8::XParams()
.SetSender(obstacle),
[] (const a8::XParams& param)
{
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
obstacle->UpdateTimerFunc();
},
&obstacle->xtimer_attacher.timer_list_
);
} else {
abort();
}
return obstacle;
}

View File

@ -15,6 +15,7 @@ namespace MetaData
struct xtimer_list;
class Skill;
class Obstacle;
class RoomObstacle;
class Creature : public MoveableEntity
{
public:
@ -113,6 +114,7 @@ class Creature : public MoveableEntity
virtual void _UpdateMove(int speed) {};
void CheckSpecObject();
RoomObstacle* SummonObstacle(int id, const a8::Vec2& pos);
private:

View File

@ -1878,43 +1878,6 @@ void Human::WinExp(Human* sender, int exp)
}
}
RoomObstacle* Human::SummonObstacle(int id, const a8::Vec2& pos)
{
RoomObstacle* obstacle = room->CreateObstacle(id, pos.x, pos.y);
if (obstacle) {
obstacle->master.Attach(this);
room->xtimer.AddRepeatTimerAndAttach
(
SERVER_FRAME_RATE,
a8::XParams()
.SetSender(obstacle),
[] (const a8::XParams& param)
{
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
obstacle->ActiveTimerFunc();
},
&obstacle->xtimer_attacher.timer_list_
);
room->xtimer.AddRepeatTimerAndAttach
(
SERVER_FRAME_RATE,
a8::XParams()
.SetSender(obstacle),
[] (const a8::XParams& param)
{
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
obstacle->UpdateTimerFunc();
},
&obstacle->xtimer_attacher.timer_list_
);
} else {
abort();
}
return obstacle;
}
void Human::_InternalUpdateMove(float speed)
{
float nx = move_dir.x * speed;

View File

@ -238,7 +238,6 @@ class Human : public Creature
int GetSeat() { return seat_; }
void SetSeat(int seat) { seat_ = seat; }
void DeadDrop();
RoomObstacle* SummonObstacle(int id, const a8::Vec2& pos);
virtual std::string GetName() override { return name;};
protected: