not working build do not launch, need to finish loading all assets and the mod
@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.Localization;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
@ -6,13 +7,31 @@ using Terraria.ModLoader;
|
||||
|
||||
namespace Emiliasmod.Content.Items.Accessories
|
||||
{
|
||||
[Autoload(false)]
|
||||
public class Spacesuit : ModItem
|
||||
{
|
||||
private int emiliasID;
|
||||
private string name;
|
||||
private string displayName;
|
||||
private string texturePath;
|
||||
|
||||
public static readonly int DefenseBonus = 8;
|
||||
|
||||
protected override bool CloneNewInstances => true;
|
||||
public override string Texture => texturePath;
|
||||
public override LocalizedText Tooltip => LocalizedText.Empty;
|
||||
//public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs();
|
||||
public override string Name => name;
|
||||
|
||||
public Spacesuit(string _name, int _emiliasID, string _displayName, string _texturePath) {
|
||||
this.name = _name;
|
||||
this.emiliasID = _emiliasID;
|
||||
this.displayName = _displayName;
|
||||
this.texturePath = _texturePath;
|
||||
}
|
||||
|
||||
public override void SetStaticDefaults() {
|
||||
Item.ResearchUnlockCount = 400;
|
||||
Item.defense = 8;
|
||||
}
|
||||
public override void SetDefaults() {
|
||||
Item.width = 40;
|
||||
Item.height = 40;
|
||||
@ -34,8 +53,7 @@ namespace Emiliasmod.Content.Items.Accessories
|
||||
}
|
||||
|
||||
public override void UpdateAccessory(Player player, bool hideVisual) {
|
||||
player.rocketBoots = 2;
|
||||
player.vanityRocketBoots = 2;
|
||||
player.rocketBoots = 4;
|
||||
|
||||
player.waterWalk2 = true;
|
||||
player.waterWalk = true;
|
||||
@ -45,14 +63,8 @@ namespace Emiliasmod.Content.Items.Accessories
|
||||
player.noFallDmg = true;
|
||||
player.lavaRose = true;
|
||||
player.lavaImmune = true;
|
||||
|
||||
|
||||
player.statDefense += DefenseBonus;
|
||||
|
||||
//player.arcticDivingGear = true;
|
||||
player.accMerman = true;
|
||||
player.wolfAcc = true;
|
||||
player.accDivingHelm = true;
|
||||
player.statDefense += Item.defense;
|
||||
|
||||
player.buffImmune[BuffID.BrokenArmor] = true;
|
||||
player.buffImmune[BuffID.Bleeding] = true;
|
||||
@ -82,17 +94,16 @@ namespace Emiliasmod.Content.Items.Accessories
|
||||
player.accRunSpeed *= 3.75f;
|
||||
player.runSlowdown *= 1.75f;
|
||||
|
||||
player.arcticDivingGear = true;//may it do something ?
|
||||
player.accMerman = true;
|
||||
player.wolfAcc = true;
|
||||
|
||||
if (!hideVisual) {
|
||||
player.CancelAllBootRunVisualEffects(); // This ensures that boot visual effects don't overlap if multiple are equipped
|
||||
|
||||
// Hellfire Treads sprint dust. For more info on sprint dusts see Player.SpawnFastRunParticles() method in Player.cs
|
||||
player.hellfireTreads = true;
|
||||
// Other boot run visual effects include: sailDash, coldDash, desertDash, fairyBoots
|
||||
|
||||
if (!player.mount.Active || player.mount.Type != MountID.WallOfFleshGoat) {
|
||||
// Spawns flames when walking, like Flame Waker Boots. We also check the Goat Skull mount so the effects don't overlap.
|
||||
player.DoBootsEffect(player.DoBootsEffect_PlaceFlamesOnTile);
|
||||
}
|
||||
player.vanityRocketBoots = 4;
|
||||
player.CancelAllBootRunVisualEffects();
|
||||
} else {
|
||||
player.hideWolf = true;
|
||||
player.hideMerman = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 416 B |
@ -6,13 +6,21 @@ using Terraria.ModLoader;
|
||||
|
||||
namespace Emiliasmod.Content.Items.Accessories
|
||||
{
|
||||
[AutoloadEquip(EquipType.Wings)]
|
||||
public class Spacesurf : ModItem
|
||||
{
|
||||
public override void SetStaticDefaults() {
|
||||
ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(180, 9.0f, 4.5f, true, 16.0f, 4.5f);
|
||||
}
|
||||
[Autoload(false)]
|
||||
public class Spacesurf : ModItem {
|
||||
public override string Texture => $"Emiliasmod/Assets/Texture/{Name}";
|
||||
//public abstract int FlyTime { get; }
|
||||
//public abstract float FlySpeed { get; }
|
||||
//public abstract float Acceleration { get; }
|
||||
//public abstract bool CanHover { get; }
|
||||
public int FlyTime = 180;
|
||||
public float FlySpeed = 9.0f;
|
||||
public float Acceleration = 4.5f;
|
||||
public bool CanHover = true;
|
||||
|
||||
public override void SetStaticDefaults() {
|
||||
ArmorIDs.Wing.Sets.Stats[Item.wingSlot] = new WingStats(FlyTime, FlySpeed, Acceleration, CanHover);
|
||||
}
|
||||
public override void SetDefaults() {
|
||||
Item.width = 22;
|
||||
Item.height = 20;
|
||||
@ -20,6 +28,7 @@ namespace Emiliasmod.Content.Items.Accessories
|
||||
Item.rare = ItemRarityID.Red;
|
||||
Item.accessory = true;
|
||||
Item.master = true;
|
||||
Item.wingSlot = Item.type;
|
||||
}
|
||||
|
||||
public override void UpdateAccessory(Player player, bool hideVisual) {
|
||||
@ -37,5 +46,12 @@ namespace Emiliasmod.Content.Items.Accessories
|
||||
recipe.AddIngredient(ItemID.LongRainbowTrailWings, 1);
|
||||
recipe.Register();
|
||||
}
|
||||
public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentSpeed, ref float ascentRunSpeed) {
|
||||
ascentWhenFalling = 0.85f;
|
||||
ascentWhenRising = 0.15f;
|
||||
maxCanAscendMultiplier = 1f;
|
||||
maxAscentSpeed = 3f;
|
||||
ascentRunSpeed = 2.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 370 B |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 389 B |
@ -6,7 +6,7 @@ using Terraria.ModLoader;
|
||||
namespace Emiliasmod.Content.Items.Ammo
|
||||
{
|
||||
|
||||
//[Autoload(false)]
|
||||
[Autoload(false)]
|
||||
public class VacuumTube : ModItem {
|
||||
public override void SetDefaults() {
|
||||
Item.width = 24;
|
||||
@ -20,6 +20,18 @@ namespace Emiliasmod.Content.Items.Ammo
|
||||
Item.shoot = ModContent.ProjectileType<SpaceBlasterProjectile>();
|
||||
Item.ammo = ModContent.ItemType<VacuumTube>();
|
||||
}
|
||||
public override void AddRecipes()
|
||||
{
|
||||
Recipe recipe = CreateRecipe();
|
||||
recipe.AddIngredient(ItemID.Glass, 15);
|
||||
recipe.AddIngredient(ItemID.GoldBar, 4);
|
||||
recipe.AddIngredient(ItemID.TitaniumBar, 4);
|
||||
recipe.AddIngredient(ItemID.PlatinumCoin, 4);
|
||||
recipe.AddIngredient(ItemID.LunarBar, 2);
|
||||
recipe.AddIngredient(ItemID.Nanites, 2);
|
||||
recipe.AddTile(TileID.HeavyWorkBench);
|
||||
recipe.Register();
|
||||
}
|
||||
}
|
||||
public class QuantumVacuumTube : ModItem {//for debug purpose while overheat isn't created
|
||||
public override void SetDefaults() {
|
||||
@ -34,5 +46,15 @@ namespace Emiliasmod.Content.Items.Ammo
|
||||
Item.shoot = ModContent.ProjectileType<SpaceBlasterProjectile>();
|
||||
Item.ammo = ModContent.ItemType<VacuumTube>();
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
Recipe recipe = CreateRecipe();
|
||||
recipe.AddIngredient(ModContent.ItemType<VacuumTube>(), 100);
|
||||
recipe.AddIngredient(ItemID.LunarBar, 500);
|
||||
recipe.AddIngredient(ItemID.Nanites, 1000);
|
||||
recipe.AddTile(TileID.LunarMonolith);
|
||||
recipe.Register();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 285 B |
@ -3,28 +3,22 @@ using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
|
||||
namespace Emiliasmod.Content.Items.Weapon
|
||||
{
|
||||
// This is a basic item template.
|
||||
// Please see tModLoader's ExampleMod for every other example:
|
||||
// https://github.com/tModLoader/tModLoader/tree/stable/ExampleMod
|
||||
[Autoload(false)]
|
||||
public class EmiliasWand : ModItem
|
||||
{
|
||||
|
||||
public override void SetStaticDefaults() {
|
||||
// As mentioned in the documentation, IsDrill and IsChainsaw automatically reduce useTime and useAnimation to 60% of what is set in SetDefaults and decrease tileBoost by 1, but only for vanilla items.
|
||||
// We set it here despite it doing nothing because it is likely to be used by other mods to provide special effects to drill or chainsaw items globally.
|
||||
ItemID.Sets.IsDrill[Type] = true;
|
||||
}
|
||||
|
||||
// The Display Name and Tooltip of this item can be edited in the 'Localization/en-US_Mods.Emiliasmod.hjson' file.
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.damage = 300;
|
||||
Item.pick = 300;
|
||||
//Item.pick = 300;
|
||||
//Item.tileBoost = 5;
|
||||
Item.DamageType = DamageClass.MeleeNoSpeed;
|
||||
Item.tileBoost = 5;
|
||||
Item.width = 64;
|
||||
Item.height = 64;
|
||||
Item.useTime = 2;
|
||||
@ -34,19 +28,21 @@ namespace Emiliasmod.Content.Items.Weapon
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.value = Item.buyPrice(platinum: 1);
|
||||
Item.rare = ItemRarityID.Red;
|
||||
//Item.UseSound = SoundID.ZombieMoan;
|
||||
Item.UseSound = SoundID.Item85;
|
||||
Item.shoot = ModContent.ProjectileType<EmiliasWandProjectile>();
|
||||
Item.shootSpeed = 32f; // Adjusts how far away from the player to hold the projectile
|
||||
Item.noMelee = true; // Turns off damage from the item itself, as we have a projectile
|
||||
Item.noUseGraphic = true; // Stops the item from drawing in your hands, for the aforementioned reason
|
||||
Item.shootSpeed = 32f;
|
||||
Item.noMelee = true;
|
||||
Item.noUseGraphic = true;
|
||||
Item.channel = true;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
Recipe recipe = CreateRecipe();
|
||||
recipe.AddIngredient(ItemID.DirtBlock, 10);
|
||||
recipe.AddTile(TileID.WorkBenches);
|
||||
recipe.AddIngredient(ItemID.Drax, 1);
|
||||
recipe.AddIngredient(ItemID.LaserDrill, 1);
|
||||
recipe.AddIngredient(ItemID.LunarBar, 50);
|
||||
recipe.AddTile(TileID.LunarMonolith);
|
||||
recipe.Register();
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 773 B |
@ -3,11 +3,10 @@ using Emiliasmod.Content.Items.Ammo;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Emiliasmod.Content.Items.Weapon
|
||||
{
|
||||
{
|
||||
[Autoload(false)]
|
||||
public class SpaceBlaster : ModItem
|
||||
{
|
||||
public override void SetDefaults()
|
||||
@ -17,8 +16,8 @@ namespace Emiliasmod.Content.Items.Weapon
|
||||
Item.width = 64;
|
||||
Item.height = 64;
|
||||
Item.crit = -20;
|
||||
Item.useTime = 20;
|
||||
Item.useAnimation = 20;
|
||||
Item.useTime = 24;
|
||||
Item.useAnimation = 24;
|
||||
Item.useStyle = ItemUseStyleID.Shoot;
|
||||
Item.noMelee = true;
|
||||
Item.knockBack = 0;
|
||||
@ -36,14 +35,9 @@ namespace Emiliasmod.Content.Items.Weapon
|
||||
Recipe recipe = CreateRecipe();
|
||||
recipe.AddIngredient(ItemID.WaterGun, 1);
|
||||
recipe.AddIngredient(ItemID.BubbleGun, 1);
|
||||
//recipe.AddIngredient(ItemID, 10);
|
||||
recipe.AddTile(TileID.WorkBenches);
|
||||
recipe.AddIngredient(ItemID.LunarBar, 50);
|
||||
recipe.AddTile(TileID.LunarMonolith);
|
||||
recipe.Register();
|
||||
}
|
||||
|
||||
//public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
|
||||
//{
|
||||
// base.PostDrawInWorld(spriteBatch, lightColor, alphaColor, rotation, scale, whoAmI);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 599 B |
@ -6,6 +6,7 @@ using Terraria.ModLoader;
|
||||
|
||||
namespace Emiliasmod.Content.Projectiles
|
||||
{
|
||||
[Autoload(false)]
|
||||
public class EmiliasWandProjectile : ModProjectile
|
||||
{
|
||||
public override void SetStaticDefaults() {
|
||||
@ -21,38 +22,27 @@ namespace Emiliasmod.Content.Projectiles
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.DamageType = DamageClass.Melee;
|
||||
Projectile.ownerHitCheck = true;
|
||||
Projectile.aiStyle = -1; // Replace with 20 if you do not want custom code
|
||||
Projectile.hide = true; // Hides the projectile, so it will draw in the player's hand when we set the player's heldProj to this one.
|
||||
Projectile.aiStyle = -1;
|
||||
Projectile.hide = true;
|
||||
}
|
||||
|
||||
// This code is adapted and simplified from aiStyle 20 to use a different dust and more noises. If you want to use aiStyle 20, you do not need to do any of this.
|
||||
// It should be noted that this projectile has no effect on mining and is mostly visual.
|
||||
public override void AI() {
|
||||
Player player = Main.player[Projectile.owner];
|
||||
|
||||
Projectile.timeLeft = 60;
|
||||
|
||||
// Animation code could go here if the projectile was animated.
|
||||
|
||||
// Plays a sound every 20 ticks. In aiStyle 20, soundDelay is set to 30 ticks.
|
||||
//if (Projectile.soundDelay <= 0) {
|
||||
//SoundEngine.PlaySound(SoundID.Item22, Projectile.Center);
|
||||
//Projectile.soundDelay = 20;
|
||||
//}
|
||||
if (Projectile.soundDelay <= 0) {
|
||||
SoundEngine.PlaySound(SoundID.Item85, Projectile.Center);
|
||||
Projectile.soundDelay = 20;
|
||||
}
|
||||
|
||||
Vector2 playerCenter = player.RotatedRelativePoint(player.MountedCenter);
|
||||
if (Main.myPlayer == Projectile.owner) {
|
||||
// This code must only be ran on the client of the projectile owner
|
||||
if (player.channel) {
|
||||
float holdoutDistance = player.HeldItem.shootSpeed * Projectile.scale;
|
||||
// Calculate a normalized vector from player to mouse and multiply by holdoutDistance to determine resulting holdoutOffset
|
||||
Vector2 holdoutOffset = holdoutDistance * Vector2.Normalize(Main.MouseWorld - playerCenter);
|
||||
if (holdoutOffset.X != Projectile.velocity.X || holdoutOffset.Y != Projectile.velocity.Y) {
|
||||
// This will sync the projectile, most importantly, the velocity.
|
||||
Projectile.netUpdate = true;
|
||||
}
|
||||
|
||||
// Projectile.velocity acts as a holdoutOffset for held projectiles.
|
||||
Projectile.velocity = holdoutOffset;
|
||||
}
|
||||
else {
|
||||
@ -68,18 +58,16 @@ namespace Emiliasmod.Content.Projectiles
|
||||
}
|
||||
|
||||
Projectile.spriteDirection = Projectile.direction;
|
||||
player.ChangeDir(Projectile.direction); // Change the player's direction based on the projectile's own
|
||||
player.heldProj = Projectile.whoAmI; // We tell the player that the drill is the held projectile, so it will draw in their hand
|
||||
player.SetDummyItemTime(2); // Make sure the player's item time does not change while the projectile is out
|
||||
Projectile.Center = playerCenter; // Centers the projectile on the player. Projectile.velocity will be added to this in later Terraria code causing the projectile to be held away from the player at a set distance.
|
||||
player.ChangeDir(Projectile.direction);
|
||||
player.heldProj = Projectile.whoAmI;
|
||||
player.SetDummyItemTime(2);
|
||||
Projectile.Center = playerCenter;
|
||||
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
||||
player.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation();
|
||||
|
||||
// Gives the drill a slight jiggle
|
||||
Projectile.velocity.X *= 1f + Main.rand.Next(-3, 4) * 0.01f;
|
||||
Projectile.velocity.Y *= 1f + Main.rand.Next(-3, 4) * 0.01f;
|
||||
|
||||
// Spawning dust
|
||||
if (Main.rand.NextBool(10)) {
|
||||
Dust dust = Dust.NewDustDirect(Projectile.position + Projectile.velocity * Main.rand.Next(6, 10) * 0.15f, Projectile.width, Projectile.height, DustID.Honey, 0f, 0f, 80, Color.White, 1f);
|
||||
dust.position.X -= 4f;
|
||||
|
||||
|
Before Width: | Height: | Size: 355 B |
@ -5,9 +5,12 @@ using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ModLoader.IO;
|
||||
using Terraria.ObjectData;
|
||||
|
||||
namespace Emiliasmod.Content.Projectiles
|
||||
{
|
||||
[Autoload(false)]
|
||||
public class SpaceBlasterProjectile : ModProjectile
|
||||
{
|
||||
public int JumpsLeft = 10;
|
||||
@ -19,7 +22,7 @@ namespace Emiliasmod.Content.Projectiles
|
||||
Projectile.friendly = true;
|
||||
Projectile.DamageType = DamageClass.Generic;
|
||||
Projectile.extraUpdates = 100;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.tileCollide = true;
|
||||
Projectile.timeLeft = 600;
|
||||
Projectile.CritChance = 0;
|
||||
Projectile.penetrate = -1;
|
||||
@ -58,14 +61,20 @@ namespace Emiliasmod.Content.Projectiles
|
||||
|
||||
private NPC FindNextTarget(Vector2 origin, float range) {
|
||||
NPC closest = null;
|
||||
float closestDist = range;
|
||||
float closestDistSq = range * range; // Use squared distance to avoid sqrt in loop
|
||||
|
||||
for (int i = 0; i < Main.maxNPCs; i++) {
|
||||
NPC npc = Main.npc[i];
|
||||
if (npc.CanBeChasedBy() && !hitTargets.Contains(npc.whoAmI)) {
|
||||
float dist = Vector2.Distance(origin, npc.Center);
|
||||
if (dist < closestDist) {
|
||||
closestDist = dist;
|
||||
closest = npc;
|
||||
|
||||
if (npc.active && npc.CanBeChasedBy() && !hitTargets.Contains(npc.whoAmI)) {
|
||||
float distSq = Vector2.DistanceSquared(origin, npc.Center);
|
||||
|
||||
if (distSq < closestDistSq) {
|
||||
// Check collision last (most expensive check)
|
||||
if (Collision.CanHitLine(origin, 1, 1, npc.position, npc.width, npc.height)) {
|
||||
closestDistSq = distSq;
|
||||
closest = npc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -75,12 +84,15 @@ namespace Emiliasmod.Content.Projectiles
|
||||
private static void DrawLightning(Vector2 start, Vector2 end) {
|
||||
int count = (int)(Vector2.Distance(start, end) / 8f);
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
||||
Vector2 pos = Vector2.Lerp(start, end, i / (float)count);
|
||||
Dust d1 = Dust.NewDustDirect(pos, 0, 0, DustID.Electric, Main.rand.Next(-3, 4), Main.rand.Next(-3, 4), 0, Color.Cyan, 0.8f);
|
||||
if (Main.rand.NextBool(10)) {
|
||||
Dust d1 = Dust.NewDustDirect(pos, 0, 0, DustID.Electric, Main.rand.Next(-3, 4), Main.rand.Next(-3, 4), 0, Color.Cyan, 0.8f);
|
||||
d1.noGravity = true;
|
||||
}
|
||||
Dust d2 = Dust.NewDustPerfect(pos, DustID.Electric, Vector2.Zero, 100, Color.Cyan, 0.8f);
|
||||
d1.noGravity = true;
|
||||
d2.noGravity = true;
|
||||
Lighting.AddLight(pos, Color.Cyan.ToVector3());
|
||||
Lighting.AddLight(pos, Color.Cyan.ToVector3());//may not be usefull
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 115 B |
@ -2,16 +2,73 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using Emiliasmod.Content.Items.Ammo;
|
||||
using Emiliasmod.Content.Items.Accessories;
|
||||
using Emiliasmod.Content.Items.Weapon;
|
||||
using Emiliasmod.Content.Projectiles;
|
||||
|
||||
// Please read https://github.com/tModLoader/tModLoader/wiki/Basic-tModLoader-Modding-Guide#mod-skeleton-contents for more information about the various files in a mod.
|
||||
namespace Emiliasmod
|
||||
{
|
||||
// Please read https://github.com/tModLoader/tModLoader/wiki/Basic-tModLoader-Modding-Guide#mod-skeleton-contents for more information about the various files in a mod.
|
||||
public static class InternalLoader {
|
||||
public static void Load(Mod mod) {
|
||||
var types = mod.Code.GetTypes();
|
||||
|
||||
foreach (Type type in types) {
|
||||
// 1. Must be a class and not abstract
|
||||
// 2. Must implement ILoadable (this covers ModItem, ModNPC, ModSystem, etc.)
|
||||
// 3. Optional: Check if it has the [Autoload(false)] attribute to confirm it's your target
|
||||
// !type.IsAbstract is the key here to skip BaseWing itself
|
||||
if (!type.IsAbstract && typeof(ILoadable).IsAssignableFrom(type)) {
|
||||
var instance = (ILoadable)Activator.CreateInstance(type);
|
||||
mod.AddContent(instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void Unload(Mod mod) {
|
||||
// Manual cleanup for statics if necessary
|
||||
// 1. Clear custom lists/dictionaries
|
||||
// hitTargets.Clear();
|
||||
|
||||
// 2. Nullify static references to textures/assets
|
||||
// MyBaseClass.CustomShader = null;
|
||||
|
||||
// 3. Use Reflection to nullify all statics in a specific namespace (Extreme approach)
|
||||
// Only do this if you have hundreds of static fields and want to be "lazy" but safe.
|
||||
var types = mod.Code.GetTypes();
|
||||
foreach (var type in types) {
|
||||
// Look for any static fields that are classes (not value types)
|
||||
var staticFields = type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
foreach (var field in staticFields) {
|
||||
if (!field.FieldType.IsValueType) {
|
||||
field.SetValue(null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Emiliasmod : Mod
|
||||
{
|
||||
public const string AssetPath = $"{nameof(Emiliasmod)}/Assets/";
|
||||
//public override bool IsLoadingEnabled(Mod tModLoader) => true;
|
||||
//need to load all of the mods here
|
||||
public override void Load() {
|
||||
InternalLoader.Load(this);
|
||||
//Spacesuit spacesuit = new Spacesuit(Spacesui);
|
||||
// Manual registration happens here
|
||||
AddContent<VacuumTube>();
|
||||
AddContent<QuantumVacuumTube>();
|
||||
}
|
||||
|
||||
public override void Unload() {
|
||||
InternalLoader.Unload(this);
|
||||
// Clear caches, static references, or arrays
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||