1
Modding / Re: How to replace a class?
« on: April 14, 2021, 11:17:43 AM »You need to replace the PersonBountyManager with a version that generates instances of your person bounty class instead of the vanilla one.
I did some searching and turns out, there's a way to do it easily in the particular case of the PersonBountyManager. In your mod plugin:Code: javapublic void onGameLoad() {
/* bounty manager is added on every game load, so we need to remove it on every game load */
Global.getSector().removeScript(PersonBountyManager.getInstance());
if (!sector.hasScript(MyModifiedPersonBountyManager.class)) {
Global.getSector().addScript(new MyModifiedPersonBountyManager());
}
}
Thank you for your help!
I'm kinda new to Java and completely new to Starsector modding, so sorry for my noobish questions, but:
1. Do I include this code into my class or I need to create some other script? If another script - what exaclty script or where can I read about it? If into my class - does '!sector' mean that I need to call it from somewhere like 'Global' cause it is marked as error if I put it like it is?
2. Do I need to change the name of my class somehow so it will be not the same as replaced class'es name from Vanilla?