More inventory fixes

This commit is contained in:
2024-09-10 00:09:53 -07:00
parent b5798e7bc0
commit 086370987c
18 changed files with 373 additions and 63 deletions

View File

@@ -2,10 +2,12 @@ using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using GameJamDungeon;
using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
[Meta(typeof(IAutoNode))]
public partial class Accessory : Node3D, IInventoryItem, IEquipable
public partial class Accessory : Node3D, IInventoryItem, IEquipable, IEquatable<Accessory>
{
public override void _Notification(int what) => this.Notify(what);
@@ -35,4 +37,100 @@ public partial class Accessory : Node3D, IInventoryItem, IEquipable
GameRepo.InventoryItems.OnNext(inventoryList);
QueueFree();
}
public override bool Equals(object obj)
{
return Equals(obj as Accessory);
}
public bool Equals(Accessory other)
{
return other is not null &&
NativeInstance.Equals(other.NativeInstance) &&
EqualityComparer<NodePath>.Default.Equals(_ImportPath, other._ImportPath) &&
EqualityComparer<StringName>.Default.Equals(Name, other.Name) &&
UniqueNameInOwner == other.UniqueNameInOwner &&
SceneFilePath == other.SceneFilePath &&
EqualityComparer<Node>.Default.Equals(Owner, other.Owner) &&
EqualityComparer<MultiplayerApi>.Default.Equals(Multiplayer, other.Multiplayer) &&
ProcessMode == other.ProcessMode &&
ProcessPriority == other.ProcessPriority &&
ProcessPhysicsPriority == other.ProcessPhysicsPriority &&
ProcessThreadGroup == other.ProcessThreadGroup &&
ProcessThreadGroupOrder == other.ProcessThreadGroupOrder &&
ProcessThreadMessages == other.ProcessThreadMessages &&
PhysicsInterpolationMode == other.PhysicsInterpolationMode &&
AutoTranslateMode == other.AutoTranslateMode &&
EditorDescription == other.EditorDescription &&
Transform.Equals(other.Transform) &&
GlobalTransform.Equals(other.GlobalTransform) &&
Position.Equals(other.Position) &&
Rotation.Equals(other.Rotation) &&
RotationDegrees.Equals(other.RotationDegrees) &&
Quaternion.Equals(other.Quaternion) &&
Basis.Equals(other.Basis) &&
Scale.Equals(other.Scale) &&
RotationEditMode == other.RotationEditMode &&
RotationOrder == other.RotationOrder &&
TopLevel == other.TopLevel &&
GlobalPosition.Equals(other.GlobalPosition) &&
GlobalBasis.Equals(other.GlobalBasis) &&
GlobalRotation.Equals(other.GlobalRotation) &&
GlobalRotationDegrees.Equals(other.GlobalRotationDegrees) &&
Visible == other.Visible &&
EqualityComparer<NodePath>.Default.Equals(VisibilityParent, other.VisibilityParent) &&
EqualityComparer<IGameRepo>.Default.Equals(GameRepo, other.GameRepo) &&
EqualityComparer<InventoryItemInfo>.Default.Equals(Info, other.Info) &&
EqualityComparer<AccessoryInfo>.Default.Equals(AccessoryInfo, other.AccessoryInfo) &&
EqualityComparer<Sprite3D>.Default.Equals(Sprite, other.Sprite) &&
EqualityComparer<Area3D>.Default.Equals(Pickup, other.Pickup) &&
EqualityComparer<MixinBlackboard>.Default.Equals(MixinState, other.MixinState) &&
EqualityComparer<IMetatype>.Default.Equals(Metatype, other.Metatype);
}
public override int GetHashCode()
{
HashCode hash = new HashCode();
hash.Add(NativeInstance);
hash.Add(_ImportPath);
hash.Add(Name);
hash.Add(UniqueNameInOwner);
hash.Add(SceneFilePath);
hash.Add(Owner);
hash.Add(Multiplayer);
hash.Add(ProcessMode);
hash.Add(ProcessPriority);
hash.Add(ProcessPhysicsPriority);
hash.Add(ProcessThreadGroup);
hash.Add(ProcessThreadGroupOrder);
hash.Add(ProcessThreadMessages);
hash.Add(PhysicsInterpolationMode);
hash.Add(AutoTranslateMode);
hash.Add(EditorDescription);
hash.Add(Transform);
hash.Add(GlobalTransform);
hash.Add(Position);
hash.Add(Rotation);
hash.Add(RotationDegrees);
hash.Add(Quaternion);
hash.Add(Basis);
hash.Add(Scale);
hash.Add(RotationEditMode);
hash.Add(RotationOrder);
hash.Add(TopLevel);
hash.Add(GlobalPosition);
hash.Add(GlobalBasis);
hash.Add(GlobalRotation);
hash.Add(GlobalRotationDegrees);
hash.Add(Visible);
hash.Add(VisibilityParent);
hash.Add(GameRepo);
hash.Add(Info);
hash.Add(AccessoryInfo);
hash.Add(Sprite);
hash.Add(Pickup);
hash.Add(MixinState);
hash.Add(Metatype);
return hash.ToHashCode();
}
}

