-
Notifications
You must be signed in to change notification settings - Fork 17
/
ModMBAddon.cs
127 lines (110 loc) · 3.75 KB
/
ModMBAddon.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using System;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.ModLoader;
using MetroidMod.Default;
using MetroidMod.ID;
namespace MetroidMod
{
public abstract class ModMBAddon : ModType
{
public int Type { get; private set; }
internal void ChangeType(int type) => Type = type;
/// <summary>
/// The <see cref="ModItem"/> this addon controls.
/// </summary>
public ModItem ModItem;
/// <summary>
/// The <see cref="ModTile"/> this addon controls.
/// </summary>
public ModTile ModTile;
/// <summary>
/// The <see cref="Item"/> this addon controls.
/// </summary>
public Item Item;
public int ItemType { get; internal set; }
public int TileType { get; internal set; }
/// <summary>
/// The translations for the display name of this item.
/// </summary>
public ModTranslation DisplayName { get; internal set; }
/// <summary>
/// The translations for the tooltip of this item.
/// </summary>
public ModTranslation Tooltip { get; internal set; }
public abstract string ItemTexture { get; }
public abstract string TileTexture { get; }
public abstract bool AddOnlyAddonItem { get; }
public int SacrificeTotal { get; set; } = 1;
public bool ItemNameLiteral { get; set; } = true;
public int AddonSlot { get; set; } = MorphBallAddonSlotID.None;
public string GetAddonSlotName() => MBAddonLoader.GetAddonSlotName(AddonSlot);
/// <summary>
/// Determines if the addon can generate on Chozo Statues during world generation.
/// </summary>
/// <param name="x">The X location of the tile</param>
/// <param name="y">The Y location of the tile</param>
public virtual bool CanGenerateOnChozoStatue(int x, int y) => false;
/// <summary>
/// Determines how likely the addon will generate on Chozo Statues.
/// </summary>
/// <param name="x">The X location of the tile</param>
/// <param name="y">The Y location of the tile</param>
public virtual double GenerationChance(int x, int y) { return 0; }
public override sealed void SetupContent()
{
SetStaticDefaults();
InternalStaticDefaults();
ModItem.SetStaticDefaults();
}
internal virtual void InternalStaticDefaults() { }
public override void Load()
{
ModItem = new MBAddonItem(this);
ModTile = new MBAddonTile(this);
if (ModItem == null) { throw new Exception("WTF happened here? MissileAddonItem is null!"); }
if (ModTile == null) { throw new Exception("WTF happened here? MissileAddonTile is null!"); }
Mod.AddContent(ModItem);
Mod.AddContent(ModTile);
}
public override void Unload()
{
ModItem.Unload();
ModTile.Unload();
ModItem = null;
ModTile = null;
Item = null;
base.Unload();
}
protected override sealed void Register()
{
DisplayName = LocalizationLoader.CreateTranslation(Mod, $"SuitAddonName.{Name}");
Tooltip = LocalizationLoader.CreateTranslation(Mod, $"SuitAddonTooltip.{Name}");
if (!AddOnlyAddonItem)
{
Type = MBAddonLoader.AddonCount;
if (Type > 127)
{
throw new Exception("Morph Ball Addons Limit Reached. (Max: 128)");
}
MBAddonLoader.addons.Add(this);
}
MetroidMod.Instance.Logger.Info("Register new Morph Ball Addon: " + FullName + ", OnlyAddonItem: " + AddOnlyAddonItem);
}
public override void SetStaticDefaults()
{
base.SetStaticDefaults();
}
/// <inheritdoc cref="ModItem.SetDefaults()"/>
public virtual void SetItemDefaults(Item item) { }
/// <inheritdoc cref="ModItem.UpdateEquip(Player)"/>
public virtual void UpdateEquip(Player player) { }
/// <inheritdoc cref="ModItem.AddRecipes"/>
public virtual void AddRecipes() { }
public Recipe CreateRecipe(int amount = 1) => ModItem.CreateRecipe(amount);
}
}