initial implementation
This commit is contained in:
38
Items/GlobalItem.cs
Normal file
38
Items/GlobalItem.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using MagicStorage.Components;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace MagicStorageVoidBag.Items {
|
||||
internal class GlobalItem : Terraria.ModLoader.GlobalItem {
|
||||
public override bool OnPickup(Item item, Player player) {
|
||||
var i = player.inventory.Where(i => i.type == ModContent.ItemType<MSVoidBag>()).DefaultIfEmpty(null).First();
|
||||
if (i != null && !player.ItemSpace(item).CanTakeItem) {
|
||||
var bag = (MSVoidBag)i.ModItem;
|
||||
|
||||
if (bag.location.X < 0 || bag.location.Y < 0) return false;
|
||||
|
||||
Tile tile = Main.tile[bag.location.X, bag.location.Y];
|
||||
|
||||
if (!tile.HasTile || tile.TileType != ModContent.TileType<StorageHeart>() || tile.TileFrameX != 0 || tile.TileFrameY != 0) return false;
|
||||
if (!TileEntity.ByPosition.TryGetValue(bag.location, out TileEntity te)) return false;
|
||||
if (te.type != ModContent.TileEntityType<TEStorageHeart>()) return false;
|
||||
|
||||
TEStorageHeart heart = (TEStorageHeart)te;
|
||||
|
||||
int oldStack = item.stack;
|
||||
heart.TryDeposit(item);
|
||||
if (item.stack == 0) return true;
|
||||
|
||||
}
|
||||
|
||||
return base.OnPickup(item, player);
|
||||
}
|
||||
}
|
||||
}
|
76
Items/MSVoidBag.cs
Normal file
76
Items/MSVoidBag.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using MagicStorage.Items;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria;
|
||||
using Terraria.GameContent.Creative;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace MagicStorageVoidBag.Items {
|
||||
[ExtendsFromMod("MagicStorage")]
|
||||
public class MSVoidBag : PortableAccess {
|
||||
|
||||
/*
|
||||
Code here largely thanks to original MagicStorage source, which can be found at
|
||||
https://github.com/blushiemagic/MagicStorage/
|
||||
License:
|
||||
MIT License
|
||||
|
||||
Copyright(c) 2017 Kaylee Minsuh Kim
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
public override void SetStaticDefaults() {
|
||||
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
|
||||
}
|
||||
|
||||
public override void SetDefaults() {
|
||||
Item.width = 26;
|
||||
Item.height = 34;
|
||||
Item.maxStack = 1;
|
||||
Item.rare = ItemRarityID.Purple;
|
||||
Item.useStyle = ItemUseStyleID.Swing;
|
||||
Item.useAnimation = 28;
|
||||
Item.useTime = 28;
|
||||
Item.value = Item.sellPrice(gold: 10);
|
||||
}
|
||||
|
||||
public override void ModifyTooltips(List<TooltipLine> lines) {
|
||||
bool isSet = location.X >= 0 && location.Y >= 0;
|
||||
for (int k = 0; k < lines.Count; k++)
|
||||
if (isSet && lines[k].Mod == "Terraria" && lines[k].Name == "Tooltip1") {
|
||||
lines[k].Text = Language.GetTextValue("Mods.MagicStorage.SetTo", location.X, location.Y);
|
||||
} else if (!isSet && lines[k].Mod == "Terraria" && lines[k].Name == "Tooltip2") {
|
||||
lines.RemoveAt(k);
|
||||
k--;
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddRecipes() {
|
||||
Recipe recipe = CreateRecipe();
|
||||
recipe.AddIngredient<PortableAccess>();
|
||||
recipe.AddIngredient(ItemID.VoidLens);
|
||||
recipe.AddIngredient<RadiantJewel>();
|
||||
recipe.AddTile(TileID.LunarCraftingStation);
|
||||
recipe.Register();
|
||||
}
|
||||
}
|
||||
}
|
BIN
Items/MSVoidBag.png
Normal file
BIN
Items/MSVoidBag.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 558 B |
Reference in New Issue
Block a user