mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 09:44:10 +00:00
comments from movementAI branch (#1483)
tests tested that red green and yellow bots waved when interacted with tested that construction robot races when interacted with wandering vendor does nothing before and after, but script is ready for use when npcs are implemented. add scripts for robot city
This commit is contained in:
@@ -15,7 +15,9 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_AM
|
||||
"AmSkullkinDrillStand.cpp"
|
||||
"AmSkullkinTower.cpp"
|
||||
"AmBlueX.cpp"
|
||||
"AmTeapotServer.cpp")
|
||||
"AmTeapotServer.cpp"
|
||||
"WanderingVendor.cpp"
|
||||
)
|
||||
|
||||
add_library(dScriptsServerMapAM ${DSCRIPTS_SOURCES_02_SERVER_MAP_AM})
|
||||
target_include_directories(dScriptsServerMapAM PUBLIC ".")
|
||||
|
33
dScripts/02_server/Map/AM/WanderingVendor.cpp
Normal file
33
dScripts/02_server/Map/AM/WanderingVendor.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "WanderingVendor.h"
|
||||
#include "MovementAIComponent.h"
|
||||
#include "ProximityMonitorComponent.h"
|
||||
|
||||
void WanderingVendor::OnStartup(Entity* self) {
|
||||
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
|
||||
if (!movementAIComponent) return;
|
||||
// movementAIComponent->Resume();
|
||||
self->SetProximityRadius(10, "playermonitor");
|
||||
}
|
||||
|
||||
void WanderingVendor::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
|
||||
if (status == "ENTER" && entering->IsPlayer()) {
|
||||
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
|
||||
if (!movementAIComponent) return;
|
||||
// movementAIComponent->Pause();
|
||||
self->CancelTimer("startWalking");
|
||||
} else if (status == "LEAVE") {
|
||||
auto* proximityMonitorComponent = self->GetComponent<ProximityMonitorComponent>();
|
||||
if (!proximityMonitorComponent) self->AddComponent<ProximityMonitorComponent>();
|
||||
|
||||
const auto proxObjs = proximityMonitorComponent->GetProximityObjects("playermonitor");
|
||||
if (proxObjs.empty()) self->AddTimer("startWalking", 1.5);
|
||||
}
|
||||
}
|
||||
|
||||
void WanderingVendor::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "startWalking") {
|
||||
auto movementAIComponent = self->GetComponent<MovementAIComponent>();
|
||||
if (!movementAIComponent) return;
|
||||
// movementAIComponent->Resume();
|
||||
}
|
||||
}
|
13
dScripts/02_server/Map/AM/WanderingVendor.h
Normal file
13
dScripts/02_server/Map/AM/WanderingVendor.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef __WANDERINGVENDOR__H__
|
||||
#define __WANDERINGVENDOR__H__
|
||||
|
||||
#include "CppScripts.h"
|
||||
|
||||
class WanderingVendor : public CppScripts::Script {
|
||||
public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
|
||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||
};
|
||||
|
||||
#endif //!__WANDERINGVENDOR__H__
|
Reference in New Issue
Block a user