This commit is contained in:
aozhiwei 2023-02-08 10:18:27 +08:00
parent 547f250364
commit eea6cbdeec
3 changed files with 76 additions and 8 deletions

View File

@ -11,14 +11,65 @@ static bool EnableDebug()
return App::Instance()->instance_id == 6;
}
void DebugCmd::CreateSphere(Creature* c, float x, float y, float z)
void DebugCmd::CreateSphere(Creature* c,
const glm::vec3& pos,
const glm::vec3& scale,
int uniid)
{
if (c->IsPlayer() && EnableDebug()) {
cs::SMDebugCmd msg;
msg.set_cmd("create_sphere");
msg.add_params(x);
msg.add_params(y);
msg.add_params(z);
msg.add_params(pos.x);
msg.add_params(pos.y);
msg.add_params(pos.z);
msg.add_params(scale.x);
msg.add_params(scale.y);
msg.add_params(scale.z);
msg.add_params(uniid);
c->AsPlayer()->SendNotifyMsg(msg);
}
}
void DebugCmd::CreateCube(Creature* c,
const glm::vec3& pos,
const glm::vec3& scale,
const glm::quat& rotation,
int uniid)
{
if (c->IsPlayer() && EnableDebug()) {
cs::SMDebugCmd msg;
msg.set_cmd("create_cube");
msg.add_params(pos.x);
msg.add_params(pos.y);
msg.add_params(pos.z);
msg.add_params(scale.x);
msg.add_params(scale.y);
msg.add_params(scale.z);
msg.add_params(rotation.x);
msg.add_params(rotation.y);
msg.add_params(rotation.z);
msg.add_params(rotation.w);
msg.add_params(uniid);
c->AsPlayer()->SendNotifyMsg(msg);
}
}
void DebugCmd::DestoryGameObject(Creature* c, int uniid)
{
if (c->IsPlayer() && EnableDebug()) {
cs::SMDebugCmd msg;
msg.set_cmd("destory_gameobject");
msg.add_params(uniid);
c->AsPlayer()->SendNotifyMsg(msg);
}
}

View File

@ -2,12 +2,26 @@
#ifdef DEBUG
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
class Creature;
class DebugCmd
{
public:
static void CreateSphere(Creature* c, float x, float y, float z);
static void CreateSphere(Creature* c,
const glm::vec3& pos,
const glm::vec3& scale,
int uniid);
static void CreateCube(Creature* c,
const glm::vec3& pos,
const glm::vec3& scale,
const glm::quat& rotation,
int uniid);
static void DestoryGameObject(Creature* c, int uniid);
};

View File

@ -240,9 +240,12 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
#ifdef DEBUG
DebugCmd::CreateSphere(c,
bullet_info.bullet_born_pos.x,
bullet_info.bullet_born_pos.y,
bullet_info.bullet_born_pos.z);
glm::vec3(
bullet_info.bullet_born_pos.x,
bullet_info.bullet_born_pos.y,
bullet_info.bullet_born_pos.z),
glm::vec3(1, 1, 1),
c->room->AllocUniid());
#endif
c->room->frame_event.AddBullet