MCPcopy Create free account
hub / github.com/OpenArkStudio/ARK / CreateAnPlayerAndInit

Method CreateAnPlayerAndInit

samples/sample3/Sample3Module.cpp:230–261  ·  view source on GitHub ↗

-----------------------------inner interface--------------------------------------------

Source from the content-addressed store, hash-verified

228
229//-----------------------------inner interface--------------------------------------------
230std::shared_ptr<ark::AFIEntity> Sample3Module::CreateAnPlayerAndInit()
231{
232 // create object
233 auto pEntity =
234 m_pKernelModule->CreateEntity(NULL_GUID, MPA_ID, 0, AFEntityMetaPlayer::self_name(), NULL_INT, AFCDataList());
235 ARK_ASSERT_RET_VAL(pEntity != nullptr, nullptr);
236
237 // init data
238 pEntity->SetString(AFEntityMetaPlayer::name(), "Xiaoming");
239 pEntity->SetInt32(AFEntityMetaPlayer::gender(), 1);
240 pEntity->SetInt32(AFEntityMetaPlayer::career(), 1);
241 pEntity->SetInt32(AFEntityMetaPlayer::camp(), 1);
242 pEntity->SetInt32(AFEntityMetaPlayer::last_map_id(), 1);
243 pEntity->SetInt32(AFEntityMetaPlayer::level(), 1);
244
245 AFITable* pTable = pEntity->FindTable(RECORD_NAME);
246 ARK_ASSERT_RET_VAL(pTable != nullptr, nullptr);
247
248 auto pRow = pTable->AddRow(0);
249 ARK_ASSERT_RET_VAL(pRow != nullptr, nullptr);
250 pRow->SetInt64(col_guid, 1111);
251
252 if (!pEntity->FindCustomData("test"))
253 {
254 pEntity->AddCustomInt32("test", 111);
255 }
256
257 std::cout << "CreatePlayer name " << pEntity->GetString(AFEntityMetaPlayer::name()).c_str() << " "
258 << AFEntityMetaPlayer::gender() << pEntity->GetInt32(AFEntityMetaPlayer::gender()) << std::endl;
259
260 return pEntity;
261}
262
263void Sample3Module::QueryStringTest(const AFGUID& guid, size_t count, const uint32_t index)
264{

Callers

nothing calls this directly

Calls 11

CreateEntityMethod · 0.80
AddRowMethod · 0.80
FindCustomDataMethod · 0.80
AddCustomInt32Method · 0.80
SetStringMethod · 0.45
SetInt32Method · 0.45
FindTableMethod · 0.45
SetInt64Method · 0.45
c_strMethod · 0.45
GetStringMethod · 0.45
GetInt32Method · 0.45

Tested by

no test coverage detected