#include "AgLaserSensorServer.h" #include "PhantomPhysicsComponent.h" #include "SkillComponent.h" #include "ePhysicsEffectType.h" void AgLaserSensorServer::OnStartup(Entity* self) { self->SetBoolean(u"active", true); auto repelForce = self->GetVarAs(u"repelForce"); if (!repelForce) repelForce = m_RepelForce; auto phantomPhysicsComponent = self->GetComponent(); if (!phantomPhysicsComponent) return; phantomPhysicsComponent->SetPhysicsEffectActive(true); phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE); phantomPhysicsComponent->SetDirectionalMultiplier(repelForce); phantomPhysicsComponent->SetDirection(NiPoint3::UNIT_Y); } void AgLaserSensorServer::OnCollisionPhantom(Entity* self, Entity* target) { auto active = self->GetVar(u"active"); if (!active) return; auto skillCastID = self->GetVarAs(u"skillCastID"); if (skillCastID == 0) skillCastID = m_SkillCastID; auto skillComponent = self->GetComponent(); if (!skillComponent) return; skillComponent->CastSkill(m_SkillCastID, target->GetObjectID()); }