[Request] Event pause Mod

Started by Crimsonknight3, May 12, 2014, 12:41:52 PM

Previous topic - Next topic

Crimsonknight3

Hey, I play a lot of 3x speed and sometimes (using mods anyway) I get enemies drop in from space and attack immediately and sometimes it takes me a few moments too long to notice. I am wondering if someone can write or knows of a mod that can automatically pause the game when a configured event happens, trade ship, enemy attack, berserk animal etc?

Thanks all :)

Crimsonknight3

Does anybody know whether this is even possible?

pawnstorm

#2
It shouldn't be too hard. Forcing the game to pause is simple, just do
TickManager tm = Find.TickManager;
if (tm.curTimeSpeed != TimeSpeed.Paused)
{
    tm.prePauseTimeSpeed = tm.curTimeSpeed;
    tm.curTimeSpeed = TimeSpeed.Paused;
}


Then all you'd need to do is extend the relevant IncidentWorker classes and put that code somewhere where it gets triggered when the incident happens. Near the end of the TryExecute should work. Or just do:
public override bool TryExecute(IncidentParms parms)
{
if (base.TryExecute(parms))
{
TickManager tm = Find.TickManager;
if (tm.curTimeSpeed != TimeSpeed.Paused)
{
tm.prePauseTimeSpeed = tm.curTimeSpeed;
tm.curTimeSpeed = TimeSpeed.Paused;
}
return true;
}
return false;
}


Edit: Hmm, I suppose I'll go add it as an option to Vanilla+

Crimsonknight3

Quote from: pawnstorm on May 12, 2014, 08:55:42 PM
It shouldn't be too hard. Forcing the game to pause is simple, just do
TickManager tm = Find.TickManager;
if (tm.curTimeSpeed != TimeSpeed.Paused)
{
    tm.prePauseTimeSpeed = tm.curTimeSpeed;
    tm.curTimeSpeed = TimeSpeed.Paused;
}


Then all you'd need to do is extend the relevant IncidentWorker classes and put that code somewhere where it gets triggered when the incident happens. Near the end of the TryExecute should work. Or just do:
public override bool TryExecute(IncidentParms parms)
{
if (base.TryExecute(parms))
{
TickManager tm = Find.TickManager;
if (tm.curTimeSpeed != TimeSpeed.Paused)
{
tm.prePauseTimeSpeed = tm.curTimeSpeed;
tm.curTimeSpeed = TimeSpeed.Paused;
}
return true;
}
return false;
}


Edit: Hmm, I suppose I'll go add it as an option to Vanilla+

that would be awesome and im sure others will get use out of it. Glad I could contribute to vanilla+

Austupaio

Oh yeah, I'd definitely appreciate that. The fact that the game doesn't pause when raiders attack immediately is kind of an oversight. I imagine it'll be fixed soon enough officially, but in the mean time, mods are great.

Crimsonknight3

Quote from: Austupaio on May 13, 2014, 12:35:45 PM
Oh yeah, I'd definitely appreciate that. The fact that the game doesn't pause when raiders attack immediately is kind of an oversight. I imagine it'll be fixed soon enough officially, but in the mean time, mods are great.

I can understand some people like the toughness of never knowing when and having to improvise but others would find it easy. To be honest when it first started happening to me I was surprised that there are any situational based options inside the games main options, pause on event, pause on attack, pause on pawn leaving colony etc I just assumed it would already be there lol