game2006/server/gameserver/debugcmd.cc
aozhiwei a12af68c88 1
2023-11-24 12:24:37 +08:00

101 lines
2.4 KiB
C++

#ifdef MYDEBUG
#include "precompile.h"
#include "debugcmd.h"
#include "cs_proto.pb.h"
#include "player.h"
#include "app.h"
bool DebugCmd::Enable()
{
return f8::App::Instance()->GetInstanceId() == 6;
}
void DebugCmd::CreateSphere(Creature* c,
const glm::vec3& pos,
const glm::vec3& scale,
int uniid)
{
if (c->IsPlayer() && Enable()) {
cs::SMDebugCmd msg;
msg.set_cmd("create_sphere");
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() && Enable()) {
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);
a8::XPrintf("r:%f,%f,%f,%f\n", {rotation.x, rotation.y, rotation.z, rotation.w});
msg.add_params(uniid);
c->AsPlayer()->SendNotifyMsg(msg);
}
}
void DebugCmd::DrawLine(Creature* c,
const glm::vec3& begin,
const glm::vec3& end,
float time)
{
if (c->IsPlayer() && Enable()) {
cs::SMDebugCmd msg;
msg.set_cmd("draw_line");
msg.add_params(begin.x);
msg.add_params(begin.y);
msg.add_params(begin.z);
msg.add_params(end.x);
msg.add_params(end.y);
msg.add_params(end.z);
msg.add_params(time);
c->AsPlayer()->SendNotifyMsg(msg);
}
}
void DebugCmd::DestoryGameObject(Creature* c, int uniid)
{
if (c->IsPlayer() && Enable()) {
cs::SMDebugCmd msg;
msg.set_cmd("destory_gameobject");
msg.add_params(uniid);
c->AsPlayer()->SendNotifyMsg(msg);
}
}
#endif