mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-26 15:37:20 +00:00
doesnt compile
This commit is contained in:
parent
b2fee29ee0
commit
45bcc80a1b
@ -504,10 +504,7 @@ void Entity::Initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AddCallbackTimer(0.0f, [this]() {
|
AddCallbackTimer(0.0f, [this]() {
|
||||||
auto scripts = CppScripts::GetEntityScripts(this);
|
GetScript()->OnStartup(this);
|
||||||
std::for_each(scripts.begin(), scripts.end(), [this](const auto& script) {
|
|
||||||
script->OnStartup(this);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load data specific to this LOT first. These act as defaults for the components.
|
// Load data specific to this LOT first. These act as defaults for the components.
|
||||||
@ -523,7 +520,7 @@ void Entity::Initialize() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Startup all the components. Some components need or want data from other components so
|
* Startup all the components. Some components need or want data from other components so
|
||||||
* we want to ensure that
|
* we want to ensure that
|
||||||
* A) Most if not all components are newed and ready to be accessed.
|
* A) Most if not all components are newed and ready to be accessed.
|
||||||
* B) All components have their personal data loaded and ready to be used.
|
* B) All components have their personal data loaded and ready to be used.
|
||||||
@ -533,7 +530,7 @@ void Entity::Initialize() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Load the player save data from XML. Ideally we do this after all initialization so the player
|
* Load the player save data from XML. Ideally we do this after all initialization so the player
|
||||||
* save data overrides any defaults that may be applied.
|
* save data overrides any defaults that may be applied.
|
||||||
*/
|
*/
|
||||||
if (!IsPlayer()) std::for_each(m_Components.begin(), m_Components.end(), [this](auto& component) {
|
if (!IsPlayer()) std::for_each(m_Components.begin(), m_Components.end(), [this](auto& component) {
|
||||||
@ -647,7 +644,7 @@ void Entity::SetGMLevel(eGameMasterLevel value) {
|
|||||||
GameMessages::SendGMLevelBroadcast(m_ObjectID, value);
|
GameMessages::SendGMLevelBroadcast(m_ObjectID, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType) {
|
void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, const eReplicaPacketType packetType) {
|
||||||
if (packetType == eReplicaPacketType::CONSTRUCTION) {
|
if (packetType == eReplicaPacketType::CONSTRUCTION) {
|
||||||
outBitStream->Write(m_ObjectID);
|
outBitStream->Write(m_ObjectID);
|
||||||
outBitStream->Write(m_TemplateID);
|
outBitStream->Write(m_TemplateID);
|
||||||
@ -768,7 +765,7 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType) {
|
void Entity::WriteComponents(RakNet::BitStream* outBitStream, const eReplicaPacketType packetType) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -787,34 +784,36 @@ void Entity::UpdateXMLDoc(tinyxml2::XMLDocument* doc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CppScripts::Script* Entity::GetScript() const {
|
||||||
|
auto* scriptComponent = GetComponent<ScriptComponent>();
|
||||||
|
auto* script = scriptComponent->GetScript();
|
||||||
|
DluAssert(script != nullptr);
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
|
||||||
void Entity::Update(const float deltaTime) {
|
void Entity::Update(const float deltaTime) {
|
||||||
uint32_t timerPosition;
|
auto namedTimerItr = std::remove_if(m_Timers.begin(), m_Timers.end(), [this, &deltaTime](EntityTimer* timer) {
|
||||||
timerPosition = 0;
|
timer->Update(deltaTime);
|
||||||
while (timerPosition < m_Timers.size()) {
|
if (timer->GetTime() <= 0) {
|
||||||
m_Timers[timerPosition]->Update(deltaTime);
|
GetScript()->OnTimerDone(this, timer->GetName());
|
||||||
if (m_Timers[timerPosition]->GetTime() <= 0) {
|
|
||||||
const auto timerName = m_Timers[timerPosition]->GetName();
|
|
||||||
|
|
||||||
delete m_Timers[timerPosition];
|
|
||||||
m_Timers.erase(m_Timers.begin() + timerPosition);
|
|
||||||
|
|
||||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
|
||||||
script->OnTimerDone(this, timerName);
|
|
||||||
}
|
|
||||||
TriggerEvent(eTriggerEventType::TIMER_DONE, this);
|
TriggerEvent(eTriggerEventType::TIMER_DONE, this);
|
||||||
} else {
|
delete timer;
|
||||||
timerPosition++;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
return false;
|
||||||
|
});
|
||||||
|
m_Timers.erase(namedTimerItr, m_Timers.end());
|
||||||
|
|
||||||
for (int i = 0; i < m_CallbackTimers.size(); i++) {
|
auto callbackTimerItr = std::remove_if(m_CallbackTimers.begin(), m_CallbackTimers.end(), [this, &deltaTime](EntityCallbackTimer* timer) {
|
||||||
m_CallbackTimers[i]->Update(deltaTime);
|
timer->Update(deltaTime);
|
||||||
if (m_CallbackTimers[i]->GetTime() <= 0) {
|
if (timer->GetTime() <= 0) {
|
||||||
m_CallbackTimers[i]->GetCallback()();
|
timer->GetCallback()();
|
||||||
delete m_CallbackTimers[i];
|
delete timer;
|
||||||
m_CallbackTimers.erase(m_CallbackTimers.begin() + i);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
return false;
|
||||||
|
});
|
||||||
|
m_CallbackTimers.erase(callbackTimerItr, m_CallbackTimers.end());
|
||||||
|
|
||||||
// Add pending timers to the list of timers so they start next tick.
|
// Add pending timers to the list of timers so they start next tick.
|
||||||
if (m_PendingTimers.size() > 0) {
|
if (m_PendingTimers.size() > 0) {
|
||||||
@ -1294,10 +1293,6 @@ void Entity::CancelTimer(const std::string& name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Entity::CancelAllTimers() {
|
void Entity::CancelAllTimers() {
|
||||||
/*for (auto timer : m_Timers) {
|
|
||||||
if (timer) delete timer;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
for (auto* timer : m_Timers) {
|
for (auto* timer : m_Timers) {
|
||||||
delete timer;
|
delete timer;
|
||||||
}
|
}
|
||||||
|
@ -223,6 +223,7 @@ public:
|
|||||||
|
|
||||||
virtual NiPoint3 GetRespawnPosition() const { return NiPoint3::ZERO; }
|
virtual NiPoint3 GetRespawnPosition() const { return NiPoint3::ZERO; }
|
||||||
virtual NiQuaternion GetRespawnRotation() const { return NiQuaternion::IDENTITY; }
|
virtual NiQuaternion GetRespawnRotation() const { return NiQuaternion::IDENTITY; }
|
||||||
|
CppScripts::Script* GetScript() const;
|
||||||
|
|
||||||
void Sleep();
|
void Sleep();
|
||||||
void Wake();
|
void Wake();
|
||||||
|
@ -36,6 +36,7 @@ set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp"
|
|||||||
"RigidbodyPhantomPhysicsComponent.cpp"
|
"RigidbodyPhantomPhysicsComponent.cpp"
|
||||||
"MultiZoneEntranceComponent.cpp"
|
"MultiZoneEntranceComponent.cpp"
|
||||||
"RocketLaunchpadControlComponent.cpp"
|
"RocketLaunchpadControlComponent.cpp"
|
||||||
|
"ScriptComponent.cpp"
|
||||||
"ScriptedActivityComponent.cpp"
|
"ScriptedActivityComponent.cpp"
|
||||||
"ShootingGalleryComponent.cpp"
|
"ShootingGalleryComponent.cpp"
|
||||||
"SimplePhysicsComponent.cpp"
|
"SimplePhysicsComponent.cpp"
|
||||||
|
@ -11,7 +11,6 @@ set(DSCRIPTS_SOURCES
|
|||||||
"Darkitect.cpp"
|
"Darkitect.cpp"
|
||||||
"NPCAddRemoveItem.cpp"
|
"NPCAddRemoveItem.cpp"
|
||||||
"NtFactionSpyServer.cpp"
|
"NtFactionSpyServer.cpp"
|
||||||
"ScriptComponent.cpp"
|
|
||||||
"ScriptedPowerupSpawner.cpp"
|
"ScriptedPowerupSpawner.cpp"
|
||||||
"SpawnPetBaseServer.cpp")
|
"SpawnPetBaseServer.cpp")
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@
|
|||||||
#include "WildNinjaSensei.h"
|
#include "WildNinjaSensei.h"
|
||||||
#include "WildNinjaBricks.h"
|
#include "WildNinjaBricks.h"
|
||||||
|
|
||||||
InvalidScript* CppScripts::invalidToReturn = new InvalidScript();
|
std::unique_ptr<InvalidScript> CppScripts::invalidScript = std::make_unique<InvalidScript>();
|
||||||
std::map<std::string, CppScripts::Script*> CppScripts::m_Scripts;
|
std::map<std::string, CppScripts::Script*> CppScripts::m_Scripts;
|
||||||
|
|
||||||
CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scriptName) {
|
CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scriptName) {
|
||||||
@ -324,7 +324,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
|||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
script = invalidToReturn;
|
script = invalidScript.get();
|
||||||
|
|
||||||
//VE / AG:
|
//VE / AG:
|
||||||
if (scriptName == "scripts\\ai\\AG\\L_AG_SHIP_PLAYER_DEATH_TRIGGER.lua")
|
if (scriptName == "scripts\\ai\\AG\\L_AG_SHIP_PLAYER_DEATH_TRIGGER.lua")
|
||||||
@ -926,7 +926,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
|||||||
|
|
||||||
// handle invalid script reporting if the path is greater than zero and it's not an ignored script
|
// handle invalid script reporting if the path is greater than zero and it's not an ignored script
|
||||||
// information not really needed for sys admins but is for developers
|
// information not really needed for sys admins but is for developers
|
||||||
else if (script == invalidToReturn) {
|
else if (script == invalidScript.get()) {
|
||||||
if ((scriptName.length() > 0) && !((scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua") ||
|
if ((scriptName.length() > 0) && !((scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua") ||
|
||||||
(scriptName == "scripts\\02_server\\Enemy\\General\\L_BASE_ENEMY_SPIDERLING.lua") ||
|
(scriptName == "scripts\\02_server\\Enemy\\General\\L_BASE_ENEMY_SPIDERLING.lua") ||
|
||||||
(scriptName =="scripts\\ai\\FV\\L_ACT_NINJA_STUDENT.lua") ||
|
(scriptName =="scripts\\ai\\FV\\L_ACT_NINJA_STUDENT.lua") ||
|
||||||
@ -938,22 +938,3 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
|||||||
m_Scripts[scriptName] = script;
|
m_Scripts[scriptName] = script;
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CppScripts::Script*> CppScripts::GetEntityScripts(Entity* entity) {
|
|
||||||
std::vector<CppScripts::Script*> scripts;
|
|
||||||
auto comps = entity->GetScriptComponents();
|
|
||||||
for (auto& scriptComp : comps) {
|
|
||||||
if (scriptComp != nullptr) {
|
|
||||||
scripts.push_back(scriptComp->GetScript());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return scripts;
|
|
||||||
}
|
|
||||||
|
|
||||||
CppScripts::Script::Script() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
CppScripts::Script::~Script() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ enum class eRebuildState : uint32_t;
|
|||||||
|
|
||||||
namespace CppScripts {
|
namespace CppScripts {
|
||||||
|
|
||||||
extern InvalidScript* invalidToReturn;
|
extern std::unique_ptr<InvalidScript> invalidScript;
|
||||||
extern std::map<std::string, CppScripts::Script*> m_Scripts;
|
extern std::map<std::string, CppScripts::Script*> m_Scripts;
|
||||||
/**
|
/**
|
||||||
* Base class for all scripts. Includes virtual methods to be overridden to handle LUA equivelent events.
|
* Base class for all scripts. Includes virtual methods to be overridden to handle LUA equivelent events.
|
||||||
@ -33,8 +34,7 @@ namespace CppScripts {
|
|||||||
*/
|
*/
|
||||||
class Script {
|
class Script {
|
||||||
public:
|
public:
|
||||||
Script();
|
virtual ~Script() = default;
|
||||||
~Script();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked one frame after the script is loaded.
|
* Invoked one frame after the script is loaded.
|
||||||
@ -365,5 +365,4 @@ namespace CppScripts {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Script* GetScript(Entity* parent, const std::string& scriptName);
|
Script* GetScript(Entity* parent, const std::string& scriptName);
|
||||||
std::vector<Script*> GetEntityScripts(Entity* entity);
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user