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;
|
|
|
|
auto* phantomPhysicsComponent = self->GetComponent<PhantomPhysicsComponent>();
|
|
|
|
if (!phantomPhysicsComponent) return;
|
|
|
|
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
|
|
|
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE);
|
|
|
|
phantomPhysicsComponent->SetDirectionalMultiplier(repelForce);
|
2024-01-29 07:53:12 +00:00
|
|
|
phantomPhysicsComponent->SetDirection(NiPoint3Constant::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;
|
|
|
|
auto* skillComponent = self->GetComponent<SkillComponent>();
|
|
|
|
if (!skillComponent) return;
|
|
|
|
skillComponent->CastSkill(m_SkillCastID, target->GetObjectID());
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|