It seems easy enough to import custom class files as attributes, but it doesn’t seem possible to import custom piece traits. If you set the ID to something unique, VASSAL doesn’t seem to be able to find the class that’s associated with it. Nowhere in the buildFile is there a reference to the imported trait class.
Am I missing something? Have custom traits been used in the past?
The editor imports the trait class without problem and I can even use the custom trait editor, but the buildFile knows nothing about the imported class.
I’m not sure what the problem is. I have used this technique to add custom traits to 5+ modules without problem.
Hmm, I do have a vague memory that after a certain vassal version, I had to do something different. Try removing the reference in the buildfile to <Vassal.build.module.BasicCommandEncoder> and replace it with your custom Command encoder. Since you custom command encoder extends BasicCommandEncoder, you only need the one.
The sequence should come through GameModule.getGameModule().decode() . This happens only when a piece is created, which in general will not happen when a module is loaded (only when loading a saved game, pulling a piece of a palette etc.). Have a look at the saved gamed loader in GameState which does
I think it has to do with changes Rodney made at my request to ensure that every single Decorator that gets created does so through a single central point. Previously, traits like Replace used to go off and create their own BasicPiece’s by calling low-level stuff directly. I had over-written BasicPiece with my own version that exposed some additional properties and I needed every BasicPiece created to happen in one central over-rideable place.
We could probably do some sort of Registration component that allows you to enter the class name of a new BasicCommandEncoder. Also the class names of new Decorator’s that you want to appear in the PieceDefiner list.
By the way, the one big lessson I learned about custom Decorators is don’t create them by subclassing an existing decorator. Instead, take a copy of the source of the existing decoraror, rename it and modify it to do what you want. I have been burned time and gain by innocuous source changes in Decorators that have blown my custom code out of the water.