This repository was archived by the owner on Nov 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
66 lines (53 loc) · 1.97 KB
/
Plugin.cs
File metadata and controls
66 lines (53 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using NetScriptFramework.SkyrimSE;
using NetScriptFramework.Tools;
namespace PluginTemplate
{
public class Plugin : NetScriptFramework.Plugin
{
public override string Key => "plugin.template";
public static string PluginName => "Plugin Template";
public override string Name => PluginName;
public override int Version => 2;
public override string Author => "erri120";
public override string Website => "https://github.com/erri120/";
public override int RequiredFrameworkVersion => 9;
public override int RequiredLibraryVersion => 13;
private bool _inMainMenu;
private Timer _timer;
private readonly object _lockObject = new object();
private long _lastTime;
protected override bool Initialize(bool loadedAny)
{
var utilityLibrary = NetScriptFramework.PluginManager.GetPlugin("utility.library");
if (utilityLibrary == null) return false;
if (!utilityLibrary.IsInitialized) return false;
if (!loadedAny) return false;
_timer = new Timer();
Events.OnMainMenu.Register(e =>
{
_inMainMenu = e.Entering;
if(e.Entering && _timer.IsRunning)
_timer.Stop();
else if(!e.Entering && !_timer.IsRunning)
_timer.Start();
});
Events.OnFrame.Register(e =>
{
if (!UtilityLibrary.UtilityLibrary.IsInGame || _inMainMenu)
return;
var now = _timer.Time;
if (now - _lastTime < 1000)
return;
_lastTime = now;
var player = PlayerCharacter.Instance;
if (player == null)
return;
lock (_lockObject)
{
//do something
}
});
return true;
}
}
}