Add shareware support and spawn correctly for difficulty levels
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -30,8 +30,24 @@ abstract class Weapon {
|
||||
this.isAutomatic = true,
|
||||
});
|
||||
|
||||
int get currentSprite =>
|
||||
state == WeaponState.idle ? idleSprite : fireFrames[frameIndex];
|
||||
int getCurrentSpriteIndex(int maxSprites) {
|
||||
int baseSprite = state == WeaponState.idle
|
||||
? idleSprite
|
||||
: fireFrames[frameIndex];
|
||||
|
||||
// Retail VSWAP typically has exactly 436 sprites (indices 0 to 435).
|
||||
// The 20 weapon sprites are ALWAYS placed at the very end of the sprite block.
|
||||
// This dynamically aligns the base index to the end of any VSWAP file!
|
||||
int dynamicOffset = 436 - maxSprites;
|
||||
int calculatedIndex = baseSprite - dynamicOffset;
|
||||
|
||||
// Safety check!
|
||||
if (calculatedIndex < 0 || calculatedIndex >= maxSprites) {
|
||||
print("WARNING: Weapon sprite index $calculatedIndex out of bounds!");
|
||||
return 0;
|
||||
}
|
||||
return calculatedIndex;
|
||||
}
|
||||
|
||||
void releaseTrigger() {
|
||||
_triggerReleased = true;
|
||||
|
||||
Reference in New Issue
Block a user