mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-10-25 21:36:05 +03:00
feat(world): add skeleton for DayNight system
This commit is contained in:
parent
4418c789f9
commit
35e44e0976
@ -808,5 +808,12 @@ void ClientInitializeGame(int32_t continentID, const C3Vector& position) {
|
||||
ClientServices::SetMessageHandler(SMSG_NEW_WORLD, &NewWorldHandler, nullptr);
|
||||
ClientServices::SetMessageHandler(SMSG_LOGIN_VERIFY_WORLD, &LoginVerifyWorldHandler, nullptr);
|
||||
|
||||
auto record = g_mapDB.GetRecord(continentID);
|
||||
if (!record) {
|
||||
return;
|
||||
}
|
||||
|
||||
CWorld::LoadMap(record->m_directory, position, continentID);
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
@ -5,12 +5,8 @@
|
||||
|
||||
#include "console/Console.hpp"
|
||||
#include "world/World.hpp"
|
||||
|
||||
|
||||
uint32_t s_newZoneID = 0;
|
||||
C3Vector s_newPosition;
|
||||
float s_newFacing = 0.0f;
|
||||
const char* s_newMapname = nullptr;
|
||||
#include "db/Db.hpp"
|
||||
#include "event/Timer.hpp"
|
||||
|
||||
|
||||
int32_t NewWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
|
||||
@ -23,7 +19,16 @@ int32_t NewWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore
|
||||
msg->Get(s_newFacing);
|
||||
|
||||
if (msg->IsRead()) {
|
||||
// TODO
|
||||
auto record = g_mapDB.GetRecord(s_newZoneID);
|
||||
if (!record) {
|
||||
ConsoleWrite("Bad SMSG_NEW_WORLD zoneID\n", DEFAULT_COLOR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s_newMapname = record->m_directory;
|
||||
// TODO: EventSetTimer(0, LoadNewWorld, 1);
|
||||
// WORKAROUND:
|
||||
LoadNewWorld(nullptr);
|
||||
return 1;
|
||||
} else {
|
||||
ConsoleWrite("Bad SMSG_NEW_WORLD\n", DEFAULT_COLOR);
|
||||
@ -45,17 +50,19 @@ int32_t LoginVerifyWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CD
|
||||
|
||||
float facing;
|
||||
msg->Get(facing);
|
||||
// zoneID != ClntObjMgrGetMapID()
|
||||
if (false) {
|
||||
|
||||
if (false /* zoneID != ClntObjMgrGetMapID() */) {
|
||||
s_newFacing = facing;
|
||||
s_newPosition = position;
|
||||
s_newZoneID = zoneID;
|
||||
//if (zoneID < dword_AD4170 || zoneID > dword_AD416C || (v0 = *(_DWORD*)(dword_AD4180 + 4 * (zoneID - dword_AD4170))) == 0) {
|
||||
// ConsoleWrite("Bad SMSG_NEW_WORLD zoneID\n", 0);
|
||||
// return 0;
|
||||
//}
|
||||
//s_newMapname = *(_DWORD*)(v0 + 4);
|
||||
LoadNewWorld();
|
||||
auto record = g_mapDB.GetRecord(s_newZoneID);
|
||||
if (!record) {
|
||||
ConsoleWrite("Bad SMSG_NEW_WORLD zoneID\n", DEFAULT_COLOR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s_newMapname = record->m_directory;
|
||||
LoadNewWorld(nullptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include "gx/Transform.hpp"
|
||||
#include "gx/Draw.hpp"
|
||||
#include "gx/Shader.hpp"
|
||||
#include "world/CWorld.hpp"
|
||||
|
||||
#include <bc/Memory.hpp>
|
||||
#include <tempest/Matrix.hpp>
|
||||
@ -62,4 +63,5 @@ void CGWorldFrame::OnWorldUpdate() {
|
||||
}
|
||||
|
||||
void CGWorldFrame::OnWorldRender() {
|
||||
CWorld::Render();
|
||||
}
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
file(GLOB PRIVATE_SOURCES "*.cpp")
|
||||
file(GLOB PRIVATE_SOURCES
|
||||
"daynight/*.cpp"
|
||||
"map/*.cpp"
|
||||
"*.cpp"
|
||||
)
|
||||
|
||||
add_library(world STATIC
|
||||
${PRIVATE_SOURCES}
|
||||
@ -13,4 +17,9 @@ target_link_libraries(world
|
||||
PRIVATE
|
||||
gx
|
||||
model
|
||||
PUBLIC
|
||||
bc
|
||||
common
|
||||
storm
|
||||
tempest
|
||||
)
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
#include "gx/Device.hpp"
|
||||
#include "gx/Shader.hpp"
|
||||
#include "model/Model2.hpp"
|
||||
#include "world/map/CMap.hpp"
|
||||
#include "world/daynight/DayNight.hpp"
|
||||
|
||||
uint32_t CWorld::s_enables;
|
||||
uint32_t CWorld::s_enables2;
|
||||
@ -42,3 +44,11 @@ void CWorld::Initialize() {
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CWorld::LoadMap(const char* mapName, const C3Vector& position, int32_t zoneID) {
|
||||
CMap::Load(mapName, zoneID);
|
||||
}
|
||||
|
||||
void CWorld::Render() {
|
||||
DayNight::RenderSky();
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define WORLD_C_WORLD_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <tempest/Vector.hpp>
|
||||
|
||||
class CWorld {
|
||||
public:
|
||||
@ -47,6 +48,8 @@ class CWorld {
|
||||
|
||||
// Static functions
|
||||
static void Initialize(void);
|
||||
static void LoadMap(const char* mapName, const C3Vector& position, int32_t zoneID);
|
||||
static void Render();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,13 @@
|
||||
#include "world/World.hpp"
|
||||
|
||||
int32_t LoadNewWorld() {
|
||||
uint32_t s_newZoneID = 0;
|
||||
C3Vector s_newPosition;
|
||||
float s_newFacing = 0.0f;
|
||||
const char* s_newMapname = nullptr;
|
||||
|
||||
|
||||
int32_t LoadNewWorld(const void* eventData) {
|
||||
// TODO
|
||||
CWorld::LoadMap(s_newMapname, s_newPosition, s_newZoneID);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -3,6 +3,11 @@
|
||||
|
||||
#include "world/CWorld.hpp"
|
||||
|
||||
int32_t LoadNewWorld();
|
||||
extern uint32_t s_newZoneID;
|
||||
extern C3Vector s_newPosition;
|
||||
extern float s_newFacing;
|
||||
extern const char* s_newMapname;
|
||||
|
||||
int32_t LoadNewWorld(const void* eventData);
|
||||
|
||||
#endif
|
||||
|
||||
46
src/world/daynight/DNStars.cpp
Normal file
46
src/world/daynight/DNStars.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#include "world/daynight/DNStars.hpp"
|
||||
#include "model/Model2.hpp"
|
||||
#include <common/Time.hpp>
|
||||
|
||||
namespace DayNight {
|
||||
|
||||
void DNStars::Initialize() {
|
||||
this->m_scene = M2CreateScene();
|
||||
this->m_model = this->m_scene->CreateModel("Environments\\Stars\\stars.mdl", 0);
|
||||
this->m_time = OsGetAsyncTimeMs();
|
||||
}
|
||||
|
||||
void DNStars::Destroy() {
|
||||
if (this->m_model) {
|
||||
this->m_model->Release();
|
||||
this->m_model = nullptr;
|
||||
}
|
||||
|
||||
if (this->m_scene) {
|
||||
// TODO: this->m_scene->Release();
|
||||
this->m_scene = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void DNStars::Update() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void DNStars::Render() {
|
||||
if (this->m_color.a < 2) {
|
||||
//return;
|
||||
}
|
||||
|
||||
this->m_model->SetAnimating(1);
|
||||
|
||||
// TODO
|
||||
|
||||
uint32_t elapsed = OsGetAsyncTimeMs() - this->m_time;
|
||||
this->m_time += elapsed;
|
||||
this->m_scene->AdvanceTime(elapsed);
|
||||
this->m_scene->Animate(C3Vector());
|
||||
this->m_scene->Draw(M2PASS_0);
|
||||
this->m_scene->Draw(M2PASS_1);
|
||||
}
|
||||
|
||||
} // namespace DayNight
|
||||
32
src/world/daynight/DNStars.hpp
Normal file
32
src/world/daynight/DNStars.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef WORLD_DAY_NIGHT_STARS_HPP
|
||||
#define WORLD_DAY_NIGHT_STARS_HPP
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
#include <tempest/Vector.hpp>
|
||||
|
||||
|
||||
class CM2Scene;
|
||||
class CM2Model;
|
||||
|
||||
|
||||
namespace DayNight {
|
||||
|
||||
class DNStars {
|
||||
public:
|
||||
void Initialize();
|
||||
void Destroy();
|
||||
void Update();
|
||||
void Render();
|
||||
|
||||
CM2Scene* m_scene = nullptr;
|
||||
CM2Model* m_model = nullptr;
|
||||
CImVector m_color { 0 };
|
||||
C3Vector m_pos;
|
||||
uint32_t m_time = 0;
|
||||
};
|
||||
|
||||
} // namespace DayNight
|
||||
|
||||
|
||||
#endif
|
||||
20
src/world/daynight/DayNight.cpp
Normal file
20
src/world/daynight/DayNight.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "world/daynight/DayNight.hpp"
|
||||
#include "world/daynight/DNStars.hpp"
|
||||
|
||||
|
||||
namespace DayNight {
|
||||
|
||||
static DNStars g_stars;
|
||||
|
||||
|
||||
void LoadMap(int32_t zoneID) {
|
||||
// TODO
|
||||
g_stars.Initialize();
|
||||
}
|
||||
|
||||
void RenderSky() {
|
||||
// TODO
|
||||
g_stars.Render();
|
||||
}
|
||||
|
||||
} // namespace DayNight
|
||||
13
src/world/daynight/DayNight.hpp
Normal file
13
src/world/daynight/DayNight.hpp
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef WORLD_DAY_NIGHT_HPP
|
||||
#define WORLD_DAY_NIGHT_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace DayNight {
|
||||
|
||||
void LoadMap(int32_t zoneID);
|
||||
void RenderSky();
|
||||
|
||||
} // namespace DayNight
|
||||
|
||||
#endif
|
||||
7
src/world/map/CMap.cpp
Normal file
7
src/world/map/CMap.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "world/map/CMap.hpp"
|
||||
#include "world/daynight/DayNight.hpp"
|
||||
|
||||
|
||||
void CMap::Load(const char* mapName, int32_t zoneID) {
|
||||
DayNight::LoadMap(zoneID);
|
||||
}
|
||||
11
src/world/map/CMap.hpp
Normal file
11
src/world/map/CMap.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef WORLD_C_MAP_HPP
|
||||
#define WORLD_C_MAP_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class CMap {
|
||||
public:
|
||||
static void Load(const char* mapName, int32_t zoneID);
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue
Block a user