1
This commit is contained in:
parent
45c68e188c
commit
52144aacad
@ -375,6 +375,11 @@ enum PostBuffAction_e
|
|||||||
kRemoveBuffByEffectAction = 2
|
kRemoveBuffByEffectAction = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ObstacleType_e
|
||||||
|
{
|
||||||
|
kObstacleSelfExplosion = 1,
|
||||||
|
};
|
||||||
|
|
||||||
const char* const PROJ_NAME_FMT = "game%d_gameserver";
|
const char* const PROJ_NAME_FMT = "game%d_gameserver";
|
||||||
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
|
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
|
||||||
|
|
||||||
|
@ -1319,32 +1319,35 @@ RoomObstacle* Creature::SummonObstacle(int id, const a8::Vec2& pos)
|
|||||||
RoomObstacle* obstacle = room->CreateObstacle(id, pos.x, pos.y);
|
RoomObstacle* obstacle = room->CreateObstacle(id, pos.x, pos.y);
|
||||||
if (obstacle) {
|
if (obstacle) {
|
||||||
obstacle->master.Attach(this);
|
obstacle->master.Attach(this);
|
||||||
room->xtimer.AddRepeatTimerAndAttach
|
if (obstacle->meta->i->thing_type() == kObstacleSelfExplosion) {
|
||||||
(
|
obstacle->Active();
|
||||||
SERVER_FRAME_RATE,
|
} else {
|
||||||
a8::XParams()
|
room->xtimer.AddRepeatTimerAndAttach
|
||||||
.SetSender(obstacle),
|
(
|
||||||
[] (const a8::XParams& param)
|
SERVER_FRAME_RATE,
|
||||||
{
|
a8::XParams()
|
||||||
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
|
.SetSender(obstacle),
|
||||||
obstacle->ActiveTimerFunc();
|
[] (const a8::XParams& param)
|
||||||
},
|
{
|
||||||
&obstacle->xtimer_attacher.timer_list_
|
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
|
||||||
);
|
obstacle->ActiveTimerFunc();
|
||||||
|
},
|
||||||
room->xtimer.AddRepeatTimerAndAttach
|
&obstacle->xtimer_attacher.timer_list_
|
||||||
(
|
);
|
||||||
SERVER_FRAME_RATE,
|
|
||||||
a8::XParams()
|
|
||||||
.SetSender(obstacle),
|
|
||||||
[] (const a8::XParams& param)
|
|
||||||
{
|
|
||||||
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
|
|
||||||
obstacle->UpdateTimerFunc();
|
|
||||||
},
|
|
||||||
&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 {
|
} else {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,10 @@ bool RoomObstacle::CanThroughable(Human* hum)
|
|||||||
|
|
||||||
void RoomObstacle::ActiveTimerFunc()
|
void RoomObstacle::ActiveTimerFunc()
|
||||||
{
|
{
|
||||||
|
if (meta->i->thing_type() == kObstacleSelfExplosion) {
|
||||||
|
room->xtimer.DeleteTimer(room->xtimer.GetRunningTimer());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!master.Get()) {
|
if (!master.Get()) {
|
||||||
room->xtimer.DeleteTimer(room->xtimer.GetRunningTimer());
|
room->xtimer.DeleteTimer(room->xtimer.GetRunningTimer());
|
||||||
return;
|
return;
|
||||||
@ -131,6 +135,10 @@ void RoomObstacle::ActiveTimerFunc()
|
|||||||
|
|
||||||
void RoomObstacle::UpdateTimerFunc()
|
void RoomObstacle::UpdateTimerFunc()
|
||||||
{
|
{
|
||||||
|
if (meta->i->thing_type() == kObstacleSelfExplosion) {
|
||||||
|
room->xtimer.DeleteTimer(room->xtimer.GetRunningTimer());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (grid_list_ && master.Get() && !IsDead(room)) {
|
if (grid_list_ && master.Get() && !IsDead(room)) {
|
||||||
std::set<Human*> human_list;
|
std::set<Human*> human_list;
|
||||||
room->grid_service->TouchAllLayerHumanList
|
room->grid_service->TouchAllLayerHumanList
|
||||||
@ -255,3 +263,27 @@ void RoomObstacle::Explosion()
|
|||||||
self_collider_->rad = old_rad;
|
self_collider_->rad = old_rad;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RoomObstacle::Active()
|
||||||
|
{
|
||||||
|
switch (meta->i->thing_type()) {
|
||||||
|
case kObstacleSelfExplosion:
|
||||||
|
{
|
||||||
|
room->xtimer.AddDeadLineTimerAndAttach
|
||||||
|
(
|
||||||
|
meta->i->time() / FRAME_RATE_MS,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(this),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
|
||||||
|
obstacle->Explosion();
|
||||||
|
},
|
||||||
|
&xtimer_attacher.timer_list_
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -20,6 +20,7 @@ class RoomObstacle : public Obstacle
|
|||||||
virtual bool CanThroughable(Human* hum) override;
|
virtual bool CanThroughable(Human* hum) override;
|
||||||
void ActiveTimerFunc();
|
void ActiveTimerFunc();
|
||||||
void UpdateTimerFunc();
|
void UpdateTimerFunc();
|
||||||
|
void Active();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Explosion();
|
void Explosion();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user