sprite.h
changeset 445 beafc0fb8f12
parent 426 381172276dc6
child 915 d845fe7cf6f2
equal deleted inserted replaced
444:6590870379ad 445:beafc0fb8f12
    80 
    80 
    81 	// Dynamically allocated, this is the sole owner
    81 	// Dynamically allocated, this is the sole owner
    82 	struct SpriteGroup *default_group;
    82 	struct SpriteGroup *default_group;
    83 };
    83 };
    84 
    84 
       
    85 struct RandomizedSpriteGroup {
       
    86 	// Take this object:
       
    87 	enum VarSpriteGroupScope var_scope;
       
    88 
       
    89 	// Check for these triggers:
       
    90 	enum RandomizedSpriteGroupCompareMode {
       
    91 		RSG_CMP_ANY,
       
    92 		RSG_CMP_ALL,
       
    93 	} cmp_mode;
       
    94 	byte triggers;
       
    95 
       
    96 	// Look for this in the per-object randomized bitmask:
       
    97 	byte lowest_randbit;
       
    98 	byte num_groups; // must be power of 2
       
    99 
       
   100 	// Take the group with appropriate index:
       
   101 	struct SpriteGroup *groups;
       
   102 };
       
   103 
    85 struct SpriteGroup {
   104 struct SpriteGroup {
    86 	enum SpriteGroupType {
   105 	enum SpriteGroupType {
    87 		SGT_REAL,
   106 		SGT_REAL,
    88 		SGT_DETERMINISTIC,
   107 		SGT_DETERMINISTIC,
    89 		SGT_RANDOM, /* TODO */
   108 		SGT_RANDOMIZED,
    90 	} type;
   109 	} type;
    91 
   110 
    92 	union {
   111 	union {
    93 		struct RealSpriteGroup real;
   112 		struct RealSpriteGroup real;
    94 		struct DeterministicSpriteGroup determ;
   113 		struct DeterministicSpriteGroup determ;
       
   114 		struct RandomizedSpriteGroup random;
    95 	} g;
   115 	} g;
    96 };
   116 };
    97 
   117 
    98 struct DeterministicSpriteGroupRange {
   118 struct DeterministicSpriteGroupRange {
    99 	struct SpriteGroup group;
   119 	struct SpriteGroup group;
   106  * DeterministicSpriteGroup. */
   126  * DeterministicSpriteGroup. */
   107 struct SpriteGroup *EvalDeterministicSpriteGroup(struct DeterministicSpriteGroup *dsg, int value);
   127 struct SpriteGroup *EvalDeterministicSpriteGroup(struct DeterministicSpriteGroup *dsg, int value);
   108 /* Get value of a common deterministic SpriteGroup variable. */
   128 /* Get value of a common deterministic SpriteGroup variable. */
   109 int GetDeterministicSpriteValue(byte var);
   129 int GetDeterministicSpriteValue(byte var);
   110 
   130 
       
   131 /* This takes randomized bitmask (probably associated with
       
   132  * vehicle/station/whatever) and chooses corresponding SpriteGroup
       
   133  * accordingly to the given RandomizedSpriteGroup. */
       
   134 struct SpriteGroup *EvalRandomizedSpriteGroup(struct RandomizedSpriteGroup *rsg, byte random_bits);
       
   135 /* Triggers given RandomizedSpriteGroup with given bitmask and returns and-mask
       
   136  * of random bits to be reseeded, or zero if there were no triggers matched
       
   137  * (then they are |ed to @waiting_triggers instead). */
       
   138 byte RandomizedSpriteGroupTriggeredBits(struct RandomizedSpriteGroup *rsg, byte triggers, byte *waiting_triggers);
       
   139 
   111 #endif
   140 #endif