View File

@@ -2,10 +2,12 @@ using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using GameJamDungeon;
using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
[Meta(typeof(IAutoNode))]
public partial class Armor : Node3D, IInventoryItem, IEquipable
public partial class Armor : Node3D, IInventoryItem, IEquipable, IEquatable<Armor>
{
public override void _Notification(int what) => this.Notify(what);
@@ -14,7 +16,7 @@ public partial class Armor : Node3D, IInventoryItem, IEquipable
public InventoryItemInfo Info => ArmorInfo;
[Export]
public ArmorInfo ArmorInfo { get; set; }
public ArmorInfo ArmorInfo { get; set; } = new ArmorInfo();
[Node] public Sprite3D Sprite { get; set; } = default!;
@@ -35,4 +37,100 @@ public partial class Armor : Node3D, IInventoryItem, IEquipable
GameRepo.InventoryItems.OnNext(inventoryList);
QueueFree();
}
public override bool Equals(object obj)
{
return Equals(obj as Armor);
}
public bool Equals(Armor other)
{
return other is not null &&
NativeInstance.Equals(other.NativeInstance) &&
EqualityComparer<NodePath>.Default.Equals(_ImportPath, other._ImportPath) &&
EqualityComparer<StringName>.Default.Equals(Name, other.Name) &&
UniqueNameInOwner == other.UniqueNameInOwner &&
SceneFilePath == other.SceneFilePath &&
EqualityComparer<Node>.Default.Equals(Owner, other.Owner) &&
EqualityComparer<MultiplayerApi>.Default.Equals(Multiplayer, other.Multiplayer) &&
ProcessMode == other.ProcessMode &&
ProcessPriority == other.ProcessPriority &&
ProcessPhysicsPriority == other.ProcessPhysicsPriority &&
ProcessThreadGroup == other.ProcessThreadGroup &&
ProcessThreadGroupOrder == other.ProcessThreadGroupOrder &&
ProcessThreadMessages == other.ProcessThreadMessages &&
PhysicsInterpolationMode == other.PhysicsInterpolationMode &&
AutoTranslateMode == other.AutoTranslateMode &&
EditorDescription == other.EditorDescription &&
Transform.Equals(other.Transform) &&
GlobalTransform.Equals(other.GlobalTransform) &&
Position.Equals(other.Position) &&
Rotation.Equals(other.Rotation) &&
RotationDegrees.Equals(other.RotationDegrees) &&
Quaternion.Equals(other.Quaternion) &&
Basis.Equals(other.Basis) &&
Scale.Equals(other.Scale) &&
RotationEditMode == other.RotationEditMode &&
RotationOrder == other.RotationOrder &&
TopLevel == other.TopLevel &&
GlobalPosition.Equals(other.GlobalPosition) &&
GlobalBasis.Equals(other.GlobalBasis) &&
GlobalRotation.Equals(other.GlobalRotation) &&
GlobalRotationDegrees.Equals(other.GlobalRotationDegrees) &&
Visible == other.Visible &&
EqualityComparer<NodePath>.Default.Equals(VisibilityParent, other.VisibilityParent) &&
EqualityComparer<IGameRepo>.Default.Equals(GameRepo, other.GameRepo) &&
EqualityComparer<InventoryItemInfo>.Default.Equals(Info, other.Info) &&
EqualityComparer<ArmorInfo>.Default.Equals(ArmorInfo, other.ArmorInfo) &&
EqualityComparer<Sprite3D>.Default.Equals(Sprite, other.Sprite) &&
EqualityComparer<Area3D>.Default.Equals(Pickup, other.Pickup) &&
EqualityComparer<MixinBlackboard>.Default.Equals(MixinState, other.MixinState) &&
EqualityComparer<IMetatype>.Default.Equals(Metatype, other.Metatype);
}
public override int GetHashCode()
{
HashCode hash = new HashCode();
hash.Add(NativeInstance);
hash.Add(_ImportPath);
hash.Add(Name);
hash.Add(UniqueNameInOwner);
hash.Add(SceneFilePath);
hash.Add(Owner);
hash.Add(Multiplayer);
hash.Add(ProcessMode);
hash.Add(ProcessPriority);
hash.Add(ProcessPhysicsPriority);
hash.Add(ProcessThreadGroup);
hash.Add(ProcessThreadGroupOrder);
hash.Add(ProcessThreadMessages);
hash.Add(PhysicsInterpolationMode);
hash.Add(AutoTranslateMode);
hash.Add(EditorDescription);
hash.Add(Transform);
hash.Add(GlobalTransform);
hash.Add(Position);
hash.Add(Rotation);
hash.Add(RotationDegrees);
hash.Add(Quaternion);
hash.Add(Basis);
hash.Add(Scale);
hash.Add(RotationEditMode);
hash.Add(RotationOrder);
hash.Add(TopLevel);
hash.Add(GlobalPosition);
hash.Add(GlobalBasis);
hash.Add(GlobalRotation);
hash.Add(GlobalRotationDegrees);
hash.Add(Visible);
hash.Add(VisibilityParent);
hash.Add(GameRepo);
hash.Add(Info);
hash.Add(ArmorInfo);
hash.Add(Sprite);
hash.Add(Pickup);
hash.Add(MixinState);
hash.Add(Metatype);
return hash.ToHashCode();
}
}

