mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
using initial weapon dirs
This commit is contained in:
+14
-2
@@ -66,6 +66,12 @@ namespace battleship{
|
||||
|
||||
components.push_back(Component(node, rotSpeed, angleConstr, vertical));
|
||||
}
|
||||
|
||||
//using the last node to determine a weapon's init direction
|
||||
Node *node = components[components.size() - 1].node;
|
||||
Vector3 p0 = unit->getModel()->globalToLocalPosition(node->localToGlobalPosition(Vector3::VEC_ZERO));
|
||||
Vector3 p1 = unit->getModel()->globalToLocalPosition(node->localToGlobalPosition(Vector3::VEC_K));
|
||||
initUnitSpaceDir = (p1 - p0).norm();
|
||||
}
|
||||
|
||||
void Weapon::initProjectileData(sol::table weaponTable){
|
||||
@@ -131,8 +137,14 @@ namespace battleship{
|
||||
if((Order::TYPE)ordTp == Order::TYPE::ATTACK && withinRange && withinAngle)
|
||||
fire(unit->getOrder(0));
|
||||
}
|
||||
else
|
||||
trackTarget(unit->getPos() + unit->getDirVec());
|
||||
else{
|
||||
Vector3 dir = (
|
||||
initUnitSpaceDir.x * unit->getLeftVec() +
|
||||
initUnitSpaceDir.y * unit->getUpVec() +
|
||||
initUnitSpaceDir.z * unit->getDirVec()
|
||||
).norm();
|
||||
trackTarget(unit->getPos() + dir);
|
||||
}
|
||||
}
|
||||
|
||||
void Weapon::useFx(FxManager::Fx *fx, Vector3 targPos, bool fire){
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace battleship{
|
||||
|
||||
struct Component{
|
||||
vb01::Node *node = nullptr;
|
||||
vb01::Vector3 initUnitSpaceDir;
|
||||
float rotSpeed, angleConstr;
|
||||
bool vertical;
|
||||
|
||||
@@ -53,7 +54,7 @@ namespace battleship{
|
||||
vb01::s64 lastFireTime = 0;
|
||||
FxManager::Fx *fireFx = nullptr;
|
||||
vb01::Quaternion projRot;
|
||||
vb01::Vector3 projPos;
|
||||
vb01::Vector3 projPos, initUnitSpaceDir;
|
||||
vb01::Node *projPar = nullptr;
|
||||
static std::string LASER_FLAG;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user