Created
January 9, 2013 04:38
-
-
Save seronis/4490621 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AlertMsgType@[] alertTypes; | |
class AlertMsgType { | |
string@ name; | |
string@ genMsg; | |
string@ badMsg; | |
AlertEntry@[] list; | |
int spamLimit; //max msgs to queue before grouping | |
float spamDelay; //time between messages | |
float lastMsg; | |
AlertMsgType( string@ &in str, string@ &in gmsg, string@ &in bmsg, int limit, float delay ) { | |
name = str; | |
genMsg = gmsg; | |
badMsg = bmsg; | |
spamLimit = limit; | |
spamDelay = delay; | |
} | |
void queueAlert( Planet@ pl ) { | |
uint len = list.length(); | |
for( int val = 0; val < len; ++val ) { | |
if( list[val].pl !is pl ) continue; | |
list[val].time = gameTime; | |
return; | |
} | |
list.resize(len+1); | |
@list[len] = AlertEntry(pl,gameTime); | |
} | |
void postAlert() { | |
uint len = list.length(); | |
string@ msg; | |
if( | |
} | |
}; | |
class AlertEntry { | |
Planet@ pl; | |
float time; | |
AlertEntry( Planet@ _pl, float _time ) { | |
pl = _pl; | |
time = _time; | |
} | |
}; | |
int registerAlert( string@ str, string@ gMsg, string@ bMsg, int limit, float delay ) { | |
int num = alertTypes.length(); | |
for( int val = 0; val < num; ++val ) { | |
if( alertTypes[val].name != str ) continue; | |
print("AS planet_alerts::register() attempting to re-register alert: " + str ); | |
return val; | |
} | |
alertTypes.resize(num+1); | |
@alertTypes[num] = alert(str,gMsg,bMsg,limit,delay); | |
return num; | |
} | |
void queueAlert( Planet@ pl, int id ) { | |
if( id < 0 || id >= alertTypes.length() ) { | |
print("AS planet_alerts::queueAlert() recieved invalid alert id("+id+") "); | |
return; | |
} | |
alertTypes[id].queueAlert(pl); | |
} | |
const float tickPeriod = 0.25f; | |
float lastTick = 0.f; | |
void tick(float tDelta) { | |
if(gameTime - lastTick > tickPeriod) { | |
lastTick += tickPeriod; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment