2
2
// See the LICENSE file in the repository root for full license text.
3
3
4
4
using VRCOSC . Game . Modules . ChatBox ;
5
- using VRCOSC . Game . OSC . VRChat ;
6
5
using VRCOSC . Game . Processes ;
7
6
8
7
namespace VRCOSC . Modules . AFK ;
@@ -13,7 +12,7 @@ public class AFKModule : ChatBoxModule
13
12
public override string Description => "Display text and time since going AFK" ;
14
13
public override string Author => "VolcanicArts" ;
15
14
public override ModuleType Type => ModuleType . General ;
16
- protected override TimeSpan DeltaUpdate => VRChatOscConstants . UPDATE_TIME_SPAN ;
15
+ protected override TimeSpan DeltaUpdate => TimeSpan . FromSeconds ( 1 ) ;
17
16
18
17
private DateTime ? afkBegan ;
19
18
@@ -38,6 +37,14 @@ protected override void OnModuleStart()
38
37
}
39
38
40
39
protected override void OnModuleUpdate ( )
40
+ {
41
+ SetVariableValue ( AFKVariable . FocusedWindow , ProcessExtensions . GetActiveWindowTitle ( ) ?? "None" ) ;
42
+ SetVariableValue ( AFKVariable . Duration , afkBegan is null ? null : ( DateTime . Now - afkBegan . Value ) . ToString ( @"hh\:mm\:ss" ) ) ;
43
+ SetVariableValue ( AFKVariable . Since , afkBegan ? . ToString ( @"hh\:mm" ) ) ;
44
+ ChangeStateTo ( afkBegan is null ? AFKState . NotAFK : AFKState . AFK ) ;
45
+ }
46
+
47
+ protected override void OnPlayerUpdate ( )
41
48
{
42
49
if ( Player . AFK is null )
43
50
{
@@ -48,7 +55,6 @@ protected override void OnModuleUpdate()
48
55
if ( Player . AFK . Value && afkBegan is null )
49
56
{
50
57
afkBegan = DateTime . Now ;
51
- SetVariableValue ( AFKVariable . FocusedWindow , ProcessExtensions . GetActiveWindowTitle ( ) ?? "None" ) ;
52
58
TriggerEvent ( AFKEvent . AFKStarted ) ;
53
59
}
54
60
@@ -57,10 +63,6 @@ protected override void OnModuleUpdate()
57
63
afkBegan = null ;
58
64
TriggerEvent ( AFKEvent . AFKStopped ) ;
59
65
}
60
-
61
- SetVariableValue ( AFKVariable . Duration , afkBegan is null ? null : ( DateTime . Now - afkBegan . Value ) . ToString ( @"hh\:mm\:ss" ) ) ;
62
- SetVariableValue ( AFKVariable . Since , afkBegan ? . ToString ( @"hh\:mm" ) ) ;
63
- ChangeStateTo ( afkBegan is null ? AFKState . NotAFK : AFKState . AFK ) ;
64
66
}
65
67
66
68
private enum AFKVariable
0 commit comments