View File

@@ -6,20 +6,20 @@ namespace GameJamDungeon;
public partial class ArmorInfo : InventoryItemInfo
{
[Export]
public int Defense { get; set; }
public int Defense { get; set; } = 0;
[Export]
public double TelluricResistance { get; set; }
public double TelluricResistance { get; set; } = 0;
[Export]
public double AeolicResistance { get; set; }
public double AeolicResistance { get; set; } = 0;
[Export]
public double HydricResistance { get; set; }
public double HydricResistance { get; set; } = 0;
[Export]
public double IgneousResistance { get; set; }
public double IgneousResistance { get; set; } = 0;
[Export]
public double FerrumResistance { get; set; }
public double FerrumResistance { get; set; } = 0;
}

View File

@@ -11,6 +11,7 @@ AeolicResistance = 0.0
HydricResistance = 0.0
IgneousResistance = 0.0
FerrumResistance = 0.0
Texture = ExtResource("1_p85jd")
Name = "Acceptance"
Description = ""
Description = "+9 DEF"
Texture = ExtResource("1_p85jd")
SpawnRate = 0.5

View File

@@ -11,6 +11,7 @@ AeolicResistance = 0.0
HydricResistance = 0.0
IgneousResistance = 0.0
FerrumResistance = 0.0
Texture = ExtResource("1_588l8")
Name = "Atoner's Adornments"
Description = ""
Description = "+1 DEF"
Texture = ExtResource("1_588l8")
SpawnRate = 0.5

View File

@@ -11,6 +11,7 @@ AeolicResistance = 0.0
HydricResistance = 0.0
IgneousResistance = 0.0
FerrumResistance = 0.0
Texture = ExtResource("1_s4gpg")
Name = "Ceremonial Vestments"
Description = ""
Description = "+2 DEF"
Texture = ExtResource("1_s4gpg")
SpawnRate = 0.5

View File

@@ -11,6 +11,7 @@ AeolicResistance = 0.0
HydricResistance = 0.0
IgneousResistance = 0.0
FerrumResistance = 0.0
Texture = ExtResource("1_5ik54")
Name = "Devic Layers"
Description = ""
Description = "+7 DEF"
Texture = ExtResource("1_5ik54")
SpawnRate = 0.5

View File

