File tree Expand file tree Collapse file tree 7 files changed +34
-0
lines changed Expand file tree Collapse file tree 7 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -1071,6 +1071,15 @@ func (p *parser) bindGameRules() {
10711071 roundTime = val .Int ()
10721072 })
10731073
1074+ entity .Property (grPrefix ("m_bFreezePeriod" )).OnUpdate (func (val st.PropertyValue ) {
1075+ newIsFreezetime := val .BoolVal ()
1076+ p .eventDispatcher .Dispatch (events.RoundFreezetimeChanged {
1077+ OldIsFreezetime : p .gameState .isFreezetime ,
1078+ NewIsFreezetime : newIsFreezetime ,
1079+ })
1080+ p .gameState .isFreezetime = newIsFreezetime
1081+ })
1082+
10741083 entity .Property (grPrefix ("m_gamePhase" )).OnUpdate (func (val st.PropertyValue ) {
10751084 oldGamePhase := p .gameState .gamePhase
10761085 p .gameState .gamePhase = common .GamePhase (val .Int ())
Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ type RoundStart struct {
3838// RoundFreezetimeEnd signals that the freeze time is over.
3939type RoundFreezetimeEnd struct {}
4040
41+ // RoundFreezetimeChanged signals that the freeze time period has changed.
42+ type RoundFreezetimeChanged struct {
43+ OldIsFreezetime bool
44+ NewIsFreezetime bool
45+ }
46+
4147// RoundEndReason is the type for the various RoundEndReasonXYZ constants.
4248//
4349// See RoundEnd.
Original file line number Diff line number Diff line change @@ -85,6 +85,11 @@ func (gs *GameState) IsWarmupPeriod() bool {
8585 return gs .Called ().Bool (0 )
8686}
8787
88+ // IsFreezetimePeriod is a mock-implementation of GameState.IsFreezetimePeriod().
89+ func (gs * GameState ) IsFreezetimePeriod () bool {
90+ return gs .Called ().Bool (0 )
91+ }
92+
8893// IsMatchStarted is a mock-implementation of GameState.IsMatchStarted().
8994func (gs * GameState ) IsMatchStarted () bool {
9095 return gs .Called ().Bool (0 )
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ type gameState struct {
3333 totalRoundsPlayed int
3434 gamePhase common.GamePhase
3535 isWarmupPeriod bool
36+ isFreezetime bool
3637 isMatchStarted bool
3738 overtimeCount int
3839 lastFlash lastFlash // Information about the last flash that exploded, used to find the attacker and projectile for player_blind events
@@ -192,6 +193,11 @@ func (gs gameState) IsWarmupPeriod() bool {
192193 return gs .isWarmupPeriod
193194}
194195
196+ // IsFreezetimePeriod returns whether the game is currently in freezetime period according to CCSGameRulesProxy.
197+ func (gs gameState ) IsFreezetimePeriod () bool {
198+ return gs .isFreezetime
199+ }
200+
195201// IsMatchStarted returns whether the match has started according to CCSGameRulesProxy.
196202func (gs gameState ) IsMatchStarted () bool {
197203 return gs .isMatchStarted
Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ type GameState interface {
5555 GamePhase () common.GamePhase
5656 // IsWarmupPeriod returns whether the game is currently in warmup period according to CCSGameRulesProxy.
5757 IsWarmupPeriod () bool
58+ // IsFreezetimePeriod returns whether the game is currently in freezetime period according to CCSGameRulesProxy.
59+ IsFreezetimePeriod () bool
5860 // IsMatchStarted returns whether the match has started according to CCSGameRulesProxy.
5961 IsMatchStarted () bool
6062 // OvertimeCount returns the number of overtime according to CCSGameRulesProxy.
Original file line number Diff line number Diff line change @@ -353,6 +353,12 @@ func TestGameRules(t *testing.T) {
353353 assert .Equal (t , ErrFailedToRetrieveGameRule , err )
354354}
355355
356+ func TestGameRules_IsFreezetimePeriod (t * testing.T ) {
357+ gs := gameState {isFreezetime : true }
358+
359+ assert .Equal (t , true , gs .IsFreezetimePeriod ())
360+ }
361+
356362func newPlayerS1 () * common.Player {
357363 pl := newPlayerWithEntityIDS1 (1 )
358364 return pl
You can’t perform that action at this time.
0 commit comments