Fractal Softworks Forum

Starsector => Mods => Modding => Topic started by: cjy4312 on November 29, 2020, 10:55:50 AM

Title: [0.9.1a RC8]bugReport: ship.setSprite in Hullmod is not working properly
Post by: cjy4312 on November 29, 2020, 10:55:50 AM
Hi Alex!
I had some problems when I using ship.setSprite() in Hullmod. :P
I'm trying to use this code to change my ship's sprite and flux dissipation when all wings removed.
Code
public void applyEffectsAfterShipCreation(ShipAPI ship, String id){
        if(ship.getVariant().getWings().isEmpty()){
            ship.setSprite("CTB_Ship", "ctb_mycarrier_redrunway");
            ship.getMutableStats().getFluxDissipation().modifyMult(id, 2f);
        }else{
            ship.getMutableStats().getFluxDissipation().unmodify(id);
        }
    }
The ship is rendered in the wrong position when I removed all wings
(I must reselect the ship then it will set "redrunway" sprite and increase flux dissipation,but when I re-added any wing to the ship,sprite and flux dissipation will be reset immediately. )/(picture.a&picture.b)

There is another issue when ship join battle with no wings,I don't know how to describe it,as shown in picture.c

I uploaded a video to show these issues:
https://www.bilibili.com/video/BV1eK4y1f7BV

[attachment deleted by admin]
Title: Re: [0.9.1a RC8]bugReport: ship.setSprite in Hullmod is not working properly
Post by: cjy4312 on November 29, 2020, 11:34:12 AM
oh no  :-[
I forgot test this code in Campaign

I even tried move this code into advanceInCombat.  maybe ".setSprite" is not worked in Campaign? :-[


Title: Re: [0.9.1a RC8]bugReport: ship.setSprite in Hullmod is not working properly
Post by: Alex on November 29, 2020, 11:56:19 AM
Hi! It looks like you're probably not setting the sprite's center? Assuming the replacement sprite is the same size as the original - which iirc it needs to be - the center needs to be set to be the same as the original sprite.

newSprite.setCenter(oldSprite.getCenterX(), oldSprite.getCenterY())

Or some such...
Title: Re: [0.9.1a RC8]bugReport: ship.setSprite in Hullmod is not working properly
Post by: cjy4312 on November 29, 2020, 12:02:29 PM
I changed “wolf_Starting”  to get my ship in campaign, when ship created by "no wing" variant,It looked like pic.b.
when I add a wing ,sprite and flux dissipation will be reset but not turn back again after I remove that wing :(
Title: Re: [0.9.1a RC8]bugReport: ship.setSprite in Hullmod is not working properly
Post by: cjy4312 on November 29, 2020, 12:08:32 PM
but setCenter is worked,thank you!
Title: Re: [0.9.1a RC8]bugReport: ship.setSprite in Hullmod is not working properly
Post by: cjy4312 on November 29, 2020, 12:23:10 PM
Hi! It looks like you're probably not setting the sprite's center? Assuming the replacement sprite is the same size as the original - which iirc it needs to be - the center needs to be set to be the same as the original sprite.

newSprite.setCenter(oldSprite.getCenterX(), oldSprite.getCenterY())

Or some such...
setCenter worked,thank you!
but setSprite is still not working in campain
I tried use shipsystem to run that code in campain combat, it's okay,but it just not work in Hullmod.applyEffectsAfterShipCreation  :(