-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPublicizedExamplePlugin.cs
More file actions
31 lines (28 loc) · 1.12 KB
/
Copy pathPublicizedExamplePlugin.cs
File metadata and controls
31 lines (28 loc) · 1.12 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
using Rocket.Core.Logging;
using Rocket.Core.Plugins;
using SDG.Unturned;
namespace UnturnedRedistExample.Publicized
{
/// <summary>
/// Uses the <c>.Publicized</c> redist, so it reads members that are non-public
/// in the stock game as plain, compile-checked field accesses. Compare with
/// <c>../Reflection</c>, which reads the same field via reflection.
/// </summary>
public class PublicizedExamplePlugin : RocketPlugin
{
protected override void Load()
{
// isDedicatedUGCInstalled is NON-public in stock Unturned. This line
// compiles only because of the .Publicized redist, and runs only
// because the .csproj sets AllowUnsafeBlocks.
var ugcInstalled = Provider.isDedicatedUGCInstalled;
Logger.Log(
$"[UnturnedRedistExample.Publicized] Loaded. Read NON-public " +
$"Provider.isDedicatedUGCInstalled = {ugcInstalled} via the .Publicized redist.");
}
protected override void Unload()
{
Logger.Log("[UnturnedRedistExample.Publicized] Unloaded.");
}
}
}