2020-12-02 11:46:44 +00:00
# pragma once
# include "build.h"
# include "common_game.h"
# include "db.h"
# include "ai.h"
# include "nnexts.h"
# include "seq.h"
# include "aiunicult.h"
BEGIN_BLD_NS
2020-11-07 15:26:14 +00:00
extern int cumulDamage [ kMaxXSprites ] ;
2020-11-06 21:48:22 +00:00
// Due to the messed up array storage of all the game data we cannot do any direct references here yet. We have to access everything via wrapper functions for now.
2020-12-02 11:46:44 +00:00
// Note that the indexing is very inconsistent - partially by sprite index, partially by xsprite index.
class DBloodActor
{
2020-11-07 15:26:14 +00:00
int index ;
2020-12-02 11:46:44 +00:00
DBloodActor * base ( ) ;
public :
2020-11-07 15:26:14 +00:00
int dudeSlope ;
DBloodActor ( ) : index ( int ( this - base ( ) ) ) { /*assert(index >= 0 && index < kMaxSprites);*/ }
DBloodActor & operator = ( const DBloodActor & other ) = default ;
2020-12-02 11:46:44 +00:00
2020-12-06 07:18:03 +00:00
void Clear ( )
{
dudeSlope = 0 ;
}
bool hasX ( ) { return sprite [ index ] . extra > 0 ; }
2020-12-02 11:46:44 +00:00
spritetype & s ( ) { return sprite [ index ] ; }
XSPRITE & x ( ) { return xsprite [ sprite [ index ] . extra ] ; } // calling this does not validate the xsprite!
SPRITEHIT & hit ( ) { return gSpriteHit [ sprite [ index ] . extra ] ; }
int & xvel ( ) { return Blood : : xvel [ index ] ; }
int & yvel ( ) { return Blood : : yvel [ index ] ; }
int & zvel ( ) { return Blood : : zvel [ index ] ; }
int & cumulDamage ( ) { return Blood : : cumulDamage [ sprite [ index ] . extra ] ; }
DUDEEXTRA & dudeExtra ( ) { return gDudeExtra [ sprite [ index ] . extra ] ; }
SPRITEMASS & spriteMass ( ) { return gSpriteMass [ sprite [ index ] . extra ] ; }
GENDUDEEXTRA & genDudeExtra ( ) { return Blood : : gGenDudeExtra [ index ] ; }
POINT3D & basePoint ( ) { return Blood : : baseSprite [ index ] ; }
} ;
extern DBloodActor bloodActors [ kMaxSprites ] ;
inline DBloodActor * DBloodActor : : base ( ) { return bloodActors ; }
2020-12-02 16:10:00 +00:00
// Iterator wrappers that return an actor pointer, not an index.
class BloodStatIterator : public StatIterator
{
public :
BloodStatIterator ( int stat ) : StatIterator ( stat )
{
}
DBloodActor * Next ( )
{
int n = NextIndex ( ) ;
return n > = 0 ? & bloodActors [ n ] : nullptr ;
}
DBloodActor * Peek ( )
{
int n = PeekIndex ( ) ;
return n > = 0 ? & bloodActors [ n ] : nullptr ;
}
} ;
class BloodSectIterator : public SectIterator
{
public :
BloodSectIterator ( int stat ) : SectIterator ( stat )
{
}
DBloodActor * Next ( )
{
int n = NextIndex ( ) ;
return n > = 0 ? & bloodActors [ n ] : nullptr ;
}
DBloodActor * Peek ( )
{
int n = PeekIndex ( ) ;
return n > = 0 ? & bloodActors [ n ] : nullptr ;
}
} ;
2020-12-02 19:05:53 +00:00
inline int DeleteSprite ( DBloodActor * nSprite )
{
if ( nSprite ) return DeleteSprite ( nSprite - > s ( ) . index ) ;
return 0 ;
}
2020-12-02 16:10:00 +00:00
2020-12-02 11:46:44 +00:00
END_BLD_NS