//////////////// 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(); }
//////////////// internal void TrialLicenseItemByDefinition(ItemDefinition itemDef, bool playSound) { var mymod = (LicensesMod)this.mod; if (this.TrialLicensedItem != null) { string itemName = ItemAttributeHelpers.GetQualifiedName(this.TrialLicensedItem.Type); Main.NewText(itemName + " trial cancelled.", Color.Yellow); if (!this.LicensedItems.Contains(itemDef)) { NihilismAPI.UnsetItemWhitelistEntry(this.TrialLicensedItem, true); } } this.TrialLicensedItems.Add(itemDef); this.TrialLicensedItem = itemDef; NihilismAPI.SetItemWhitelistEntry(itemDef, true); Timers.UnsetTimer("LicensesTrialPeriod"); Timers.SetTimer("LicensesTrialPeriod", LicensesMod.Config.TrialLicenseDurationInTicks, () => { var myplayer = (LicensesPlayer)TmlHelpers.SafelyGetModPlayer(Main.LocalPlayer, mymod, "LicensesPlayer"); if (!myplayer.LicensedItems.Contains(itemDef)) { string itemName = ItemAttributeHelpers.GetQualifiedName(itemDef.Type); Main.NewText(itemName + " trial has expired.", Color.Yellow); NihilismAPI.UnsetItemWhitelistEntry(itemDef, true); myplayer.TrialLicensedItem = null; } return(false); }); if (playSound) { Main.PlaySound(SoundID.Unlock, player.position); } }