The problem I encountered with Armor::onAdd is that GameConnection::applyBodyParts was being called after onAdd, causing the chest node to be un-hidden. Also, Armor::onAdd doesn't seem to be called if the player changes their datablock through events. What I've just tried (that ostensibly seems to work) is overriding applyBodyParts itself, checking if the players datablock is my playertype and then mounting the chest image from there.
datablock PlayerData(PlayerCloneTrooper : PlayerStandardArmor) {
uiName = "Clone Trooper Player";
};
datablock ShapeBaseImageData(CloneChestImage) {
shapeFile = "./Chest.dts";
emap = true;
mountPoint = $BackSlot;
offset = "0 0 0";
eyeOffset = "0 0 10";
rotation = eulerToMatrix("0 0 0");
scale = "1 1 1";
doColorShift = false;
};
function CloneChestImage::onUnMount(%this, %obj, %slot) {
%player = %obj;
%player.unhideNode("Chest");
}
function CloneChestImage::onMount(%this, %obj, %slot) {
%player = %obj;
%player.hideNode("Chest");
}
package ClonePlayerPackage {
function GameConnection::applyBodyParts(%client) {
parent::applyBodyParts(%client);
if(%client.player.dataBlock $= PlayerCloneTrooper) {
%client.player.mountImage(CloneChestImage,1);
echo("GameConnection::applyBodyParts Client:" SPC %client);
} else {
if(%client.player.getMountedImage(1) == nameToID(CloneChestImage)) {
%client.player.unMountImage(1);
}
}
}
}; activatePackage(ClonePlayerPackage);
Is there any reason why doing it this way would be a bad idea?