示例#1
0
        internal void LicenseItemByDefinition(ItemDefinition itemDef, bool playSound)
        {
            this.LicensedItems.Add(itemDef);

            NihilismAPI.SetItemWhitelistEntry(itemDef, true);

            if (!LicensesMod.Config.FreeRecipes)
            {
                NihilismAPI.SetRecipeWhitelistEntry(itemDef, true);
            }

            if (playSound)
            {
                Main.PlaySound(SoundID.Unlock, player.position);
            }
        }
示例#2
0
        ////////////////

        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);
            }
        }
		////

		private void LoadNihilismFilters() {
			if( LicensesMod.Config.OverrideNihilismDefaultFilters ) {
				NihilismAPI.ClearFiltersForCurrentWorld( true );
			}
			
			NihilismAPI.SetItemBlacklistGroupEntry( "Any Item", true );

			if( !LicensesMod.Config.FreeRecipes ) {
				NihilismAPI.SetRecipeBlacklistGroupEntry( "Any Item", true );
			}

			if( LicensesMod.Config.FreeMaterials ) {
				NihilismAPI.SetItemWhitelistGroupEntry( "Any Plain Material", true );
			}
			if( LicensesMod.Config.FreePlaceables ) {
				NihilismAPI.SetItemWhitelistGroupEntry( "Any Placeable", true );
			}

			foreach( ItemDefinition itemDef in LicensesMod.Config.FreeStarterItems ) {
				NihilismAPI.SetItemWhitelistEntry( itemDef, true );
			}
		}