From 086370987c9b4fe8c67400f272a0b393541ce588 Mon Sep 17 00:00:00 2001 From: Zenny Date: Tue, 10 Sep 2024 00:09:53 -0700 Subject: [PATCH] More inventory fixes --- src/game/IGameRepo.cs | 4 + src/inventory_menu/InventoryMenu.cs | 22 ++-- src/inventory_menu/InventoryMenu.tscn | 15 ++- src/inventory_menu/ItemSlot.tscn | 11 +- src/items/accessory/Accessory.cs | 100 +++++++++++++++- src/items/armor/Armor.cs | 102 ++++++++++++++++- src/items/armor/ArmorInfo.cs | 12 +- src/items/armor/resources/Acceptance.tres | 5 +- .../armor/resources/AtonersAdornments.tres | 5 +- .../armor/resources/CeremonialVestments.tres | 5 +- src/items/armor/resources/DevicLayer.tres | 5 +- src/items/armor/resources/GoddessRobe.tres | 5 +- src/items/armor/resources/IronCage.tres | 5 +- .../armor/resources/LogisticiansGarb.tres | 5 +- src/items/armor/resources/Stoic.tres | 5 +- src/items/armor/resources/WoodenArmament.tres | 5 +- src/items/weapons/Weapon.cs | 107 ++++++++++++++++-- src/items/weapons/WeaponInfo.cs | 18 +-- 18 files changed, 373 insertions(+), 63 deletions(-) diff --git a/src/game/IGameRepo.cs b/src/game/IGameRepo.cs index 05fa260a..4a839710 100644 --- a/src/game/IGameRepo.cs +++ b/src/game/IGameRepo.cs @@ -116,11 +116,15 @@ public class GameRepo : IGameRepo public void OnWeaponEquipped(Weapon equippedItem) { + PlayerStatInfo.Value.BonusAttack -= _equippedWeapon.Value.WeaponInfo.Damage; + PlayerStatInfo.Value.BonusAttack += equippedItem.WeaponInfo.Damage; _equippedWeapon.OnNext(equippedItem); } public void OnArmorEquipped(Armor equippedItem) { + PlayerStatInfo.Value.BonusDefense -= _equippedArmor.Value.ArmorInfo.Defense; + PlayerStatInfo.Value.BonusDefense += equippedItem.ArmorInfo.Defense; _equippedArmor.OnNext(equippedItem); } diff --git a/src/inventory_menu/InventoryMenu.cs b/src/inventory_menu/InventoryMenu.cs index 921cd74f..5046e3fd 100644 --- a/src/inventory_menu/InventoryMenu.cs +++ b/src/inventory_menu/InventoryMenu.cs @@ -58,8 +58,8 @@ public partial class InventoryMenu : Control, IInventoryMenu public void PopulateItems() { - PopulatePlayerInfo(); PopulateInventory(); + PopulatePlayerInfo(); } public void PopulatePlayerInfo() @@ -102,13 +102,9 @@ public partial class InventoryMenu : Control, IInventoryMenu if (ItemSlots.Any()) { - ItemDescriptionTitle.Text = $"{ItemSlots.ElementAtOrDefault(_currentIndex).Item.Info.Name}"; - ItemEffectLabel.Text = $"{ItemSlots.ElementAtOrDefault(_currentIndex).Item.Info.Description}"; - } - else - { - ItemDescriptionTitle.Text = string.Empty; - ItemEffectLabel.Text = string.Empty; + var item = ItemSlots.ElementAt(_currentIndex).Item; + ItemDescriptionTitle.Text = $"{item.Info.Name}"; + ItemEffectLabel.Text = $"{item.Info.Description}"; } } @@ -187,6 +183,9 @@ public partial class InventoryMenu : Control, IInventoryMenu oldItem.SetEquippedItemStyle(); if (newItem.Item is IEquipable newEquipable && GameRepo.IsItemEquipped(newEquipable)) newItem.SetEquippedSelectedItemStyle(); + + ItemDescriptionTitle.Text = $"{newItem.Item.Info.Name}"; + ItemEffectLabel.Text = $"{newItem.Item.Info.Description}"; } if (ItemSlots.Any() && Input.IsActionJustPressed(GameInputs.UiUp)) @@ -204,6 +203,8 @@ public partial class InventoryMenu : Control, IInventoryMenu oldItem.SetEquippedItemStyle(); if (newItem.Item is IEquipable newEquipable && GameRepo.IsItemEquipped(newEquipable)) newItem.SetEquippedSelectedItemStyle(); + ItemDescriptionTitle.Text = $"{newItem.Item.Info.Name}"; + ItemEffectLabel.Text = $"{newItem.Item.Info.Description}"; } if (ItemSlots.Any() && Input.IsActionJustPressed(GameInputs.UiAccept)) @@ -221,6 +222,11 @@ public partial class InventoryMenu : Control, IInventoryMenu GameRepo.EquipItem(equipableItem); itemSlot.SetEquippedSelectedItemStyle(); } + + var atkBonus = GameRepo.PlayerStatInfo.Value.BonusAttack; + ATKBonusLabel.Text = atkBonus != 0 ? $"{atkBonus:+0;-#}" : "..."; + var defBonus = GameRepo.PlayerStatInfo.Value.BonusDefense; + DEFBonusLabel.Text = defBonus != 0 ? $"{defBonus:+0;-#}" : "..."; } } } diff --git a/src/inventory_menu/InventoryMenu.tscn b/src/inventory_menu/InventoryMenu.tscn index 2993051c..adabde20 100644 --- a/src/inventory_menu/InventoryMenu.tscn +++ b/src/inventory_menu/InventoryMenu.tscn @@ -5,7 +5,6 @@ [ext_resource type="FontFile" uid="uid://cm8j5vcdop5x0" path="res://src/ui/fonts/Mrs-Eaves-OT-Roman_31443.ttf" id="3_lm4o1"] [ext_resource type="FontFile" uid="uid://cb41qqmxqurj8" path="res://src/ui/fonts/FT88-Bold.ttf" id="4_rg5yb"] [ext_resource type="FontFile" uid="uid://dit3vylt7hmmx" path="res://src/ui/fonts/FT88-Regular.ttf" id="5_2qnnx"] -[ext_resource type="LabelSettings" uid="uid://dupifadnagodp" path="res://src/ui/label_settings/MainTextRegular.tres" id="5_v2ky8"] [ext_resource type="LabelSettings" uid="uid://c4wbba5mo7qcp" path="res://src/ui/label_settings/MainTextFontItalicized.tres" id="6_q3oua"] [ext_resource type="LabelSettings" uid="uid://ca1q6yu8blwxf" path="res://src/ui/label_settings/InventoryMainTextBold.tres" id="6_tmdno"] @@ -66,6 +65,11 @@ font = ExtResource("4_rg5yb") font_size = 46 font_color = Color(0.737255, 0.705882, 0.690196, 1) +[sub_resource type="LabelSettings" id="LabelSettings_mundu"] +font = ExtResource("5_2qnnx") +font_size = 28 +font_color = Color(0.737255, 0.705882, 0.690196, 1) + [sub_resource type="LabelSettings" id="LabelSettings_x4aj3"] font = ExtResource("3_lm4o1") font_size = 80 @@ -307,7 +311,7 @@ text = "..." label_settings = ExtResource("6_tmdno") [node name="ReferenceRect3" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/PlayerInfo"] -custom_minimum_size = Vector2(0, 55) +custom_minimum_size = Vector2(0, 25) layout_mode = 2 [node name="HBoxContainer" type="HBoxContainer" parent="InventoryInfo/HBoxContainer/PlayerInfo"] @@ -335,13 +339,12 @@ custom_minimum_size = Vector2(800, 200) layout_mode = 2 size_flags_horizontal = 0 text = "Raises ATK" -label_settings = ExtResource("5_v2ky8") +label_settings = SubResource("LabelSettings_mundu") autowrap_mode = 2 [node name="ItemInfo" type="VBoxContainer" parent="InventoryInfo/HBoxContainer"] layout_mode = 2 -size_flags_horizontal = 6 -theme_override_constants/separation = 30 +theme_override_constants/separation = 20 [node name="HBoxContainer" type="HBoxContainer" parent="InventoryInfo/HBoxContainer/ItemInfo"] custom_minimum_size = Vector2(800, 0) @@ -380,5 +383,5 @@ theme_override_constants/separation = 15 alignment = 1 [node name="ReferenceRect3" type="ReferenceRect" parent="InventoryInfo/HBoxContainer/ItemInfo/ItemsPage"] -custom_minimum_size = Vector2(0, 38) +custom_minimum_size = Vector2(0, 14) layout_mode = 2 diff --git a/src/inventory_menu/ItemSlot.tscn b/src/inventory_menu/ItemSlot.tscn index ef4bafea..4f114621 100644 --- a/src/inventory_menu/ItemSlot.tscn +++ b/src/inventory_menu/ItemSlot.tscn @@ -1,10 +1,15 @@ -[gd_scene load_steps=6 format=3 uid="uid://c005nd0m2eim"] +[gd_scene load_steps=7 format=3 uid="uid://c005nd0m2eim"] [ext_resource type="LabelSettings" uid="uid://ca1q6yu8blwxf" path="res://src/ui/label_settings/InventoryMainTextBold.tres" id="1_ybfv1"] [ext_resource type="Script" path="res://src/inventory_menu/ItemSlot.cs" id="1_yttxt"] [ext_resource type="Texture2D" uid="uid://0r1dws4ajhdx" path="res://src/items/accessory/textures/MASK 01.PNG" id="2_7kdbd"] [ext_resource type="Script" path="res://src/inventory_menu/ItemLabel.cs" id="3_xlgl0"] -[ext_resource type="LabelSettings" uid="uid://b3jrpf2sdtsqo" path="res://src/ui/label_settings/MainTextFontSelectedEquipped.tres" id="4_xl2xb"] +[ext_resource type="FontFile" uid="uid://bohbd123672ea" path="res://src/ui/fonts/FT88-Italic.ttf" id="4_vcxwm"] + +[sub_resource type="LabelSettings" id="LabelSettings_lgjx0"] +font = ExtResource("4_vcxwm") +font_size = 30 +font_color = Color(0, 0.682353, 0.937255, 1) [node name="ItemSlot" type="HBoxContainer"] custom_minimum_size = Vector2(100, 60) @@ -40,7 +45,7 @@ unique_name_in_owner = true custom_minimum_size = Vector2(600, 50) layout_mode = 2 text = "Mask of the Goddess of Destruction" -label_settings = ExtResource("4_xl2xb") +label_settings = SubResource("LabelSettings_lgjx0") vertical_alignment = 1 autowrap_mode = 2 script = ExtResource("3_xlgl0") diff --git a/src/items/accessory/Accessory.cs b/src/items/accessory/Accessory.cs index 6fc73778..63640e92 100644 --- a/src/items/accessory/Accessory.cs +++ b/src/items/accessory/Accessory.cs @@ -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 { 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.Default.Equals(_ImportPath, other._ImportPath) && + EqualityComparer.Default.Equals(Name, other.Name) && + UniqueNameInOwner == other.UniqueNameInOwner && + SceneFilePath == other.SceneFilePath && + EqualityComparer.Default.Equals(Owner, other.Owner) && + EqualityComparer.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.Default.Equals(VisibilityParent, other.VisibilityParent) && + EqualityComparer.Default.Equals(GameRepo, other.GameRepo) && + EqualityComparer.Default.Equals(Info, other.Info) && + EqualityComparer.Default.Equals(AccessoryInfo, other.AccessoryInfo) && + EqualityComparer.Default.Equals(Sprite, other.Sprite) && + EqualityComparer.Default.Equals(Pickup, other.Pickup) && + EqualityComparer.Default.Equals(MixinState, other.MixinState) && + EqualityComparer.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(); + } } diff --git a/src/items/armor/Armor.cs b/src/items/armor/Armor.cs index 9ee8ec7d..19750dfd 100644 --- a/src/items/armor/Armor.cs +++ b/src/items/armor/Armor.cs @@ -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 { 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.Default.Equals(_ImportPath, other._ImportPath) && + EqualityComparer.Default.Equals(Name, other.Name) && + UniqueNameInOwner == other.UniqueNameInOwner && + SceneFilePath == other.SceneFilePath && + EqualityComparer.Default.Equals(Owner, other.Owner) && + EqualityComparer.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.Default.Equals(VisibilityParent, other.VisibilityParent) && + EqualityComparer.Default.Equals(GameRepo, other.GameRepo) && + EqualityComparer.Default.Equals(Info, other.Info) && + EqualityComparer.Default.Equals(ArmorInfo, other.ArmorInfo) && + EqualityComparer.Default.Equals(Sprite, other.Sprite) && + EqualityComparer.Default.Equals(Pickup, other.Pickup) && + EqualityComparer.Default.Equals(MixinState, other.MixinState) && + EqualityComparer.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(); + } } diff --git a/src/items/armor/ArmorInfo.cs b/src/items/armor/ArmorInfo.cs index e338d1e9..0196b0a3 100644 --- a/src/items/armor/ArmorInfo.cs +++ b/src/items/armor/ArmorInfo.cs @@ -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; } diff --git a/src/items/armor/resources/Acceptance.tres b/src/items/armor/resources/Acceptance.tres index c3f9424d..b9d345a6 100644 --- a/src/items/armor/resources/Acceptance.tres +++ b/src/items/armor/resources/Acceptance.tres @@ -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 diff --git a/src/items/armor/resources/AtonersAdornments.tres b/src/items/armor/resources/AtonersAdornments.tres index 6c418900..8a6951e2 100644 --- a/src/items/armor/resources/AtonersAdornments.tres +++ b/src/items/armor/resources/AtonersAdornments.tres @@ -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 diff --git a/src/items/armor/resources/CeremonialVestments.tres b/src/items/armor/resources/CeremonialVestments.tres index 7ede9345..11875b58 100644 --- a/src/items/armor/resources/CeremonialVestments.tres +++ b/src/items/armor/resources/CeremonialVestments.tres @@ -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 diff --git a/src/items/armor/resources/DevicLayer.tres b/src/items/armor/resources/DevicLayer.tres index 8b64490e..a7958214 100644 --- a/src/items/armor/resources/DevicLayer.tres +++ b/src/items/armor/resources/DevicLayer.tres @@ -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 diff --git a/src/items/armor/resources/GoddessRobe.tres b/src/items/armor/resources/GoddessRobe.tres index 6fe3ba5c..cbba76b0 100644 --- a/src/items/armor/resources/GoddessRobe.tres +++ b/src/items/armor/resources/GoddessRobe.tres @@ -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 diff --git a/src/items/armor/resources/IronCage.tres b/src/items/armor/resources/IronCage.tres index 306e5dfe..b49ead64 100644 --- a/src/items/armor/resources/IronCage.tres +++ b/src/items/armor/resources/IronCage.tres @@ -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 diff --git a/src/items/armor/resources/LogisticiansGarb.tres b/src/items/armor/resources/LogisticiansGarb.tres index 5a113589..ee0b89c8 100644 --- a/src/items/armor/resources/LogisticiansGarb.tres +++ b/src/items/armor/resources/LogisticiansGarb.tres @@ -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 diff --git a/src/items/armor/resources/Stoic.tres b/src/items/armor/resources/Stoic.tres index 31010df2..9ba75d20 100644 --- a/src/items/armor/resources/Stoic.tres +++ b/src/items/armor/resources/Stoic.tres @@ -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 diff --git a/src/items/armor/resources/WoodenArmament.tres b/src/items/armor/resources/WoodenArmament.tres index c9374440..7918313d 100644 --- a/src/items/armor/resources/WoodenArmament.tres +++ b/src/items/armor/resources/WoodenArmament.tres @@ -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 diff --git a/src/items/weapons/Weapon.cs b/src/items/weapons/Weapon.cs index 0ee56c7c..2913f44d 100644 --- a/src/items/weapons/Weapon.cs +++ b/src/items/weapons/Weapon.cs @@ -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 { - public Weapon() - { - WeaponInfo = new WeaponInfo() { Damage = 1, WeaponTags = new Godot.Collections.Array(), Texture = new Texture2D() }; - } - public override void _Notification(int what) => this.Notify(what); [Dependency] public IGameRepo GameRepo => this.DependOn(); @@ -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.Default.Equals(_ImportPath, other._ImportPath) && + EqualityComparer.Default.Equals(Name, other.Name) && + UniqueNameInOwner == other.UniqueNameInOwner && + SceneFilePath == other.SceneFilePath && + EqualityComparer.Default.Equals(Owner, other.Owner) && + EqualityComparer.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.Default.Equals(VisibilityParent, other.VisibilityParent) && + EqualityComparer.Default.Equals(GameRepo, other.GameRepo) && + EqualityComparer.Default.Equals(Info, other.Info) && + EqualityComparer.Default.Equals(WeaponInfo, other.WeaponInfo) && + EqualityComparer.Default.Equals(Sprite, other.Sprite) && + EqualityComparer.Default.Equals(Pickup, other.Pickup) && + EqualityComparer.Default.Equals(MixinState, other.MixinState) && + EqualityComparer.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(); + } } diff --git a/src/items/weapons/WeaponInfo.cs b/src/items/weapons/WeaponInfo.cs index 40a91a8e..5dff22ef 100644 --- a/src/items/weapons/WeaponInfo.cs +++ b/src/items/weapons/WeaponInfo.cs @@ -4,14 +4,8 @@ using Godot; [GlobalClass] public partial class WeaponInfo : InventoryItemInfo { - public WeaponInfo() - { - Damage = 1; - WeaponTags = new Godot.Collections.Array(); - } - [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 WeaponTags { get; set; } = new Godot.Collections.Array();