313 lines
6.2 KiB
C#
313 lines
6.2 KiB
C#
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/Data/Items.cs")]
|
|
public partial class Items : Node
|
|
{
|
|
public enum IDs
|
|
{
|
|
None = -1,
|
|
BallOfJunk,
|
|
ToyGun,
|
|
SpikedClub,
|
|
CorkPistol,
|
|
LeatherVest,
|
|
LeatherPoncho,
|
|
Hat,
|
|
ShinyMedal,
|
|
BrickCandy,
|
|
RevivalMint,
|
|
PopRock,
|
|
RawGunpowder,
|
|
WantedPoster,
|
|
Peashooter,
|
|
SoftballBat,
|
|
KanakoPhone,
|
|
TensionBit,
|
|
TensionGem,
|
|
TensionMax,
|
|
GoldenBell,
|
|
FoxNecklace,
|
|
KetsukaneHeirloom,
|
|
FoxStaff,
|
|
RedLetter,
|
|
AxisGloves,
|
|
BearPin,
|
|
HomemadeLunch,
|
|
KingFeast,
|
|
SafetyVest,
|
|
SpaceGun,
|
|
RobotFist,
|
|
SafetyGoggles,
|
|
TrueBat,
|
|
BaseballCap,
|
|
MagicRing,
|
|
Firecracker,
|
|
Bomb,
|
|
GuardianMitt,
|
|
GiantScrewdriver
|
|
}
|
|
|
|
public enum Type
|
|
{
|
|
Normal,
|
|
Key,
|
|
Weapon,
|
|
Equip,
|
|
Money,
|
|
LightWorld,
|
|
Storage
|
|
}
|
|
|
|
public partial class Data
|
|
{
|
|
public bool tossable = true;
|
|
|
|
public bool consumable = true;
|
|
|
|
public Type type;
|
|
}
|
|
|
|
public static bool CheckFull(Type inv)
|
|
{
|
|
if (inv == Type.Normal)
|
|
{
|
|
if (SaveFile.current.flags.Contains(SaveFile.Flags.IsInDW))
|
|
{
|
|
if (SaveFile.current.dwItems.Count >= 12)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
else if (SaveFile.current.lwItems.Count >= 8)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static void AddItem(IDs id, Type inv)
|
|
{
|
|
switch (inv)
|
|
{
|
|
case Type.Normal:
|
|
if (SaveFile.current.flags.Contains(SaveFile.Flags.IsInDW))
|
|
{
|
|
SaveFile.current.dwItems.Add(id);
|
|
}
|
|
else
|
|
{
|
|
SaveFile.current.lwItems.Add(id);
|
|
}
|
|
break;
|
|
case Type.Weapon:
|
|
SaveFile.current.dwWeapon.Add(id);
|
|
break;
|
|
case Type.Equip:
|
|
SaveFile.current.dwArmor.Add(id);
|
|
break;
|
|
case Type.Key:
|
|
SaveFile.current.dwKey.Add(id);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public static bool RemoveItem(IDs id, Type? pouch = null, bool checkEquipped = false)
|
|
{
|
|
if ((!pouch.HasValue || pouch == Type.Normal) && SaveFile.current.dwItems.Remove(id))
|
|
{
|
|
return true;
|
|
}
|
|
if (!pouch.HasValue || pouch == Type.Weapon)
|
|
{
|
|
if (SaveFile.current.dwWeapon.Remove(id))
|
|
{
|
|
return true;
|
|
}
|
|
if (checkEquipped)
|
|
{
|
|
for (int i = 0; i < SaveFile.current.activeParty.Count; i++)
|
|
{
|
|
if (Party.party[SaveFile.current.activeParty[i]].EQUIP[0] == (int)id)
|
|
{
|
|
Party.party[SaveFile.current.activeParty[i]].EQUIP[0] = -1;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!pouch.HasValue || pouch == Type.Equip)
|
|
{
|
|
if (SaveFile.current.dwArmor.Remove(id))
|
|
{
|
|
return true;
|
|
}
|
|
if (checkEquipped)
|
|
{
|
|
for (int j = 0; j < SaveFile.current.activeParty.Count; j++)
|
|
{
|
|
if (Party.party[SaveFile.current.activeParty[j]].EQUIP[1] == (int)id)
|
|
{
|
|
Party.party[SaveFile.current.activeParty[j]].EQUIP[1] = -1;
|
|
return true;
|
|
}
|
|
if (Party.party[SaveFile.current.activeParty[j]].EQUIP[2] == (int)id)
|
|
{
|
|
Party.party[SaveFile.current.activeParty[j]].EQUIP[2] = -1;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ((!pouch.HasValue || pouch == Type.Key) && SaveFile.current.dwKey.Remove(id))
|
|
{
|
|
return true;
|
|
}
|
|
if ((!pouch.HasValue || pouch == Type.LightWorld) && SaveFile.current.lwItems.Remove(id))
|
|
{
|
|
return true;
|
|
}
|
|
if ((!pouch.HasValue || pouch == Type.Storage) && SaveFile.current.storage.Remove(id))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static bool HasItem(IDs id, Type? pouch = null, bool checkEquipped = true)
|
|
{
|
|
if ((!pouch.HasValue || pouch == Type.Normal) && SaveFile.current.dwItems.Contains(id))
|
|
{
|
|
return true;
|
|
}
|
|
if (!pouch.HasValue || pouch == Type.Weapon)
|
|
{
|
|
if (SaveFile.current.dwWeapon.Contains(id))
|
|
{
|
|
return true;
|
|
}
|
|
if (checkEquipped)
|
|
{
|
|
for (int i = 0; i < SaveFile.current.activeParty.Count; i++)
|
|
{
|
|
if (Party.party[SaveFile.current.activeParty[i]].EQUIP[0] == (int)id)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!pouch.HasValue || pouch == Type.Equip)
|
|
{
|
|
if (SaveFile.current.dwArmor.Contains(id))
|
|
{
|
|
return true;
|
|
}
|
|
if (checkEquipped)
|
|
{
|
|
for (int j = 0; j < SaveFile.current.activeParty.Count; j++)
|
|
{
|
|
if (Party.party[SaveFile.current.activeParty[j]].EQUIP[1] == (int)id)
|
|
{
|
|
return true;
|
|
}
|
|
if (Party.party[SaveFile.current.activeParty[j]].EQUIP[2] == (int)id)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ((!pouch.HasValue || pouch == Type.Key) && SaveFile.current.dwKey.Contains(id))
|
|
{
|
|
return true;
|
|
}
|
|
if ((!pouch.HasValue || pouch == Type.LightWorld) && SaveFile.current.lwItems.Contains(id))
|
|
{
|
|
return true;
|
|
}
|
|
if ((!pouch.HasValue || pouch == Type.Storage) && SaveFile.current.storage.Contains(id))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static void UseItem(IDs id)
|
|
{
|
|
Player.instance.CallDeferred("StopInput");
|
|
Player.instance.CallDeferred("PartyStop");
|
|
if (id != IDs.Hat)
|
|
{
|
|
string useDiag = Texts.items[id].useDiag;
|
|
if (useDiag != null && useDiag.Length > 0)
|
|
{
|
|
if (Texts.items[id].useDiag[0] == '@')
|
|
{
|
|
CommonEvents.DoEvent(Texts.items[id].useDiag.Remove(0, 1));
|
|
}
|
|
else
|
|
{
|
|
TextSystem.GetText(Texts.items[id].useDiag);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string callEvent = Texts.items[id].callEvent;
|
|
if (callEvent != null && callEvent.Length > 0)
|
|
{
|
|
CommonEvents.DoEvent(Texts.items[id].callEvent);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Party.StopMoving();
|
|
if (Player.instance.animMod != Entity.AnimMods.Hat)
|
|
{
|
|
Player.instance.animMod = Entity.AnimMods.Hat;
|
|
Player.instance.UpdateAnim(force: true);
|
|
TextSystem.GetText("EquipHat");
|
|
}
|
|
else
|
|
{
|
|
Player.instance.animMod = Entity.AnimMods.None;
|
|
Player.instance.UpdateAnim(force: true);
|
|
TextSystem.GetText("RemoveHat");
|
|
}
|
|
}
|
|
if (Texts.items[id].nonConsumable)
|
|
{
|
|
return;
|
|
}
|
|
if (!SaveFile.current.flags.Contains(SaveFile.Flags.IsInDW))
|
|
{
|
|
Player instance = Player.instance;
|
|
if (instance == null || instance.animMod != Entity.AnimMods.DW)
|
|
{
|
|
SaveFile.current.lwItems.Remove(id);
|
|
return;
|
|
}
|
|
}
|
|
switch (Texts.items[id].type)
|
|
{
|
|
case Type.Normal:
|
|
SaveFile.current.dwItems.Remove(id);
|
|
break;
|
|
case Type.Weapon:
|
|
SaveFile.current.dwWeapon.Remove(id);
|
|
break;
|
|
case Type.Equip:
|
|
SaveFile.current.dwArmor.Remove(id);
|
|
break;
|
|
case Type.Key:
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|