Skip to content

Commit

Permalink
Simplify the excel
Browse files Browse the repository at this point in the history
  • Loading branch information
i0gan committed Sep 22, 2024
1 parent 9eb71ab commit 64ff5d5
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 60 deletions.
Binary file modified resource/excel/Group.xlsx
Binary file not shown.
Binary file added resource/excel/Object.xlsx
Binary file not shown.
Binary file modified resource/excel/Player.xlsx
Binary file not shown.
Binary file modified resource/excel/Scene.xlsx
Binary file not shown.
Binary file modified resource/excel/common/IObject.xlsx
Binary file not shown.
Binary file modified resource/excel/example/Property.xlsx
Binary file not shown.
Binary file modified resource/excel/example/Record.xlsx
Binary file not shown.
9 changes: 4 additions & 5 deletions src/squick/plugin/world/cell_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bool CellModule::Start() {
}

bool CellModule::AfterStart() {
m_world_->AddClassCallBack(excel::Player::ThisName(), this, &CellModule::OnObjectEvent);
m_world_->AddClassCallBack(excel::Object::ThisName(), this, &CellModule::OnObjectEvent);

// NF SYNC
/*X
Expand Down Expand Up @@ -376,15 +376,14 @@ int CellModule::AddMoveOutEventCallBack(CELL_MOVE_EVENT_FUNCTOR_PTR functorPtr)

int CellModule::OnObjectEvent(const Guid &self, const std::string &classNames, const CLASS_OBJECT_EVENT classEvent, const DataList &var) {
if (CLASS_OBJECT_EVENT::COE_CREATE_FINISH == classEvent) {
m_world_->AddPropertyCallBack(self, excel::IObject::Position(), this, &CellModule::OnPositionEvent);
m_world_->AddPropertyCallBack(self, excel::Object::Position(), this, &CellModule::OnPositionEvent);
}

return 0;
}

int CellModule::OnPositionEvent(const Guid &self, const std::string &propertyName, const SquickData &oldVar, const SquickData &newVar, const INT64 reason) {
const int sceneID = m_world_->GetPropertyInt32(self, excel::IObject::SceneID());
const int groupID = m_world_->GetPropertyInt32(self, excel::IObject::GroupID());
const int sceneID = m_world_->GetPropertyInt32(self, excel::Object::SceneID());
const int groupID = m_world_->GetPropertyInt32(self, excel::Object::GroupID());
const Vector3 &oldVec = oldVar.GetVector3();
const Vector3 &newVec = newVar.GetVector3();

Expand Down
2 changes: 1 addition & 1 deletion src/squick/plugin/world/data_tail_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bool DataTailModule::Update() { return true; }

bool DataTailModule::AfterStart() {
#ifdef SQUICK_DEBUG_MODE
m_world_->AddClassCallBack(excel::Player::ThisName(), this, &DataTailModule::OnClassObjectEvent);
m_world_->AddClassCallBack(excel::Object::ThisName(), this, &DataTailModule::OnClassObjectEvent);
#endif
return true;
}
Expand Down
48 changes: 24 additions & 24 deletions src/squick/plugin/world/scene_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ bool SceneModule::RequestEnterScene(const Guid &self, const int sceneID, const i
return false;
}

const int nNowSceneID = m_world_->GetPropertyInt32(self, excel::Player::SceneID());
const int nNowGroupID = m_world_->GetPropertyInt32(self, excel::Player::GroupID());
const int nNowSceneID = m_world_->GetPropertyInt32(self, excel::Object::SceneID());
const int nNowGroupID = m_world_->GetPropertyInt32(self, excel::Object::GroupID());

if (nNowSceneID == sceneID && nNowGroupID == groupID) {
LOG_INFO("Guid<%v> in same scene and group but it not a clone scene<%v>, group_id<%v> ", self.ToString(), sceneID, groupID);
Expand Down Expand Up @@ -196,7 +196,7 @@ bool SceneModule::LeaveSceneGroup(const Guid &self) {
}
/////////

const Vector3 &lastPos = m_world_->GetPropertyVector3(self, excel::IObject::Position());
const Vector3 &lastPos = m_world_->GetPropertyVector3(self, excel::Object::Position());
BeforeLeaveSceneGroup(self, nOldSceneID, nOldGroupID, 0, DataList::Empty());

const Guid lastCell = m_pCellModule->ComputeCellID(lastPos);
Expand Down Expand Up @@ -394,7 +394,7 @@ bool SceneModule::CreateSceneNPC(const int sceneID, const int groupID, const Dat
int nWeight = m_world_->Random(0, 100);
if (nWeight <= pResource->nWeight) {
DataList arg;
arg << excel::IObject::Position() << pResource->vSeedPos;
arg << excel::Object::Position() << pResource->vSeedPos;
// arg << SquickProtocol::NPC::SeedID() << pResource->seedID;
arg.Append(argList);

Expand Down Expand Up @@ -916,7 +916,7 @@ bool SceneModule::SwitchScene(const Guid &self, const int nTargetSceneID, const
}
/////////

const Vector3 &lastPos = m_world_->GetPropertyVector3(self, excel::IObject::Position());
const Vector3 &lastPos = m_world_->GetPropertyVector3(self, excel::Object::Position());
BeforeLeaveSceneGroup(self, nOldSceneID, nOldGroupID, type, arg);

const Guid lastCell = m_pCellModule->ComputeCellID(lastPos);
Expand Down Expand Up @@ -944,7 +944,7 @@ bool SceneModule::SwitchScene(const Guid &self, const int nTargetSceneID, const
const Guid newCell = m_pCellModule->ComputeCellID(v);
OnMoveCellEvent(self, nTargetGroupID, nTargetGroupID, Guid(), newCell);

pObject->SetPropertyVector3(excel::IObject::MoveTo(), v);
pObject->SetPropertyVector3(excel::Object::MoveTo(), v);

/////////
AfterEnterSceneGroup(self, nTargetSceneID, nTargetGroupID, type, arg);
Expand Down Expand Up @@ -1004,15 +1004,15 @@ int SceneModule::OnSceneRecordCommonEvent(const Guid &self, const RECORD_EVENT_D

int SceneModule::OnPropertyCommonEvent(const Guid &self, const std::string &propertyName, const SquickData &oldVar, const SquickData &newVar,
const INT64 reason) {
const std::string &className = m_world_->GetPropertyString(self, excel::IObject::ClassName());
if (className == excel::Player::ThisName()) {
const std::string &className = m_world_->GetPropertyString(self, excel::Object::ClassName());
if (className == excel::Object::ThisName()) {
// only player can change grupid and sceneid
if (excel::Player::GroupID() == propertyName) {
if (excel::Object::GroupID() == propertyName) {
OnPlayerGroupEvent(self, propertyName, oldVar, newVar);
return 0;
}

if (excel::Player::SceneID() == propertyName) {
if (excel::Object::SceneID() == propertyName) {
OnPlayerSceneEvent(self, propertyName, oldVar, newVar);
return 0;
}
Expand All @@ -1031,7 +1031,7 @@ int SceneModule::OnPropertyCommonEvent(const Guid &self, const std::string &prop
int SceneModule::OnRecordCommonEvent(const Guid &self, const RECORD_EVENT_DATA &eventData, const SquickData &oldVar, const SquickData &newVar) {
const std::string &recordName = eventData.recordName;

int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::Player::GroupID());
int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::Object::GroupID());

if (nObjectGroupID < 0) {
return 0;
Expand All @@ -1047,14 +1047,14 @@ int SceneModule::OnRecordCommonEvent(const Guid &self, const RECORD_EVENT_DATA &

int SceneModule::OnClassCommonEvent(const Guid &self, const std::string &className, const CLASS_OBJECT_EVENT classEvent, const DataList &var) {
if (CLASS_OBJECT_EVENT::COE_DESTROY == classEvent) {
const int nObjectSceneID = m_world_->GetPropertyInt32(self, excel::IObject::SceneID());
const int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::IObject::GroupID());
const int nObjectSceneID = m_world_->GetPropertyInt32(self, excel::Object::SceneID());
const int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::Object::GroupID());

if (nObjectGroupID < 0 || nObjectSceneID <= 0) {
return 0;
}

const Vector3 &pos = m_world_->GetPropertyVector3(self, excel::Player::Position());
const Vector3 &pos = m_world_->GetPropertyVector3(self, excel::Object::Position());
DataList valueAllPlayrNoSelfList;
m_pCellModule->GetCellObjectList(nObjectSceneID, nObjectGroupID, pos, valueAllPlayrNoSelfList, true, self);

Expand All @@ -1070,7 +1070,7 @@ int SceneModule::OnClassCommonEvent(const Guid &self, const std::string &classNa
DataList selfVar;
selfVar << self;

if (className == excel::Player::ThisName()) {
if (className == excel::Object::ThisName()) {
// tell youself<client>, u want to enter this scene or this group
OnObjectListEnter(selfVar, selfVar);

Expand All @@ -1080,13 +1080,13 @@ int SceneModule::OnClassCommonEvent(const Guid &self, const std::string &classNa

OnObjectListEnterFinished(selfVar, selfVar);
} else {
const int nObjectSceneID = m_world_->GetPropertyInt32(self, excel::IObject::SceneID());
const int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::IObject::GroupID());
const int nObjectSceneID = m_world_->GetPropertyInt32(self, excel::Object::SceneID());
const int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::Object::GroupID());

if (nObjectGroupID < 0 || nObjectSceneID <= 0) {
return 0;
}
const Vector3 &pos = m_world_->GetPropertyVector3(self, excel::Player::Position());
const Vector3 &pos = m_world_->GetPropertyVector3(self, excel::Object::Position());
DataList valueAllPlayrObjectList;
m_pCellModule->GetCellObjectList(nObjectSceneID, nObjectGroupID, pos, valueAllPlayrObjectList, true);

Expand All @@ -1105,8 +1105,8 @@ int SceneModule::OnClassCommonEvent(const Guid &self, const std::string &classNa

int SceneModule::OnPlayerGroupEvent(const Guid &self, const std::string &propertyName, const SquickData &oldVar, const SquickData &newVar) {
// this event only happened in the same scene
const int sceneID = m_world_->GetPropertyInt32(self, excel::IObject::SceneID());
const Vector3 position = m_world_->GetPropertyVector3(self, excel::IObject::Position());
const int sceneID = m_world_->GetPropertyInt32(self, excel::Object::SceneID());
const Vector3 position = m_world_->GetPropertyVector3(self, excel::Object::Position());
int nOldGroupID = oldVar.GetInt32();
int nNewGroupID = newVar.GetInt32();

Expand Down Expand Up @@ -1206,11 +1206,11 @@ int SceneModule::OnPlayerSceneEvent(const Guid &self, const std::string &propert
}

int SceneModule::GetBroadCastObject(const Guid &self, const std::string &propertyName, const bool bTable, DataList &valueObject) {
const int nObjectContainerID = m_world_->GetPropertyInt32(self, excel::IObject::SceneID());
const int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::IObject::GroupID());
const Vector3 &position = m_world_->GetPropertyVector3(self, excel::IObject::Position());
const int nObjectContainerID = m_world_->GetPropertyInt32(self, excel::Object::SceneID());
const int nObjectGroupID = m_world_->GetPropertyInt32(self, excel::Object::GroupID());
const Vector3 &position = m_world_->GetPropertyVector3(self, excel::Object::Position());

const std::string &className = m_world_->GetPropertyString(self, excel::IObject::ClassName());
const std::string &className = m_world_->GetPropertyString(self, excel::Object::ClassName());
std::shared_ptr<IRecordManager> pClassRecordManager = m_class_->GetClassRecordManager(className);
std::shared_ptr<IPropertyManager> pClassPropertyManager = m_class_->GetClassPropertyManager(className);

Expand Down
60 changes: 30 additions & 30 deletions src/squick/plugin/world/world_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ std::shared_ptr<IObject> WorldModule::CreateObject(const Guid &self, const int s
{
Vector3 vRelivePos = m_scene_->GetRelivePosition(sceneID, 0);

pObject->SetPropertyString(excel::IObject::ConfigID(), configIndex);
pObject->SetPropertyString(excel::IObject::ClassName(), className);
pObject->SetPropertyInt(excel::IObject::SceneID(), sceneID);
pObject->SetPropertyInt(excel::IObject::GroupID(), groupID);
pObject->SetPropertyVector3(excel::IObject::Position(), vRelivePos);
pObject->SetPropertyString(excel::Object::ConfigID(), configIndex);
pObject->SetPropertyString(excel::Object::ClassName(), className);
pObject->SetPropertyInt(excel::Object::SceneID(), sceneID);
pObject->SetPropertyInt(excel::Object::GroupID(), groupID);
pObject->SetPropertyVector3(excel::Object::Position(), vRelivePos);

pContainerInfo->AddObjectToGroup(groupID, ident, className == excel::Player::ThisName() ? true : false);
pContainerInfo->AddObjectToGroup(groupID, ident, className == excel::Object::ThisName() ? true : false);

DoEvent(ident, className, pObject->GetState(), arg);
}
Expand Down Expand Up @@ -186,9 +186,9 @@ std::shared_ptr<IObject> WorldModule::CreateObject(const Guid &self, const int s
std::shared_ptr<IPropertyManager> pPropertyManager = pObject->GetPropertyManager();
for (int i = 0; i < arg.GetCount() - 1; i += 2) {
const std::string &propertyName = arg.String(i);
if (excel::IObject::ConfigID() != propertyName && excel::IObject::ClassName() != propertyName &&
excel::IObject::SceneID() != propertyName && excel::IObject::ID() != propertyName &&
excel::IObject::GroupID() != propertyName) {
if (excel::Object::ConfigID() != propertyName && excel::Object::ClassName() != propertyName &&
excel::Object::SceneID() != propertyName && excel::Object::ID() != propertyName &&
excel::Object::GroupID() != propertyName) {
std::shared_ptr<IProperty> pArgProperty = pPropertyManager->GetElement(propertyName);
if (pArgProperty) {
switch (pArgProperty->GetType()) {
Expand Down Expand Up @@ -222,7 +222,7 @@ std::shared_ptr<IObject> WorldModule::CreateObject(const Guid &self, const int s
stream << " config_name: " << configIndex;
stream << " scene_id: " << sceneID;
stream << " group_id: " << groupID;
stream << " position: " << pObject->GetPropertyVector3(excel::IObject::Position()).ToString();
stream << " position: " << pObject->GetPropertyVector3(excel::Object::Position()).ToString();

LOG_INFO("%v", stream.str());

Expand Down Expand Up @@ -302,14 +302,14 @@ std::shared_ptr<IObject> WorldModule::CreateObject(const Guid &self, const int s
{
Vector3 vRelivePos = m_scene_->GetRelivePosition(sceneID, 0);

pObject->SetPropertyObject(excel::IObject::ID(), ident);
pObject->SetPropertyString(excel::IObject::ConfigID(), configIndex);
pObject->SetPropertyString(excel::IObject::ClassName(), className);
pObject->SetPropertyInt(excel::IObject::SceneID(), sceneID);
pObject->SetPropertyInt(excel::IObject::GroupID(), groupID);
pObject->SetPropertyVector3(excel::IObject::Position(), vRelivePos);
pObject->SetPropertyObject(excel::Object::ID(), ident);
pObject->SetPropertyString(excel::Object::ConfigID(), configIndex);
pObject->SetPropertyString(excel::Object::ClassName(), className);
pObject->SetPropertyInt(excel::Object::SceneID(), sceneID);
pObject->SetPropertyInt(excel::Object::GroupID(), groupID);
pObject->SetPropertyVector3(excel::Object::Position(), vRelivePos);

pContainerInfo->AddObjectToGroup(groupID, ident, className == excel::Player::ThisName() ? true : false);
pContainerInfo->AddObjectToGroup(groupID, ident, className == excel::Object::ThisName() ? true : false);

DoEvent(ident, className, pObject->GetState(), arg);
}
Expand Down Expand Up @@ -338,8 +338,8 @@ std::shared_ptr<IObject> WorldModule::CreateObject(const Guid &self, const int s
std::shared_ptr<IPropertyManager> pPropertyManager = pObject->GetPropertyManager();
for (int i = 0; i < arg.GetCount() - 1; i += 2) {
const std::string &propertyName = arg.String(i);
if (excel::IObject::ConfigID() != propertyName && excel::IObject::ClassName() != propertyName && excel::IObject::SceneID() != propertyName &&
excel::IObject::ID() != propertyName && excel::IObject::GroupID() != propertyName) {
if (excel::Object::ConfigID() != propertyName && excel::Object::ClassName() != propertyName && excel::Object::SceneID() != propertyName &&
excel::Object::ID() != propertyName && excel::Object::GroupID() != propertyName) {
std::shared_ptr<IProperty> pArgProperty = pPropertyManager->GetElement(propertyName);
if (pArgProperty) {
switch (pArgProperty->GetType()) {
Expand Down Expand Up @@ -373,7 +373,7 @@ std::shared_ptr<IObject> WorldModule::CreateObject(const Guid &self, const int s
stream << " config_name: " << configIndex;
stream << " scene_id: " << sceneID;
stream << " group_id: " << groupID;
stream << " position: " << pObject->GetPropertyVector3(excel::IObject::Position()).ToString();
stream << " position: " << pObject->GetPropertyVector3(excel::Object::Position()).ToString();

// m_log_->LogInfo(stream);

Expand Down Expand Up @@ -421,20 +421,20 @@ bool WorldModule::DestroyObject(const Guid &self) {
return DestroySelf(self);
}

const int sceneID = GetPropertyInt32(self, excel::IObject::SceneID());
const int groupID = GetPropertyInt32(self, excel::IObject::GroupID());
const int sceneID = GetPropertyInt32(self, excel::Object::SceneID());
const int groupID = GetPropertyInt32(self, excel::Object::GroupID());

std::shared_ptr<SceneInfo> pContainerInfo = m_scene_->GetElement(sceneID);
if (pContainerInfo) {
const std::string &className = GetPropertyString(self, excel::IObject::ClassName());
if (className == excel::Player::ThisName()) {
const std::string &className = GetPropertyString(self, excel::Object::ClassName());
if (className == excel::Object::ThisName()) {
m_scene_->LeaveSceneGroup(self);
}

DoEvent(self, className, COE_BEFOREDESTROY, DataList::Empty());
DoEvent(self, className, COE_DESTROY, DataList::Empty());

if (className != excel::Player::ThisName()) {
if (className != excel::Object::ThisName()) {
pContainerInfo->RemoveObjectFromGroup(groupID, self, false);
}

Expand Down Expand Up @@ -1134,7 +1134,7 @@ bool WorldModule::GetGroupObjectList(const int sceneID, const int groupID, const
continue;
}

if (this->GetPropertyString(xID, excel::IObject::ClassName()) == className && xID != noSelf) {
if (this->GetPropertyString(xID, excel::Object::ClassName()) == className && xID != noSelf) {
list.AddObject(xID);
}
}
Expand Down Expand Up @@ -1167,8 +1167,8 @@ bool WorldModule::LogInfo(const Guid ident) {

std::shared_ptr<IObject> pObject = GetObject(ident);
if (pObject) {
int sceneID = GetPropertyInt32(ident, excel::IObject::SceneID());
int groupID = GetPropertyInt32(ident, excel::IObject::GroupID());
int sceneID = GetPropertyInt32(ident, excel::Object::SceneID());
int groupID = GetPropertyInt32(ident, excel::Object::GroupID());
LOG_INFO("Guid<%v> SceneID<%v>", ident.ToString(), sceneID);
} else {
LOG_ERROR("Guid<%v> There is no object", ident.ToString());
Expand All @@ -1191,7 +1191,7 @@ int WorldModule::OnPropertyCommonEvent(const Guid &self, const std::string &prop
pFun->operator()(self, propertyName, oldVar, newVar, reason);
}

const std::string &className = xObject->GetPropertyString(excel::IObject::ClassName());
const std::string &className = xObject->GetPropertyString(excel::Object::ClassName());
std::map<std::string, std::list<PROPERTY_EVENT_FUNCTOR_PTR>>::iterator itClass = mtClassPropertyCallBackList.find(className);
if (itClass != mtClassPropertyCallBackList.end()) {
std::list<PROPERTY_EVENT_FUNCTOR_PTR>::iterator itList = itClass->second.begin();
Expand Down Expand Up @@ -1304,7 +1304,7 @@ int WorldModule::OnRecordCommonEvent(const Guid &self, const RECORD_EVENT_DATA &
}
}

const std::string &className = xObject->GetPropertyString(excel::IObject::ClassName());
const std::string &className = xObject->GetPropertyString(excel::Object::ClassName());
std::map<std::string, std::list<RECORD_EVENT_FUNCTOR_PTR>>::iterator itClass = mtClassRecordCallBackList.find(className);
if (itClass != mtClassRecordCallBackList.end()) {
std::list<RECORD_EVENT_FUNCTOR_PTR>::iterator itList = itClass->second.begin();
Expand Down

0 comments on commit 64ff5d5

Please sign in to comment.