@@ -11,6 +11,7 @@ AeolicResistance = 0.0
HydricResistance = 0.0
IgneousResistance = 0.0
FerrumResistance = 0.0
Texture = ExtResource("1_5vleh")
Name = "Goddess' Robe"
Description = ""
Description = "+8 DEF"
Texture = ExtResource("1_5vleh")
SpawnRate = 0.5

View File

@@ -11,6 +11,7 @@ AeolicResistance = 0.0
HydricResistance = 0.0
IgneousResistance = 0.0
FerrumResistance = 0.0
Texture = ExtResource("1_jyoar")
Name = "Iron Cage"
Description = ""
Description = "+4 DEF"
Texture = ExtResource("1_jyoar")
SpawnRate = 0.5

View File

@@ -11,6 +11,7 @@ AeolicResistance = 0.0
HydricResistance = 0.0
IgneousResistance = 0.0
FerrumResistance = 0.0
Texture = ExtResource("1_kh3n2")
Name = "Logistician's Garb"
Description = ""
Description = "+5 DEF"
Texture = ExtResource("1_kh3n2")
SpawnRate = 0.5

View File

@@ -11,6 +11,7 @@ AeolicResistance = 0.0
HydricResistance = 0.0
IgneousResistance = 0.0
FerrumResistance = 0.0
Texture = ExtResource("1_xpphu")
Name = "Stoic"
Description = ""
Description = "+6 DEF"
Texture = ExtResource("1_xpphu")
SpawnRate = 0.5

View File

@@ -11,6 +11,7 @@ AeolicResistance = 0.0
HydricResistance = 0.0
IgneousResistance = 0.0
FerrumResistance = 0.0
Texture = ExtResource("1_vs6ua")
Name = "Wooden Armament"
Description = ""
Description = "+3 DEF"
Texture = ExtResource("1_vs6ua")
SpawnRate = 0.5

View File

