Skip to content

Commit

Permalink
see desc
Browse files Browse the repository at this point in the history
- Fix GameRules#IsNightGameTime
- Fix GameRules#NetTimeOfDayNormilize
  • Loading branch information
Sicdex committed Nov 21, 2024
1 parent b682585 commit 40ee16f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions wrapper/Objects/Base/GameRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ export class CGameRules extends Entity {
super(Index, serial)
this.IsGameRules = true
}

public get NetTimeOfDayNormilize(): number {
return this.NetTimeOfDay / 65535
// idk, ask valve why "Math.remapRange" is used
return Math.remapRange(this.NetTimeOfDay, 0, 65535, 0, 1)
}
public get GameTime(): number {
const time = this.RawGameTime,
Expand Down Expand Up @@ -126,14 +126,17 @@ export class CGameRules extends Entity {
GameState.IsConnected)
)
}
public get IsDayGameTime(): boolean {
return (
this.NetTimeOfDayNormilize >= this.DayTimeStart &&
this.NetTimeOfDayNormilize <= this.NightTimeStart
)
}
public get IsNightGameTime(): boolean {
return !this.IsDayGameTime || (this.GameTime / 60 / 5) % 2 >= 1
const dayStart = this.DayTimeStart,
nightStart = this.NightTimeStart,
currentTime = this.NetTimeOfDayNormilize
if (nightStart <= dayStart) {
return currentTime > nightStart && currentTime <= dayStart
}
return currentTime <= dayStart || currentTime > nightStart
}
public get IsDayGameTime(): boolean {
return !this.IsNightGameTime
}
public get IsNight(): boolean {
return (
Expand Down

0 comments on commit 40ee16f

Please sign in to comment.