2021-12-05 17:54:36 +00:00
|
|
|
#include "AgLaserSensorServer.h"
|
|
|
|
|
2022-07-05 06:00:10 +00:00
|
|
|
#include "PhantomPhysicsComponent.h"
|
|
|
|
#include "SkillComponent.h"
|
2023-03-25 10:26:39 +00:00
|
|
|
#include "ePhysicsEffectType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void AgLaserSensorServer::OnStartup(Entity* self) {
|
2023-05-13 23:21:17 +00:00
|
|
|
self->SetBoolean(u"active", true);
|
|
|
|
auto repelForce = self->GetVarAs<float>(u"repelForce");
|
|
|
|
if (!repelForce) repelForce = m_RepelForce;
|
2023-06-07 07:23:50 +00:00
|
|
|
auto phantomPhysicsComponent = self->GetComponent<PhantomPhysicsComponent>();
|
2023-05-13 23:21:17 +00:00
|
|
|
if (!phantomPhysicsComponent) return;
|
|
|
|
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
|
|
|
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE);
|
|
|
|
phantomPhysicsComponent->SetDirectionalMultiplier(repelForce);
|
|
|
|
phantomPhysicsComponent->SetDirection(NiPoint3::UNIT_Y);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AgLaserSensorServer::OnCollisionPhantom(Entity* self, Entity* target) {
|
2023-05-13 23:21:17 +00:00
|
|
|
auto active = self->GetVar<bool>(u"active");
|
|
|
|
if (!active) return;
|
|
|
|
auto skillCastID = self->GetVarAs<float>(u"skillCastID");
|
|
|
|
if (skillCastID == 0) skillCastID = m_SkillCastID;
|
2023-06-07 07:23:50 +00:00
|
|
|
auto skillComponent = self->GetComponent<SkillComponent>();
|
2023-05-13 23:21:17 +00:00
|
|
|
if (!skillComponent) return;
|
|
|
|
skillComponent->CastSkill(m_SkillCastID, target->GetObjectID());
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|