XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

DeathMod

【Terraria】DeathMod (now aka Soul Harvest)

公开
关注 0 Fork 0 Star 0
UTF-8
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SoulHarvest.Items;

public class Soul : ModItem
{
    public override void SetStaticDefaults()
    {
        Item.ResearchUnlockCount = 1;
    }

    public override void SetDefaults()
    {
        Item.width = 20;
        Item.height = 20;
        Item.maxStack = Item.CommonMaxStack;
        Item.value = Item.buyPrice(gold: 1);
        Item.rare = ItemRarityID.Master;
    }

    public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
    {
        Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
        float drawScale = 38f / Math.Max(texture.Width, texture.Height) * scale;
        Vector2 position = Item.Center - Main.screenPosition;
        spriteBatch.Draw(texture, position, null, lightColor, rotation,
            texture.Size() * 0.5f, drawScale, SpriteEffects.None, 0f);
        return false;
    }
}