31
Modding / Re: Misc modding questions that are too minor to warrant their own thread
« on: January 07, 2024, 08:19:07 PM »
I have this running off a single deco weapon that's on a single ship on an EveryFrameWeaponEffect, here's the entire advance method:
Code
@Override
public void advance(float amount, CombatEngineAPI engine, WeaponAPI weapon) {
if(!runOnce)
{
runOnce=true;
ship=weapon.getShip();
for(WeaponAPI w : ship.getAllWeapons())
{
switch (w.getSlot().getId())
{
case "A_GUN":
if(armL==null)
{
armL = w;
}
break;
case "A_GUN2":
if(armR==null)
{
armR= w;
}
break;
case "E_RSHOULDER":
shoulderR = w;
originalShoulderPos = shoulderR.getSprite().getCenterY();
break;
case "E_LSHOULDER":
shoulderL = w;
originalShoulderPosL = shoulderL.getSprite().getCenterY();
break;
case "WS0003":
turretR = w;
break;
case "WS0001":
if(turretL == null)
turretL = w;
break;
case "E_DECO":
if(decoL == null)
decoL = w;
break;
case "E_DECO_R":
decoR = w;
break;
//break;
}
}
}
if (armL==null) {
return;
}
float sineA=0, sinceB=0;
float global=ship.getFacing();
float aim=MathUtils.getShortestRotation(global, weapon.getCurrAngle());
//*End animation math stuff
//Right arm + shoulder
weapon.setCurrAngle(ship.getFacing() + MathUtils.getShortestRotation(ship.getFacing(),armL.getCurrAngle())*0.7f);
weapon.getSprite().setCenterY(originalShoulderPos+(2*armL.getCooldownRemaining()/armL.getCooldown()));
//turretL.setCurrAngle(ship.getFacing() + MathUtils.getShortestRotation(ship.getFacing(),armL.getCurrAngle())*0.7f);
if(armR != null)
{
shoulderR.setCurrAngle(ship.getFacing() + MathUtils.getShortestRotation(ship.getFacing(),armR.getCurrAngle())*0.7f);
shoulderR.getSprite().setCenterY(originalShoulderPos+(2*armR.getCooldownRemaining()/armR.getCooldown()));
}
ship.syncWeaponDecalsWithArmorDamage();
List<ShipAPI> children = ship.getChildModulesCopy();
if(children != null && !lostmodules)
{
for(ShipAPI module: children)
{
module.ensureClonedStationSlotSpec();
if(module.getStationSlot() != null)
{
if(ship.getSystem().isActive())
{
module.getFluxTracker().showOverloadFloatyIfNeeded("Emergency Purge!", Color.yellow, 4f, true);
ShipAPI s = engine.getFleetManager(ship.getOwner()).spawnFleetMember(module.getFleetMember(),ship.getLocation(),ship.getFacing(),0f);
//m.setStationSlot(null);
lostmodules = true;
//m.setHitpoints(0f);
//engine.removeEntity(m);
break;
}
}
}
}
}