Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Suggestion: put hullmod incompatibility checks in their own silos  (Read 586 times)

ShadowDragon8685

  • Ensign
  • *
  • Posts: 45
    • View Profile

So, I've just had a devil of a time troubleshooting a problem I had: I wanted to make a set of Logistics hullmods, alternative implementations to the vanilla Augmented Drive Field hullmod. They needed to be incompatible with one another and the vanilla Augmented Drive Field, as well as counting-as Logistics hullmods.

What I discovered, after considerable trial-and-error, was that the way vanilla hullmod incompatibilities are handled, and the way vanilla Logistic hullmods being rejected for the ship already having too many Logistic hullmods, was the same implementation; an @override, specifically something like this:

Code
@override
public boolean isApplicableToShip(ShipAPI ship) {...};
public String getUnapplicableReason(ShipAPI ship) {...};

Thus, when I implemented the hullmod incompatibility checks (so you couldn't detune the engines at the cost of Burn for fuel-efficiency, and then retune them for speed,) it, well, overrode the vanilla "Too Many Logistics Hullmods!" check, and would let me install those hullmods when there were too many Logistics hullmods, which then kicked off another Logistics hullmod the way the shipyard normally does.

So it didn't actually let you build an illegal ship, but it didn't give good feedback about what it was doing.

It would be nice if, instead of this current system, you had something like, I dunno... Pardon my arse-pulled psuedocode here because I'm very much not-a-coder working with things I barely understand, but...

Code

public class mySuperAwesomeHullMod extends BaseHullMod {...

public boolean conflictsWithHullmods(ShipAPI ship) {
if !ship.getVariant().getHullMods().contains("hullmod 1");
String text = "mySuperAwesomeHullMod conflicts with hullmod 1...";
if !ship.getVariant().getHullMods().contains("hullmod 2");
String text = "mySuperAwesomeHullMod conflicts with hullmod 2...";
if !ship.getVariant().getHullMods().contains("hullmod 3");
String text = "mySuperAwesomeHullMod conflicts with hullmod 3...";
else return null
}
[code]

For extra rigor, it might or might not be desirable to spin-off the "too many Logistics hullmod checking" from the same

[code]
public boolean isApplicableToShip(ShipAPI ship) {...}

into something like, I dunno,

Code
	public boolean isTooManyLogisticsHullmods(ShipAPI ship) {...}

So it would be significantly less likely for a modder to accidentally override it when attempting to render a hullmod incompatible for another reason.
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7227
  • Harpoon Affectionado
    • View Profile
Re: Suggestion: put hullmod incompatibility checks in their own silos
« Reply #1 on: May 07, 2020, 12:54:23 PM »

I haven't played around with hullmods very much, so forgive me if this is incorrect, but can you call "super.isApplicableToShip(ShipAPI ship)" in your own implementation in order to keep the desired logistics behavior from the base function? IE if the super returns false, your own function then returns false before needing to run any longer.

In regards to the hullmod incompatibility being hard to deal with, you are correct. If you haven't already you may want to check out Magic Lib https://fractalsoftworks.com/forum/index.php?topic=13718.0

I recall Tartiflette putting in a significant amount of work to create a flexible system that can sit on top of the vanilla code to try and make things easier.
Logged

ShadowDragon8685

  • Ensign
  • *
  • Posts: 45
    • View Profile
Re: Suggestion: put hullmod incompatibility checks in their own silos
« Reply #2 on: May 07, 2020, 02:15:28 PM »

I haven't played around with hullmods very much, so forgive me if this is incorrect, but can you call "super.isApplicableToShip(ShipAPI ship)" in your own implementation in order to keep the desired logistics behavior from the base function? IE if the super returns false, your own function then returns false before needing to run any longer.

I... Honestly do not know. I am not really a Java programmer, I am a caveman playing with incantations from working examples and a big super-searchable library.

Quote
In regards to the hullmod incompatibility being hard to deal with, you are correct. If you haven't already you may want to check out Magic Lib https://fractalsoftworks.com/forum/index.php?topic=13718.0

I recall Tartiflette putting in a significant amount of work to create a flexible system that can sit on top of the vanilla code to try and make things easier.

In fact I have, and I've implemented it throughout that mod in question, both to handle incompatibilities with Vanilla hullmods and with DME's Monobloc Construction.
Logged