env_spark: Added support for Trigger() state control

This commit is contained in:
Marco Cawthorne 2020-08-20 19:14:26 +02:00
parent 308a529244
commit 1bd552685d

View file

@ -68,16 +68,24 @@ void env_spark::TimedSpark(void)
nextthink = time + (random() * m_flMaxDelay); nextthink = time + (random() * m_flMaxDelay);
} }
/* TODO: Implement state */
void env_spark::Trigger(entity act, int state) void env_spark::Trigger(entity act, int state)
{ {
if (spawnflags & EVSPARK_TOGGLE) { if (spawnflags & EVSPARK_TOGGLE) {
if (think != __NULL__) { switch (state) {
case TRIG_OFF:
think = __NULL__; think = __NULL__;
nextthink = 0; nextthink = 0;
} else { break;
case TRIG_ON:
think = TimedSpark; think = TimedSpark;
nextthink = time + (random() * m_flMaxDelay); nextthink = time + (random() * m_flMaxDelay);
break;
default:
if (think != __NULL__) {
Trigger(act, TRIG_OFF);
} else {
Trigger(act, TRIG_ON);
}
} }
} else { } else {
CreateSpark(); CreateSpark();
@ -91,8 +99,7 @@ void env_spark::Respawn(void)
} }
if (spawnflags & EVSPARK_STARTON) { if (spawnflags & EVSPARK_STARTON) {
think = TimedSpark; Trigger(this, TRIG_ON);
nextthink = time + (random() * m_flMaxDelay);
} }
} }