@@ -2,16 +2,13 @@ using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using GameJamDungeon;
using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
[Meta(typeof(IAutoNode))]
public partial class Weapon : Node3D, IInventoryItem, IEquipable
public partial class Weapon : Node3D, IInventoryItem, IEquipable, IEquatable<Weapon>
{
public Weapon()
{
WeaponInfo = new WeaponInfo() { Damage = 1, WeaponTags = new Godot.Collections.Array<WeaponTag>(), Texture = new Texture2D() };
}
public override void _Notification(int what) => this.Notify(what);
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
@@ -19,7 +16,7 @@ public partial class Weapon : Node3D, IInventoryItem, IEquipable
public InventoryItemInfo Info => WeaponInfo;
[Export]
public WeaponInfo WeaponInfo { get; set; }
public WeaponInfo WeaponInfo { get; set; } = new WeaponInfo() { Damage = 1 };
[Node] public Sprite3D Sprite { get; set; } = default!;
@@ -40,4 +37,100 @@ public partial class Weapon : Node3D, IInventoryItem, IEquipable
GameRepo.InventoryItems.OnNext(inventoryList);
QueueFree();
}
public override bool Equals(object obj)
{
return Equals(obj as Weapon);
}
public bool Equals(Weapon other)
{
return other is not null &&
NativeInstance.Equals(other.NativeInstance) &&
EqualityComparer<NodePath>.Default.Equals(_ImportPath, other._ImportPath) &&
EqualityComparer<StringName>.Default.Equals(Name, other.Name) &&
UniqueNameInOwner == other.UniqueNameInOwner &&
SceneFilePath == other.SceneFilePath &&
EqualityComparer<Node>.Default.Equals(Owner, other.Owner) &&
EqualityComparer<MultiplayerApi>.Default.Equals(Multiplayer, other.Multiplayer) &&
ProcessMode == other.ProcessMode &&
ProcessPriority == other.ProcessPriority &&
ProcessPhysicsPriority == other.ProcessPhysicsPriority &&
ProcessThreadGroup == other.ProcessThreadGroup &&
ProcessThreadGroupOrder == other.ProcessThreadGroupOrder &&
ProcessThreadMessages == other.ProcessThreadMessages &&
PhysicsInterpolationMode == other.PhysicsInterpolationMode &&
AutoTranslateMode == other.AutoTranslateMode &&
EditorDescription == other.EditorDescription &&
Transform.Equals(other.Transform) &&
GlobalTransform.Equals(other.GlobalTransform) &&
Position.Equals(other.Position) &&
Rotation.Equals(other.Rotation) &&
RotationDegrees.Equals(other.RotationDegrees) &&
Quaternion.Equals(other.Quaternion) &&
Basis.Equals(other.Basis) &&
Scale.Equals(other.Scale) &&
RotationEditMode == other.RotationEditMode &&
RotationOrder == other.RotationOrder &&
TopLevel == other.TopLevel &&
GlobalPosition.Equals(other.GlobalPosition) &&
GlobalBasis.Equals(other.GlobalBasis) &&
GlobalRotation.Equals(other.GlobalRotation) &&
GlobalRotationDegrees.Equals(other.GlobalRotationDegrees) &&
Visible == other.Visible &&
EqualityComparer<NodePath>.Default.Equals(VisibilityParent, other.VisibilityParent) &&
EqualityComparer<IGameRepo>.Default.Equals(GameRepo, other.GameRepo) &&
EqualityComparer<InventoryItemInfo>.Default.Equals(Info, other.Info) &&
EqualityComparer<WeaponInfo>.Default.Equals(WeaponInfo, other.WeaponInfo) &&
EqualityComparer<Sprite3D>.Default.Equals(Sprite, other.Sprite) &&
EqualityComparer<Area3D>.Default.Equals(Pickup, other.Pickup) &&
EqualityComparer<MixinBlackboard>.Default.Equals(MixinState, other.MixinState) &&
EqualityComparer<IMetatype>.Default.Equals(Metatype, other.Metatype);
}
public override int GetHashCode()
{
HashCode hash = new HashCode();
hash.Add(NativeInstance);
hash.Add(_ImportPath);
hash.Add(Name);
hash.Add(UniqueNameInOwner);
hash.Add(SceneFilePath);
hash.Add(Owner);
hash.Add(Multiplayer);
hash.Add(ProcessMode);
hash.Add(ProcessPriority);
hash.Add(ProcessPhysicsPriority);
hash.Add(ProcessThreadGroup);
hash.Add(ProcessThreadGroupOrder);
hash.Add(ProcessThreadMessages);
hash.Add(PhysicsInterpolationMode);
hash.Add(AutoTranslateMode);
hash.Add(EditorDescription);
hash.Add(Transform);
hash.Add(GlobalTransform);
hash.Add(Position);
hash.Add(Rotation);
hash.Add(RotationDegrees);
hash.Add(Quaternion);
hash.Add(Basis);
hash.Add(Scale);
hash.Add(RotationEditMode);
hash.Add(RotationOrder);
hash.Add(TopLevel);
hash.Add(GlobalPosition);
hash.Add(GlobalBasis);
hash.Add(GlobalRotation);
hash.Add(GlobalRotationDegrees);
hash.Add(Visible);
hash.Add(VisibilityParent);
hash.Add(GameRepo);
hash.Add(Info);
hash.Add(WeaponInfo);
hash.Add(Sprite);
hash.Add(Pickup);
hash.Add(MixinState);
hash.Add(Metatype);
return hash.ToHashCode();
}
}

View File

@@ -4,14 +4,8 @@ using Godot;
[GlobalClass]
public partial class WeaponInfo : InventoryItemInfo
{
public WeaponInfo()
{
Damage = 1;
WeaponTags = new Godot.Collections.Array<WeaponTag>();
}
[Export]
public int Damage { get; set; }
public int Damage { get; set; } = 1;
[Export]
public double Luck { get; set; } = 0.05;
@@ -20,19 +14,19 @@ public partial class WeaponInfo : InventoryItemInfo
public double AttackSpeed { get; set; } = 1;
[Export]
public double TelluricDamageBonus { get; set; }
public double TelluricDamageBonus { get; set; } = 0;
[Export]
public double AeolicDamageBonus { get; set; }
public double AeolicDamageBonus { get; set; } = 0;
[Export]
public double BaseHydricDamageBonus { get; set; }
public double BaseHydricDamageBonus { get; set; } = 0;
[Export]
public double IgneousDamageBonus { get; set; }
public double IgneousDamageBonus { get; set; } = 0;
[Export]
public double FerrumDamageBonus { get; set; }
public double FerrumDamageBonus { get; set; } = 0;
[Export]
public Godot.Collections.Array<WeaponTag> WeaponTags { get; set; } = new Godot.Collections.Array<WeaponTag>();