-
Notifications
You must be signed in to change notification settings - Fork 0
/
LicensesPlayer.cs
63 lines (43 loc) · 1.53 KB
/
LicensesPlayer.cs
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
using HamstarHelpers.Helpers.Debug;
using Nihilism;
using System.Collections.Generic;
using Terraria;
using Terraria.ModLoader;
using Terraria.ModLoader.Config;
namespace Licenses {
partial class LicensesPlayer : ModPlayer {
private readonly ISet<ItemDefinition> PendingLoadTrialLicenses = new HashSet<ItemDefinition>();
private readonly ISet<ItemDefinition> PendingLoadLicenses = new HashSet<ItemDefinition>();
public readonly ISet<ItemDefinition> TrialLicensedItems = new HashSet<ItemDefinition>();
public readonly ISet<ItemDefinition> LicensedItems = new HashSet<ItemDefinition>();
public int LicenseMode = 0;
////////////////
public ItemDefinition TrialLicensedItem { get; private set; } = null;
////
public override bool CloneNewInstances => false;
////////////////
internal void ResetLicenses() {
foreach( ItemDefinition itemDef in this.LicensedItems ) {
NihilismAPI.UnsetItemWhitelistEntry( itemDef, true );
}
this.TrialLicensedItem = null;
this.TrialLicensedItems.Clear();
this.LicensedItems.Clear();
this.PendingLoadTrialLicenses.Clear();
this.PendingLoadLicenses.Clear();
}
////////////////
public override void SyncPlayer( int toWho, int fromWho, bool newPlayer ) {
if( Main.netMode == 2 ) {
if( toWho == -1 && fromWho == this.player.whoAmI ) {
this.OnEnterWorldForServer();
}
}
}
////////////////
public override void PostUpdate() {
if( this.player.whoAmI != Main.myPlayer ) { return; }
this.RunLicenseCheckForItem( Main.mouseItem );
}
}
}