Redesign and reimplement inventory menu

Add jewels but no implementation yet (needed redesign of inventory menu to function correctly)
This commit is contained in:
2026-02-11 04:08:42 -08:00
parent 5451f0b31f
commit 8ce38c3c13
51 changed files with 1695 additions and 256 deletions

View File

@@ -1,8 +0,0 @@
namespace Zennysoft.Game.Abstractions;
public interface IStackable
{
int Count { get; }
void SetCount(int count);
}

View File

@@ -0,0 +1,10 @@
using Chickensoft.Collections;
namespace Zennysoft.Game.Implementation;
public interface IStackable
{
AutoProp<int> Count { get; }
void SetCount(int count);
}

View File

@@ -1,4 +1,5 @@
using Chickensoft.Introspection; using Chickensoft.Collections;
using Chickensoft.Introspection;
using Chickensoft.Serialization; using Chickensoft.Serialization;
using Zennysoft.Ma.Adapter.Entity; using Zennysoft.Ma.Adapter.Entity;
@@ -17,6 +18,10 @@ public abstract partial class EquipableItem : InventoryItem
public virtual int BonusVT { get; } public virtual int BonusVT { get; }
[Save("bonus_luck_stats")] [Save("bonus_luck_stats")]
public virtual int BonusLuck { get; } public virtual int BonusLuck { get; }
[Save("equipment_is_glued")]
public bool Glued { get; set; }
[Save("bonus_elemental_resist_stats")] [Save("bonus_elemental_resist_stats")]
public virtual ElementalResistanceSet ElementalResistance { get; } = new ElementalResistanceSet(0, 0, 0, 0, 0, 0, 0); public virtual ElementalResistanceSet ElementalResistance { get; } = new ElementalResistanceSet(0, 0, 0, 0, 0, 0, 0);
} }

View File

@@ -298,6 +298,7 @@ locale/translations_pot_files=PackedStringArray("res://src/dialog/Dialogue.dialo
3d/run_on_separate_thread=true 3d/run_on_separate_thread=true
common/physics_ticks_per_second=144 common/physics_ticks_per_second=144
jolt_physics_3d/simulation/areas_detect_static_bodies=true
[rendering] [rendering]

View File

@@ -106,6 +106,6 @@ public enum SoundEffect
SwapHPAndVT, SwapHPAndVT,
TurnAllEnemiesIntoHealingItems, TurnAllEnemiesIntoHealingItems,
WeaponQuickSlash, WeaponQuickSlash,
WeaponSlowSlash WeaponSlowSlash,
} }

View File

@@ -11,6 +11,7 @@ using Zennysoft.Game.Abstractions;
using Zennysoft.Ma.Adapter; using Zennysoft.Ma.Adapter;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using Zennysoft.Game.Implementation;
[Meta(typeof(IAutoNode))] [Meta(typeof(IAutoNode))]
public partial class Game : Node3D, IGame public partial class Game : Node3D, IGame
@@ -226,6 +227,9 @@ public partial class Game : Node3D, IGame
case ThrowableItem throwableItem: case ThrowableItem throwableItem:
EnactThrowableItemEffects(throwableItem); EnactThrowableItemEffects(throwableItem);
break; break;
case Jewel jewel:
EnactJewelItemEffects(jewel);
break;
} }
await ToSignal(GetTree().CreateTimer(0.3f), "timeout"); await ToSignal(GetTree().CreateTimer(0.3f), "timeout");
@@ -240,6 +244,7 @@ public partial class Game : Node3D, IGame
dropped.Item = item; dropped.Item = item;
_map.AddChild(dropped); _map.AddChild(dropped);
dropped.Drop(); dropped.Drop();
_player.Inventory.Remove(item);
} }
public void SetItem(InventoryItem item) public void SetItem(InventoryItem item)
@@ -248,6 +253,7 @@ public partial class Game : Node3D, IGame
var setItem = setScene.Instantiate<SetItem>(); var setItem = setScene.Instantiate<SetItem>();
_map.AddChild(setItem); _map.AddChild(setItem);
setItem.Set(); setItem.Set();
_player.Inventory.Remove(item);
} }
public void ThrowItem(InventoryItem item) public void ThrowItem(InventoryItem item)
@@ -257,6 +263,7 @@ public partial class Game : Node3D, IGame
thrown.ItemThatIsThrown = item; thrown.ItemThatIsThrown = item;
_map.AddChild(thrown); _map.AddChild(thrown);
thrown.Throw(_effectService); thrown.Throw(_effectService);
_player.Inventory.Remove(item);
} }
public IDungeonFloor CurrentFloor => _map.CurrentFloor; public IDungeonFloor CurrentFloor => _map.CurrentFloor;
@@ -560,9 +567,6 @@ public partial class Game : Node3D, IGame
_effectService.TeleportToRandomRoom(_player); _effectService.TeleportToRandomRoom(_player);
GameRepo.CloseInventory(); GameRepo.CloseInventory();
break; break;
case ThrowableItemTag.CanChangeAffinity:
_effectService.ChangeAffinity(throwableItem);
break;
case ThrowableItemTag.WarpToExitIfFound: case ThrowableItemTag.WarpToExitIfFound:
_effectService.WarpToExit(); _effectService.WarpToExit();
GameRepo.CloseInventory(); GameRepo.CloseInventory();
@@ -575,10 +579,17 @@ public partial class Game : Node3D, IGame
_player.VTComponent.Restore(throwableItem.HealVTAmount); _player.VTComponent.Restore(throwableItem.HealVTAmount);
} }
private void EnactJewelItemEffects(Jewel jewel)
{
switch (jewel.Stats.JewelTag)
{
//case JewelTags.AeolicElement
}
}
private void RemoveItemOrSubtractFromItemCount(InventoryItem item) private void RemoveItemOrSubtractFromItemCount(InventoryItem item)
{ {
if (item is IStackable stackableItem && stackableItem.Count > 1) if (item is IStackable stackableItem && stackableItem.Count.Value > 1)
stackableItem.SetCount(stackableItem.Count - 1); stackableItem.SetCount(stackableItem.Count.Value - 1);
else else
_player.Inventory.Remove(item); _player.Inventory.Remove(item);
} }

View File

@@ -213,20 +213,6 @@ public class EffectService
SfxDatabase.Instance.Play(SoundEffect.TeleportToRandomRoom); SfxDatabase.Instance.Play(SoundEffect.TeleportToRandomRoom);
} }
public void ChangeAffinity(ThrowableItem throwableItem)
{
var maximumElements = Enum.GetNames(typeof(ElementType)).Length;
var newElement = ((int)throwableItem.ElementType + 1) % maximumElements;
throwableItem.SetElementType((ElementType)newElement);
// TODO: Make this an inventory animation to cycle through elements.
throwableItem.SetDescription(
$"Inflicts {throwableItem.ElementType} damage when thrown." +
$"{System.Environment.NewLine}Use item to change Affinity.");
throwableItem.SetCount(throwableItem.Count + 1);
}
public void WarpToExit() public void WarpToExit()
{ {
var exitRoom = _game.CurrentFloor.Rooms.OfType<ExitRoom>().Single(); var exitRoom = _game.CurrentFloor.Rooms.OfType<ExitRoom>().Single();

View File

@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Zennysoft.Game.Abstractions; using Zennysoft.Game.Abstractions;
using Zennysoft.Game.Implementation;
using Zennysoft.Ma.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -96,9 +97,10 @@ public partial class Inventory : Node, IInventory
foreach (var itemStack in itemsToStack) foreach (var itemStack in itemsToStack)
{ {
var firstItem = itemStack.First(); var firstItem = itemStack.First();
firstItem.SetCount(itemStack.Count()); firstItem.SetCount(itemStack.Sum(x => x.Count.Value));
var itemsToRemove = itemStack.Except([firstItem]).Cast<InventoryItem>(); var itemsToRemove = itemStack.Except([firstItem]).Cast<InventoryItem>();
Items = [.. Items.Except(itemsToRemove)]; foreach (var item in itemsToRemove)
Remove(item);
} }
return !Items.SequenceEqual(initialList); return !Items.SequenceEqual(initialList);

View File

@@ -49,9 +49,6 @@ public class ItemDatabase
var weights = itemsToSelectFrom.Select(x => x.SpawnRate).ToArray(); var weights = itemsToSelectFrom.Select(x => x.SpawnRate).ToArray();
var selectedItem = itemsToSelectFrom.ToArray()[rng.RandWeighted(weights)]; var selectedItem = itemsToSelectFrom.ToArray()[rng.RandWeighted(weights)];
if (selectedItem is ThrowableItem throwableItem)
throwableItem.SetCount(rng.RandiRange(throwableItem.Stats.MinimumCount, throwableItem.Stats.MaximumCount));
return selectedItem; return selectedItem;
} }
@@ -140,14 +137,14 @@ public class ItemDatabase
database.Add(ammoItemScene); database.Add(ammoItemScene);
} }
//foreach (var jewelItem in jewelResources) foreach (var jewelItem in jewelResources)
//{ {
// var jewelItemInfo = GD.Load<JewelStats>($"res://src/items/jewel/resources/{jewelItem}".TrimSuffix(".remap")); var jewelItemInfo = GD.Load<JewelStats>($"res://src/items/jewels/resources/{jewelItem}".TrimSuffix(".remap"));
// var jewelItemScene = ResourceLoader.Load<PackedScene>("res://src/items/jewel/Jewel.tscn").Instantiate<Jewels>(); var jewelItemScene = ResourceLoader.Load<PackedScene>("res://src/items/jewels/Jewel.tscn").Instantiate<Jewel>();
// jewelItemScene.Stats = jewelItemInfo; jewelItemScene.Stats = jewelItemInfo;
// if (!database.Contains(jewelItemScene)) if (!database.Contains(jewelItemScene))
// database.Add(jewelItemScene); database.Add(jewelItemScene);
//} }
Items = [.. database]; Items = [.. database];
} }

View File

@@ -1,8 +1,9 @@
using Chickensoft.AutoInject; using Chickensoft.AutoInject;
using Chickensoft.Collections;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization; using Chickensoft.Serialization;
using Godot; using Godot;
using Zennysoft.Game.Abstractions; using Zennysoft.Game.Implementation;
using Zennysoft.Game.Ma; using Zennysoft.Game.Ma;
using Zennysoft.Ma.Adapter; using Zennysoft.Ma.Adapter;
@@ -11,13 +12,11 @@ public partial class Ammo : EquipableItem, IStackable
{ {
public override void _Notification(int what) => this.Notify(what); public override void _Notification(int what) => this.Notify(what);
private int _count;
[Node] private Sprite3D _sprite { get; set; } [Node] private Sprite3D _sprite { get; set; }
public void OnReady() public void OnReady()
{ {
_count = Stats.InitialCount; Count = new AutoProp<int>(Stats.InitialCount);
_sprite.Texture = Stats.Texture; _sprite.Texture = Stats.Texture;
} }
@@ -37,8 +36,9 @@ public partial class Ammo : EquipableItem, IStackable
public override Texture2D GetTexture() => Stats.Texture; public override Texture2D GetTexture() => Stats.Texture;
[Save("ammo_item_count")] [Save("ammo_item_count")]
public int Count { get => _count; } public AutoProp<int> Count { get; private set; }
public void SetCount(int count) => _count = count;
public void SetCount(int count) => Count.OnNext(count);
[Save("ammo_element")] [Save("ammo_element")]
public ElementType AmmoElement => Stats.AmmoElement; public ElementType AmmoElement => Stats.AmmoElement;

View File

@@ -0,0 +1,37 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Chickensoft.Serialization;
using Godot;
using Zennysoft.Game.Ma;
using Zennysoft.Ma.Adapter;
[Meta(typeof(IAutoNode)), Id("jewel")]
public partial class Jewel : InventoryItem
{
public override void _Notification(int what) => this.Notify(what);
[Node] private Sprite3D _sprite { get; set; }
public void OnReady()
{
_sprite.Texture = Stats.Texture;
}
public override string ItemName => Stats.Name;
public override string Description => Stats.Description;
public override float SpawnRate => Stats.SpawnRate;
public override int ThrowDamage => Stats.ThrowDamage;
public override float ThrowSpeed => Stats.ThrowSpeed;
public override ItemTag ItemTag => Stats.ItemTag;
public override Texture2D GetTexture() => Stats.Texture;
[Export]
[Save("jewel_stats")]
public JewelStats Stats { get; set; } = new JewelStats();
}

View File

@@ -0,0 +1,38 @@
[gd_scene load_steps=4 format=3 uid="uid://dqlbkyxqhyqtl"]
[ext_resource type="Script" uid="uid://bou7fk1evvet" path="res://src/items/jewels/Jewel.cs" id="1_sedqc"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_40de3"]
[sub_resource type="BoxShape3D" id="BoxShape3D_qdeu2"]
size = Vector3(0.898941, 2.34974, 0.86676)
[node name="Jewel" type="RigidBody3D"]
collision_layer = 0
axis_lock_linear_x = true
axis_lock_linear_z = true
axis_lock_angular_x = true
axis_lock_angular_y = true
axis_lock_angular_z = true
script = ExtResource("1_sedqc")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.720724, 0)
shape = SubResource("CapsuleShape3D_40de3")
[node name="Pickup" type="Area3D" parent="."]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.49274, 0)
collision_layer = 4
collision_mask = 0
[node name="Sprite" type="Sprite3D" parent="Pickup"]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.370004, 0)
pixel_size = 0.025
billboard = 2
texture_filter = 0
[node name="CollisionShape3D" type="CollisionShape3D" parent="Pickup"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00804907, 0.709896, 0.0675965)
shape = SubResource("BoxShape3D_qdeu2")

View File

@@ -1,4 +1,5 @@
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization;
using Godot; using Godot;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -7,4 +8,7 @@ namespace Zennysoft.Game.Ma;
[Meta, Id("jewel_stat_type")] [Meta, Id("jewel_stat_type")]
public partial class JewelStats : InventoryItemStats public partial class JewelStats : InventoryItemStats
{ {
[Save("jewel_tag")]
[Export]
public JewelTags JewelTag { get; set; }
} }

View File

@@ -0,0 +1,19 @@
public enum JewelTags
{
None,
AeolicElement,
IncreaseHPRecovery,
HastenVT,
LowerEXPGain,
Glue,
ItemRescue,
HydricElement,
IgneousElement,
IncreaseEXPGain,
LowerHPRecovery,
SlowVTReduction,
AutoIdentifyAllItems,
ReviveUserOnce,
TelluricElement
}

View File

@@ -0,0 +1 @@
uid://hm03eov1reaj

View File

@@ -1,18 +0,0 @@
using Godot;
using System;
using Zennysoft.Game.Ma;
using Zennysoft.Ma.Adapter;
public partial class Jewels : InventoryItem
{
public override string ItemName { get; }
public override string Description { get; }
public override float SpawnRate { get; }
public override int ThrowDamage { get; }
public override float ThrowSpeed { get; }
public override ItemTag ItemTag { get; }
public override Texture2D GetTexture() => throw new NotImplementedException();
public JewelStats Stats { get; set; } = new JewelStats();
}

View File

@@ -0,0 +1,28 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://bxen2ertkxmwo"]
[ext_resource type="Texture2D" uid="uid://c47igpgj02war" path="res://src/items/jewels/texture/Aeollic Jewel.png" id="1_p3ar8"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_u0a3e"]
[resource]
script = ExtResource("1_u0a3e")
JewelTag = 1
Name = "Aeolic Jewel"
Description = "Add Aeolic damage to Weapon or Aeolic resistance to Armor."
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_p3ar8")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,28 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://b8f23e2kay1cr"]
[ext_resource type="Texture2D" uid="uid://cdq12s3k2oemt" path="res://src/items/jewels/texture/Anabolic.png" id="1_6jhk1"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_6xlbl"]
[resource]
script = ExtResource("1_6xlbl")
JewelTag = 2
Name = "Anabolic Jewel"
Description = "Increase HP regen speed."
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_6jhk1")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://ciejgco24n0qo"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_dxj8h"]
[ext_resource type="Texture2D" uid="uid://bjpp5hp78g2w6" path="res://src/items/jewels/texture/Black Egg.png" id="1_rbr4o"]
[resource]
script = ExtResource("1_dxj8h")
Name = "Black Egg"
Description = "Increase Attack, Defense, and Luck."
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_rbr4o")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://d8186oeld7up"]
[ext_resource type="Texture2D" uid="uid://bnno0bwaxvvq4" path="res://src/items/jewels/texture/Cats Eye.png" id="1_a82hi"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_vvfsu"]
[resource]
script = ExtResource("1_vvfsu")
Name = "Cat's Eye"
Description = "Dramatically increases Luck."
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_a82hi")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://bfmujwmg1iehy"]
[ext_resource type="Texture2D" uid="uid://b2tnug7fnsqor" path="res://src/items/jewels/texture/Cinnabar Structure.png" id="1_fc5tr"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_k60ln"]
[resource]
script = ExtResource("1_k60ln")
Name = "Cinnabar Structure"
Description = "Hastens VT, adds or improves Rust."
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_fc5tr")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://cdygc6sdh0oki"]
[ext_resource type="Texture2D" uid="uid://dqqyx7usmyo1k" path="res://src/items/jewels/texture/Foolish Orb.png" id="1_ltr3k"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_pn071"]
[resource]
script = ExtResource("1_pn071")
Name = "Foolish Orb"
Description = "Lowers EXP gain."
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_ltr3k")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://b00agx6qy6yhv"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_c23yr"]
[ext_resource type="Texture2D" uid="uid://d3vv6ea17uifk" path="res://src/items/jewels/texture/Glue Orb.png" id="1_sww4k"]
[resource]
script = ExtResource("1_c23yr")
Name = "Glue Orb"
Description = "Prevents item from being unequipped."
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_sww4k")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://bxq5xnxfhatpi"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_7gwjj"]
[ext_resource type="Texture2D" uid="uid://4247dwj5g705" path="res://src/items/jewels/texture/Heirloom Stone.png" id="1_gk4x7"]
[resource]
script = ExtResource("1_7gwjj")
Name = "Heirloom Stone"
Description = "Returns item to the surface world."
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_gk4x7")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://c65jk6stksnai"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_cyti8"]
[ext_resource type="Texture2D" uid="uid://brx581xmqv54k" path="res://src/items/jewels/texture/Hydric Jewel.png" id="1_fdjqp"]
[resource]
script = ExtResource("1_cyti8")
Name = "Hydric Jewel"
Description = "Hydric e"
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_fdjqp")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://duk8un4sdv0cs"]
[ext_resource type="Texture2D" uid="uid://d3bx1j5irhdes" path="res://src/items/jewels/texture/Igneous Jewel.png" id="1_knm0p"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_qh03l"]
[resource]
script = ExtResource("1_qh03l")
Name = "Igneous Jewel"
Description = ""
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_knm0p")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://d2rdaghcccw0f"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_6e2y5"]
[ext_resource type="Texture2D" uid="uid://drfx1s7mc3j0h" path="res://src/items/jewels/texture/Meditative Stone.png" id="1_cyim2"]
[resource]
script = ExtResource("1_6e2y5")
Name = "Meditative Stone"
Description = ""
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_cyim2")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://djim1rdpt03ai"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_ivvck"]
[ext_resource type="Texture2D" uid="uid://rl6df2udk2ui" path="res://src/items/jewels/texture/Mercury.png" id="1_rw1fk"]
[resource]
script = ExtResource("1_ivvck")
Name = "Mercury Prism"
Description = ""
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_rw1fk")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://dd5stvt4g531e"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_cabnq"]
[ext_resource type="Texture2D" uid="uid://vxeil6eo3hdp" path="res://src/items/jewels/texture/Metabolic Jewel.png" id="1_pscn1"]
[resource]
script = ExtResource("1_cabnq")
Name = "Metabolic Jewel"
Description = ""
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_pscn1")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://bdd7xh6v03xul"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_75k4l"]
[ext_resource type="Texture2D" uid="uid://bxa1kqlqhbyi3" path="res://src/items/jewels/texture/Ossified Cortex.png" id="1_cq6jp"]
[resource]
script = ExtResource("1_75k4l")
Name = "Ossified Cortex"
Description = ""
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_cq6jp")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://byufike6hontv"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_fkhpb"]
[ext_resource type="Texture2D" uid="uid://c6fu3kd5yelwi" path="res://src/items/jewels/texture/Rejection Stone.png" id="1_rh6wh"]
[resource]
script = ExtResource("1_fkhpb")
Name = "Rejection Stone"
Description = ""
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_rh6wh")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://blghjvef7p6fm"]
[ext_resource type="Texture2D" uid="uid://cgs0hr24h5g6q" path="res://src/items/jewels/texture/Tarnished Jewel.png" id="1_6qtep"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="1_868vv"]
[resource]
script = ExtResource("1_868vv")
Name = "Tarnished Jewel"
Description = ""
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_6qtep")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -0,0 +1,27 @@
[gd_resource type="Resource" script_class="JewelStats" load_steps=3 format=3 uid="uid://d3fipjd8sayiw"]
[ext_resource type="Texture2D" uid="uid://r36ecoqigs2o" path="res://src/items/jewels/texture/Telleric Jewel.png" id="1_yooxp"]
[ext_resource type="Script" uid="uid://btikba31yb0tl" path="res://src/items/jewels/JewelStats.cs" id="2_c8kww"]
[resource]
script = ExtResource("2_c8kww")
Name = "Telluric Jewel"
Description = "Add Telluric damage to Weapon or Telluric resistance to Armor."
SpawnRate = 0.5
BonusAttack = 0
BonusDefense = 0
BonusLuck = 5
BonusHP = 0
BonusVT = 0
AeolicResistance = 0
TelluricResistance = 0
HydricResistance = 0
IgneousResistance = 0
FerrumResistance = 0
HolyResistance = 0
CurseResistance = 0
ThrowSpeed = 12.0
ThrowDamage = 5
ItemTag = 0
Texture = ExtResource("1_yooxp")
metadata/_custom_type_script = "uid://btikba31yb0tl"

View File

@@ -1,8 +1,9 @@
using Chickensoft.AutoInject; using Chickensoft.AutoInject;
using Chickensoft.Collections;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.Serialization; using Chickensoft.Serialization;
using Godot; using Godot;
using Zennysoft.Game.Abstractions; using Zennysoft.Game.Implementation;
using Zennysoft.Ma.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -17,6 +18,9 @@ public partial class ThrowableItem : InventoryItem, IStackable
public override void _Ready() public override void _Ready()
{ {
_sprite.Texture = Stats.Texture; _sprite.Texture = Stats.Texture;
var rng = new RandomNumberGenerator();
rng.Randomize();
Count = new AutoProp<int>(rng.RandiRange(Stats.MinimumCount, Stats.MaximumCount));
} }
public override string ItemName => Stats.Name; public override string ItemName => Stats.Name;
@@ -45,7 +49,7 @@ public partial class ThrowableItem : InventoryItem, IStackable
public void SetDescription(string description) => Stats.Description = description; public void SetDescription(string description) => Stats.Description = description;
[Save("throwable_item_count")] [Save("throwable_item_count")]
public int Count { get; private set; } = 1; public AutoProp<int> Count { get; private set; }
[Export] [Export]
[Save("throwable_item_stats")] [Save("throwable_item_stats")]
@@ -53,5 +57,5 @@ public partial class ThrowableItem : InventoryItem, IStackable
public override Texture2D GetTexture() => Stats.Texture; public override Texture2D GetTexture() => Stats.Texture;
public void SetCount(int count) => Count = count; public void SetCount(int count) => Count.OnNext(count);
} }

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=63 format=3 uid="uid://nnns2ade62al"] [gd_scene load_steps=64 format=3 uid="uid://nnns2ade62al"]
[ext_resource type="Script" uid="uid://cqm6u7qa8japr" path="res://src/system/Projectile.cs" id="1_xt24t"] [ext_resource type="Script" uid="uid://cqm6u7qa8japr" path="res://src/system/Projectile.cs" id="1_xt24t"]
[ext_resource type="Script" uid="uid://ctshiyffvt4y5" path="res://src/system/AttackDataResource.cs" id="2_yf47k"] [ext_resource type="Script" uid="uid://ctshiyffvt4y5" path="res://src/system/AttackDataResource.cs" id="2_yf47k"]
@@ -516,6 +516,8 @@ _data = {
&"RESET": SubResource("Animation_8qeb2") &"RESET": SubResource("Animation_8qeb2")
} }
[sub_resource type="SphereShape3D" id="SphereShape3D_xt24t"]
[node name="AirReactor" type="Node3D"] [node name="AirReactor" type="Node3D"]
script = ExtResource("1_xt24t") script = ExtResource("1_xt24t")
AttackData = SubResource("Resource_kcnxw") AttackData = SubResource("Resource_kcnxw")
@@ -550,3 +552,9 @@ root_node = NodePath("../AnimatedSprite3D")
libraries = { libraries = {
&"": SubResource("AnimationLibrary_q8n6h") &"": SubResource("AnimationLibrary_q8n6h")
} }
[node name="WallCollision" type="RigidBody3D" parent="Bullet"]
unique_name_in_owner = true
[node name="CollisionShape3D" type="CollisionShape3D" parent="Bullet/WallCollision"]
shape = SubResource("SphereShape3D_xt24t")

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=67 format=3 uid="uid://igpvnbi8qi6e"] [gd_scene load_steps=68 format=3 uid="uid://igpvnbi8qi6e"]
[ext_resource type="Script" uid="uid://cqm6u7qa8japr" path="res://src/system/Projectile.cs" id="1_pk6yq"] [ext_resource type="Script" uid="uid://cqm6u7qa8japr" path="res://src/system/Projectile.cs" id="1_pk6yq"]
[ext_resource type="Script" uid="uid://ctshiyffvt4y5" path="res://src/system/AttackDataResource.cs" id="2_d874y"] [ext_resource type="Script" uid="uid://ctshiyffvt4y5" path="res://src/system/AttackDataResource.cs" id="2_d874y"]
@@ -547,6 +547,8 @@ _data = {
&"RESET": SubResource("Animation_8qeb2") &"RESET": SubResource("Animation_8qeb2")
} }
[sub_resource type="SphereShape3D" id="SphereShape3D_pk6yq"]
[node name="FireReactor" type="Node3D"] [node name="FireReactor" type="Node3D"]
script = ExtResource("1_pk6yq") script = ExtResource("1_pk6yq")
AttackData = SubResource("Resource_14f5p") AttackData = SubResource("Resource_14f5p")
@@ -581,3 +583,9 @@ root_node = NodePath("../AnimatedSprite3D")
libraries = { libraries = {
&"": SubResource("AnimationLibrary_q8n6h") &"": SubResource("AnimationLibrary_q8n6h")
} }
[node name="WallCollision" type="RigidBody3D" parent="Bullet"]
unique_name_in_owner = true
[node name="CollisionShape3D" type="CollisionShape3D" parent="Bullet/WallCollision"]
shape = SubResource("SphereShape3D_pk6yq")

View File

@@ -1,8 +1,9 @@
[gd_scene load_steps=72 format=3 uid="uid://d3nx0suvhbcda"] [gd_scene load_steps=73 format=3 uid="uid://d3nx0suvhbcda"]
[ext_resource type="Script" uid="uid://cqm6u7qa8japr" path="res://src/system/Projectile.cs" id="1_7ykt2"] [ext_resource type="Script" uid="uid://cqm6u7qa8japr" path="res://src/system/Projectile.cs" id="1_7ykt2"]
[ext_resource type="Script" uid="uid://ctshiyffvt4y5" path="res://src/system/AttackDataResource.cs" id="2_3v8me"] [ext_resource type="Script" uid="uid://ctshiyffvt4y5" path="res://src/system/AttackDataResource.cs" id="2_3v8me"]
[ext_resource type="Texture2D" uid="uid://c1x4iaqgj2rur" path="res://src/vfx/Items Etc/smokepuff.png" id="3_7ykt2"] [ext_resource type="Texture2D" uid="uid://c1x4iaqgj2rur" path="res://src/vfx/Items Etc/smokepuff.png" id="3_7ykt2"]
[ext_resource type="AudioStream" uid="uid://bgvt4kqyvl5gp" path="res://src/audio/sfx/ENEMY_EDEN_FIRE.ogg" id="4_3v8me"]
[sub_resource type="Resource" id="Resource_14f5p"] [sub_resource type="Resource" id="Resource_14f5p"]
script = ExtResource("2_3v8me") script = ExtResource("2_3v8me")
@@ -456,8 +457,7 @@ animations = [{
[sub_resource type="Animation" id="Animation_xrn7e"] [sub_resource type="Animation" id="Animation_xrn7e"]
resource_name = "fire" resource_name = "fire"
length = 1.11667 length = 0.66667
step = 0.0166667
tracks/0/type = "value" tracks/0/type = "value"
tracks/0/imported = false tracks/0/imported = false
tracks/0/enabled = true tracks/0/enabled = true
@@ -477,10 +477,10 @@ tracks/1/path = NodePath(".:frame")
tracks/1/interp = 1 tracks/1/interp = 1
tracks/1/loop_wrap = true tracks/1/loop_wrap = true
tracks/1/keys = { tracks/1/keys = {
"times": PackedFloat32Array(0, 0.416667), "times": PackedFloat32Array(0.2, 0.666667),
"transitions": PackedFloat32Array(1, 1), "transitions": PackedFloat32Array(1, 1),
"update": 0, "update": 0,
"values": [1, 67] "values": [0, 67]
} }
tracks/2/type = "value" tracks/2/type = "value"
tracks/2/imported = false tracks/2/imported = false
@@ -489,7 +489,7 @@ tracks/2/path = NodePath("%ProjectileHitbox:position")
tracks/2/interp = 1 tracks/2/interp = 1
tracks/2/loop_wrap = true tracks/2/loop_wrap = true
tracks/2/keys = { tracks/2/keys = {
"times": PackedFloat32Array(0, 1.1), "times": PackedFloat32Array(0, 0.666667),
"transitions": PackedFloat32Array(1, 1), "transitions": PackedFloat32Array(1, 1),
"update": 0, "update": 0,
"values": [Vector3(0, 2.1, 0), Vector3(0, 2.1, -40)] "values": [Vector3(0, 2.1, 0), Vector3(0, 2.1, -40)]
@@ -501,11 +501,35 @@ tracks/3/path = NodePath("%ProjectileHitbox/CollisionShape3D:disabled")
tracks/3/interp = 1 tracks/3/interp = 1
tracks/3/loop_wrap = true tracks/3/loop_wrap = true
tracks/3/keys = { tracks/3/keys = {
"times": PackedFloat32Array(0, 0.0166667, 1.11667), "times": PackedFloat32Array(0, 0.0166667, 0.666667),
"transitions": PackedFloat32Array(1, 1, 1), "transitions": PackedFloat32Array(1, 1, 1),
"update": 1, "update": 1,
"values": [true, false, true] "values": [true, false, true]
} }
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("../Bullet/ProjectileHitbox/AudioStreamPlayer3D:stream")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("4_3v8me")]
}
tracks/5/type = "value"
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/path = NodePath("../Bullet/ProjectileHitbox/AudioStreamPlayer3D:playing")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/keys = {
"times": PackedFloat32Array(0.0333333),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
[sub_resource type="Animation" id="Animation_8qeb2"] [sub_resource type="Animation" id="Animation_8qeb2"]
length = 0.001 length = 0.001
@@ -557,6 +581,18 @@ tracks/3/keys = {
"update": 1, "update": 1,
"values": [true] "values": [true]
} }
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("%AudioStreamPlayer3D:playing")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_q8n6h"] [sub_resource type="AnimationLibrary" id="AnimationLibrary_q8n6h"]
_data = { _data = {
@@ -578,16 +614,16 @@ sprite_frames = SubResource("SpriteFrames_pck2g")
[node name="ProjectileHitbox" type="Area3D" parent="Bullet"] [node name="ProjectileHitbox" type="Area3D" parent="Bullet"]
unique_name_in_owner = true unique_name_in_owner = true
collision_layer = 0 collision_mask = 2049
collision_mask = 2048
monitorable = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="Bullet/ProjectileHitbox"] [node name="CollisionShape3D" type="CollisionShape3D" parent="Bullet/ProjectileHitbox"]
shape = SubResource("SphereShape3D_kct8n") shape = SubResource("SphereShape3D_kct8n")
disabled = true disabled = true
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="Bullet"] [node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="Bullet/ProjectileHitbox"]
unique_name_in_owner = true unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.1, 5.8557)
stream = ExtResource("4_3v8me")
[node name="AnimationPlayer" type="AnimationPlayer" parent="Bullet"] [node name="AnimationPlayer" type="AnimationPlayer" parent="Bullet"]
unique_name_in_owner = true unique_name_in_owner = true

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=78 format=3 uid="uid://7p2sh52lj42o"] [gd_scene load_steps=79 format=3 uid="uid://7p2sh52lj42o"]
[ext_resource type="Script" uid="uid://cqm6u7qa8japr" path="res://src/system/Projectile.cs" id="1_n88a7"] [ext_resource type="Script" uid="uid://cqm6u7qa8japr" path="res://src/system/Projectile.cs" id="1_n88a7"]
[ext_resource type="Script" uid="uid://ctshiyffvt4y5" path="res://src/system/AttackDataResource.cs" id="2_er0le"] [ext_resource type="Script" uid="uid://ctshiyffvt4y5" path="res://src/system/AttackDataResource.cs" id="2_er0le"]
@@ -621,6 +621,8 @@ _data = {
&"RESET": SubResource("Animation_8qeb2") &"RESET": SubResource("Animation_8qeb2")
} }
[sub_resource type="SphereShape3D" id="SphereShape3D_n88a7"]
[node name="WaterReactor" type="Node3D"] [node name="WaterReactor" type="Node3D"]
script = ExtResource("1_n88a7") script = ExtResource("1_n88a7")
AttackData = SubResource("Resource_k6pkx") AttackData = SubResource("Resource_k6pkx")
@@ -655,3 +657,9 @@ root_node = NodePath("../AnimatedSprite3D")
libraries = { libraries = {
&"": SubResource("AnimationLibrary_q8n6h") &"": SubResource("AnimationLibrary_q8n6h")
} }
[node name="WallCollision" type="RigidBody3D" parent="Bullet"]
unique_name_in_owner = true
[node name="CollisionShape3D" type="CollisionShape3D" parent="Bullet/WallCollision"]
shape = SubResource("SphereShape3D_n88a7")

View File

@@ -282,6 +282,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
VTComponent.RaiseMaximumVT(equipable.BonusVT, false); VTComponent.RaiseMaximumVT(equipable.BonusVT, false);
EquipmentComponent.Equip(equipable); EquipmentComponent.Equip(equipable);
SfxDatabase.Instance.Play(SoundEffect.Equip);
if (equipable is Weapon weapon && weapon.WeaponTag == WeaponTag.KineticProjectile) if (equipable is Weapon weapon && weapon.WeaponTag == WeaponTag.KineticProjectile)
PersuaderCrosshair.Show(); PersuaderCrosshair.Show();
@@ -293,6 +294,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
VTComponent.SetMaximumVT(VTComponent.MaximumVT.Value - equipable.BonusVT); VTComponent.SetMaximumVT(VTComponent.MaximumVT.Value - equipable.BonusVT);
EquipmentComponent.Unequip(equipable); EquipmentComponent.Unequip(equipable);
SfxDatabase.Instance.Play(SoundEffect.Unequip);
if (equipable is Weapon weapon && weapon.WeaponTag == WeaponTag.KineticProjectile) if (equipable is Weapon weapon && weapon.WeaponTag == WeaponTag.KineticProjectile)
PersuaderCrosshair.Hide(); PersuaderCrosshair.Hide();
@@ -354,30 +356,30 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
private void HandleProjectile(Weapon weapon) private void HandleProjectile(Weapon weapon)
{ {
var ammo = EquipmentComponent.EquippedAmmo.Value as Ammo; var ammo = EquipmentComponent.EquippedAmmo.Value as Ammo;
if (ammo == null || ammo.Count <= 0) if (ammo.Count == null || ammo.Count?.Value <= 0)
return; return;
var fired = false;
if (weapon.WeaponTag == WeaponTag.ElementalProjectile) if (weapon.WeaponTag == WeaponTag.ElementalProjectile)
{ {
var fired = false;
if (ammo.AmmoElement == ElementType.Igneous) if (ammo.AmmoElement == ElementType.Igneous)
fired = FireReactor.Fire(); fired = FireReactor.Fire();
if (ammo.AmmoElement == ElementType.Aeolic) if (ammo.AmmoElement == ElementType.Aeolic)
fired = AirReactor.Fire(); fired = AirReactor.Fire();
if (ammo.AmmoElement == ElementType.Hydric) if (ammo.AmmoElement == ElementType.Hydric)
fired = WaterReactor.Fire(); fired = WaterReactor.Fire();
}
if (weapon.WeaponTag == WeaponTag.KineticProjectile)
fired = PersuaderBullet.Fire();
if (!fired) if (!fired)
return; return;
}
else if (weapon.WeaponTag == WeaponTag.KineticProjectile)
{
var fired = false;
fired = PersuaderBullet.Fire();
}
ammo.SetCount(ammo.Count - 1); ammo.SetCount(ammo.Count.Value - 1);
if (ammo.Count <= 0) EquipmentComponent.UpdateEquipment(ammo);
if (ammo.Count.Value <= 0)
{ {
EquipmentComponent.Unequip(ammo); EquipmentComponent.Unequip(ammo);
Inventory.Remove(ammo); Inventory.Remove(ammo);

View File

@@ -1,6 +1,7 @@
using Chickensoft.AutoInject; using Chickensoft.AutoInject;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Godot; using Godot;
using System;
using Zennysoft.Game.Ma; using Zennysoft.Game.Ma;
using Zennysoft.Ma.Adapter; using Zennysoft.Ma.Adapter;
using Zennysoft.Ma.Adapter.Entity; using Zennysoft.Ma.Adapter.Entity;
@@ -23,13 +24,13 @@ public partial class Projectile : Node3D
public void OnReady() public void OnReady()
{ {
ProjectileHitbox.AreaEntered += Hitbox_AreaEntered; ProjectileHitbox.AreaEntered += Hitbox_AreaEntered;
ProjectileHitbox.BodyEntered += ProjectileHitbox_BodyEntered; ProjectileHitbox.BodyEntered += ProjectileHitbox_BodyEntered1;
ProjectileHitbox.BodyShapeEntered += ProjectileHitbox_BodyEntered;
} }
private void ProjectileHitbox_BodyEntered(Node3D body) private void ProjectileHitbox_BodyEntered1(Node3D body) => AnimationPlayer.Stop();
{
AnimationPlayer.Play("RESET"); private void ProjectileHitbox_BodyEntered(Rid bodyRid, Node3D body, long bodyShapeIndex, long localShapeIndex) => AnimationPlayer.Stop();
}
public bool Fire() public bool Fire()
{ {

View File

@@ -2,13 +2,13 @@
[ext_resource type="Script" uid="uid://dlq2mkhl4pe7a" path="res://src/ui/in_game_ui/InGameUI.cs" id="1_sc13i"] [ext_resource type="Script" uid="uid://dlq2mkhl4pe7a" path="res://src/ui/in_game_ui/InGameUI.cs" id="1_sc13i"]
[ext_resource type="PackedScene" uid="uid://bwbofurcvf3yh" path="res://src/minimap/Minimap.tscn" id="2_6sfje"] [ext_resource type="PackedScene" uid="uid://bwbofurcvf3yh" path="res://src/minimap/Minimap.tscn" id="2_6sfje"]
[ext_resource type="PackedScene" uid="uid://dlj8qdg1c5048" path="res://src/ui/inventory_menu/InventoryMenu.tscn" id="3_4vcdl"]
[ext_resource type="PackedScene" uid="uid://dxl8il8f13c2x" path="res://src/ui/player_ui/PlayerInfoUI.tscn" id="4_46s5l"] [ext_resource type="PackedScene" uid="uid://dxl8il8f13c2x" path="res://src/ui/player_ui/PlayerInfoUI.tscn" id="4_46s5l"]
[ext_resource type="PackedScene" uid="uid://bea2waybmgd6u" path="res://src/ui/teleport_prompt/UseTeleportPrompt.tscn" id="5_h1hgq"] [ext_resource type="PackedScene" uid="uid://bea2waybmgd6u" path="res://src/ui/teleport_prompt/UseTeleportPrompt.tscn" id="5_h1hgq"]
[ext_resource type="PackedScene" uid="uid://x0f1ol50nnp3" path="res://src/ui/in_game_ui/InventoryMessageUI.tscn" id="6_y26qy"] [ext_resource type="PackedScene" uid="uid://x0f1ol50nnp3" path="res://src/ui/in_game_ui/InventoryMessageUI.tscn" id="6_y26qy"]
[ext_resource type="Script" uid="uid://dj6oqler47dqf" path="res://src/utils/FpsCounter.cs" id="7_c6o8j"] [ext_resource type="Script" uid="uid://3fpuxsgdl8xe" path="res://src/utils/FpsCounter.cs" id="7_c6o8j"]
[ext_resource type="PackedScene" uid="uid://8f3dk16nj0dn" path="res://src/menu/DebugMenu.tscn" id="7_llomk"] [ext_resource type="PackedScene" uid="uid://8f3dk16nj0dn" path="res://src/menu/DebugMenu.tscn" id="7_llomk"]
[ext_resource type="Texture2D" uid="uid://bj4p4qxb1mj3q" path="res://src/ui/player_ui/Assets/panel rough draft.png" id="7_ur8ag"] [ext_resource type="Texture2D" uid="uid://bj4p4qxb1mj3q" path="res://src/ui/player_ui/Assets/panel rough draft.png" id="7_ur8ag"]
[ext_resource type="PackedScene" uid="uid://c3e6hbctay1us" path="res://src/ui/inventory_menu/InventoryMenu2.tscn" id="9_ur8ag"]
[sub_resource type="StyleBoxLine" id="StyleBoxLine_ur8ag"] [sub_resource type="StyleBoxLine" id="StyleBoxLine_ur8ag"]
color = Color(0.792157, 0.698039, 0.643137, 1) color = Color(0.792157, 0.698039, 0.643137, 1)
@@ -144,7 +144,6 @@ offset_right = 267.0
offset_bottom = 1004.0 offset_bottom = 1004.0
size_flags_vertical = 3 size_flags_vertical = 3
[node name="InventoryMenu" parent="." instance=ExtResource("3_4vcdl")] [node name="InventoryMenu" parent="." instance=ExtResource("9_ur8ag")]
unique_name_in_owner = true unique_name_in_owner = true
process_mode = 3
layout_mode = 1 layout_mode = 1

View File

@@ -9,11 +9,9 @@ public interface IItemSlot : IButton
{ {
public AutoProp<InventoryItem> Item { get; } public AutoProp<InventoryItem> Item { get; }
public bool IsSelected { get; set; } public void SetItemEquipmentStatus(bool isEquipped);
public void SetItemStyle(); public event Action<IItemSlot> ItemPressed;
public event Action<InventoryItem> ItemPressed; public event Action<IItemSlot> ItemSelected;
public event Action<IItemSlot> ItemEnterFocus;
public event Action<IItemSlot> ItemExitFocus;
} }

View File

@@ -67,8 +67,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
foreach (var item in ItemSlots) foreach (var item in ItemSlots)
{ {
item.ItemPressed += Item_Pressed; item.ItemPressed += Item_Pressed;
item.ItemEnterFocus += Item_FocusEntered;
item.ItemExitFocus += Item_ItemExitFocus;
} }
_player.AttackComponent.CurrentAttack.Sync += Attack_Sync; _player.AttackComponent.CurrentAttack.Sync += Attack_Sync;
@@ -122,8 +120,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
SfxDatabase.Instance.Play(SoundEffect.SortInventory); SfxDatabase.Instance.Play(SoundEffect.SortInventory);
Inventory_InventoryChanged(); Inventory_InventoryChanged();
foreach (var slot in ItemSlots)
slot.SetItemStyle();
Item_ItemExitFocus(_currentlySelectedItem); Item_ItemExitFocus(_currentlySelectedItem);
_currentlySelectedItem = ItemSlot1; _currentlySelectedItem = ItemSlot1;
_currentlySelectedItem.GrabFocus(); _currentlySelectedItem.GrabFocus();
@@ -151,8 +147,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
{ {
ItemDescriptionTitle.Text = string.Empty; ItemDescriptionTitle.Text = string.Empty;
ItemEffectLabel.Text = string.Empty; ItemEffectLabel.Text = string.Empty;
itemSlot.IsSelected = false;
itemSlot.SetItemStyle();
} }
private void Item_FocusEntered(IItemSlot itemSlot) private void Item_FocusEntered(IItemSlot itemSlot)
@@ -166,19 +160,16 @@ public partial class InventoryMenu : Control, IInventoryMenu
ItemDescriptionTitle.Text = $"{itemSlot.Item.Value.ItemName}"; ItemDescriptionTitle.Text = $"{itemSlot.Item.Value.ItemName}";
ItemEffectLabel.Text = $"{itemSlot.Item.Value.Description}"; ItemEffectLabel.Text = $"{itemSlot.Item.Value.Description}";
_currentlySelectedItem = itemSlot; _currentlySelectedItem = itemSlot;
itemSlot.IsSelected = true;
itemSlot.SetItemStyle();
AcceptEvent(); AcceptEvent();
} }
private void Item_Pressed(InventoryItem item) => DisplayUserActionPrompt(item); private void Item_Pressed(IItemSlot item) => DisplayUserActionPrompt(item.Item.Value);
private async void Inventory_InventoryChanged() private async void Inventory_InventoryChanged()
{ {
foreach (var slot in ItemSlots) foreach (var slot in ItemSlots)
{ {
slot.Visible = false; slot.Visible = false;
slot.SetItemStyle();
} }
var itemsToDisplay = _player.Inventory.Items; var itemsToDisplay = _player.Inventory.Items;
@@ -213,6 +204,8 @@ public partial class InventoryMenu : Control, IInventoryMenu
await EquipOrUnequipItem(equipable); await EquipOrUnequipItem(equipable);
else if (_currentlySelectedItem.Item.Value is Plastique plastique) else if (_currentlySelectedItem.Item.Value is Plastique plastique)
SetItem(); SetItem();
else if (_currentlySelectedItem.Item.Value is Jewel jewel)
AugmentEquipment(jewel);
else else
await _game.UseItem(_currentlySelectedItem.Item.Value); await _game.UseItem(_currentlySelectedItem.Item.Value);
UseButton.Disabled = false; UseButton.Disabled = false;
@@ -250,6 +243,15 @@ public partial class InventoryMenu : Control, IInventoryMenu
_gameRepo.CloseInventory(); _gameRepo.CloseInventory();
} }
private void AugmentEquipment(Jewel jewel)
{
DisplayUserActionPrompt(jewel);
foreach (var item in ItemSlots)
{
item.Disabled = item.Item.Value is not Weapon && item.Item.Value is not Armor && item.Item.Value is not Accessory;
}
}
private void DisplayUserActionPrompt(InventoryItem item) private void DisplayUserActionPrompt(InventoryItem item)
{ {
SfxDatabase.Instance.Play(SoundEffect.SelectUI); SfxDatabase.Instance.Play(SoundEffect.SelectUI);
@@ -264,6 +266,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
{ {
var isItemEquipped = _player.EquipmentComponent.IsItemEquipped(equipable); var isItemEquipped = _player.EquipmentComponent.IsItemEquipped(equipable);
UseButton.Text = isItemEquipped ? "Unequip" : "Equip"; UseButton.Text = isItemEquipped ? "Unequip" : "Equip";
UseButton.Disabled = equipable.Glued;
ThrowButton.Disabled = isItemEquipped; ThrowButton.Disabled = isItemEquipped;
ThrowButton.FocusMode = isItemEquipped ? FocusModeEnum.None : FocusModeEnum.All; ThrowButton.FocusMode = isItemEquipped ? FocusModeEnum.None : FocusModeEnum.All;
DropButton.Disabled = isItemEquipped; DropButton.Disabled = isItemEquipped;

View File

@@ -38,7 +38,6 @@ light_mode = 2
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_unikd"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_unikd"]
[node name="InventoryMenu" type="Control"] [node name="InventoryMenu" type="Control"]
visible = false
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@@ -290,120 +289,126 @@ offset_top = 23.0
offset_right = 1885.0 offset_right = 1885.0
offset_bottom = 1015.0 offset_bottom = 1015.0
[node name="ScrollContainer" type="ScrollContainer" parent="Panel"] [node name="MarginContainer" type="MarginContainer" parent="Panel"]
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
theme_override_constants/margin_left = 15
theme_override_constants/margin_top = 15
theme_override_constants/margin_right = 15
theme_override_constants/margin_bottom = 15
[node name="ScrollContainer" type="ScrollContainer" parent="Panel/MarginContainer"]
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_unikd") theme_override_styles/panel = SubResource("StyleBoxEmpty_unikd")
follow_focus = true follow_focus = true
draw_focus_border = true draw_focus_border = true
[node name="ItemsPage" type="VBoxContainer" parent="Panel/ScrollContainer"] [node name="ItemsPage" type="VBoxContainer" parent="Panel/MarginContainer/ScrollContainer"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 2 size_flags_vertical = 2
alignment = 1 alignment = 1
[node name="ItemSlot1" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot1" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
layout_mode = 2
[node name="ItemSlot2" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot2" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot3" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot3" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot4" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot4" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot5" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot5" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot6" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot6" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot7" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot7" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot8" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot8" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot9" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot9" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot10" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot10" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot11" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot11" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot12" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot12" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot13" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot13" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot14" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot14" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot15" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot15" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot16" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot16" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot17" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot17" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot18" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot18" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot19" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
[node name="ItemSlot19" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")] [node name="ItemSlot20" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot20" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2

View File

@@ -0,0 +1,264 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using System.Collections.Generic;
using System.Linq;
using Zennysoft.Game.Implementation;
using Zennysoft.Game.Ma;
using Zennysoft.Ma.Adapter;
[Meta(typeof(IAutoNode))]
public partial class InventoryMenu2 : Control, IInventoryMenu
{
public override void _Notification(int what) => this.Notify(what);
[Dependency] private IPlayer _player => this.DependOn<IPlayer>();
[Dependency] private IGame _game => this.DependOn<IGame>();
[Dependency] private IGameRepo _gameRepo => this.DependOn<IGameRepo>();
[Node] public Label ItemName { get; set; }
[Node] public Label ItemFlavor { get; set; }
[Node] public Label ItemStats { get; set; }
[Node] public Button InteractButton { get; set; }
[Node] public Button ThrowButton { get; set; }
[Node] public Button DropButton { get; set; }
[Node] public Control ActionPanel { get; set; }
private List<IItemSlot> ItemSlots;
private List<Label> ItemCountLabels;
private IItemSlot _currentlySelected;
#region ItemSlots
[Node] public IItemSlot ItemSlot01 { get; set; }
[Node] public IItemSlot ItemSlot02 { get; set; }
[Node] public IItemSlot ItemSlot03 { get; set; }
[Node] public IItemSlot ItemSlot04 { get; set; }
[Node] public IItemSlot ItemSlot05 { get; set; }
[Node] public IItemSlot ItemSlot06 { get; set; }
[Node] public IItemSlot ItemSlot07 { get; set; }
[Node] public IItemSlot ItemSlot08 { get; set; }
[Node] public IItemSlot ItemSlot09 { get; set; }
[Node] public IItemSlot ItemSlot10 { get; set; }
[Node] public IItemSlot ItemSlot11 { get; set; }
[Node] public IItemSlot ItemSlot12 { get; set; }
[Node] public IItemSlot ItemSlot13 { get; set; }
[Node] public IItemSlot ItemSlot14 { get; set; }
[Node] public IItemSlot ItemSlot15 { get; set; }
[Node] public IItemSlot ItemSlot16 { get; set; }
[Node] public IItemSlot ItemSlot17 { get; set; }
[Node] public IItemSlot ItemSlot18 { get; set; }
[Node] public IItemSlot ItemSlot19 { get; set; }
[Node] public IItemSlot ItemSlot20 { get; set; }
[Node] public Label ItemCount01 { get; set; }
[Node] public Label ItemCount02 { get; set; }
[Node] public Label ItemCount03 { get; set; }
[Node] public Label ItemCount04 { get; set; }
[Node] public Label ItemCount05 { get; set; }
[Node] public Label ItemCount06 { get; set; }
[Node] public Label ItemCount07 { get; set; }
[Node] public Label ItemCount08 { get; set; }
[Node] public Label ItemCount09 { get; set; }
[Node] public Label ItemCount10 { get; set; }
[Node] public Label ItemCount11 { get; set; }
[Node] public Label ItemCount12 { get; set; }
[Node] public Label ItemCount13 { get; set; }
[Node] public Label ItemCount14 { get; set; }
[Node] public Label ItemCount15 { get; set; }
[Node] public Label ItemCount16 { get; set; }
[Node] public Label ItemCount17 { get; set; }
[Node] public Label ItemCount18 { get; set; }
[Node] public Label ItemCount19 { get; set; }
[Node] public Label ItemCount20 { get; set; }
#endregion
public void OnResolved()
{
ItemSlots = [ItemSlot01, ItemSlot02, ItemSlot03, ItemSlot04, ItemSlot05, ItemSlot06, ItemSlot07, ItemSlot08, ItemSlot09, ItemSlot10, ItemSlot11, ItemSlot12, ItemSlot13, ItemSlot14, ItemSlot15, ItemSlot16, ItemSlot17, ItemSlot18, ItemSlot19, ItemSlot20];
ItemCountLabels = [ItemCount01, ItemCount02, ItemCount03, ItemCount04, ItemCount05, ItemCount06, ItemCount07, ItemCount08, ItemCount09, ItemCount10, ItemCount11, ItemCount12, ItemCount13, ItemCount14, ItemCount15, ItemCount16, ItemCount17, ItemCount18, ItemCount19, ItemCount20];
foreach (var slot in ItemSlots)
{
slot.ItemSelected += Slot_FocusEntered;
slot.ItemPressed += Slot_ItemPressed;
}
VisibilityChanged += InventoryMenu_VisibilityChanged;
InteractButton.Pressed += InteractButton_Pressed;
ThrowButton.Pressed += ThrowButton_Pressed;
DropButton.Pressed += DropButton_Pressed;
_currentlySelected = ItemSlot01;
}
private void InteractButton_Pressed()
{
if (_currentlySelected != null)
{
var item = _currentlySelected.Item.Value;
if (item is EquipableItem equipable)
{
if (_player.EquipmentComponent.IsItemEquipped(equipable))
_player.Unequip(equipable);
else
{
_player.Equip(equipable);
}
foreach (var slot in ItemSlots)
slot.SetItemEquipmentStatus(_player.EquipmentComponent.IsItemEquipped(slot.Item.Value));
}
else if (item is Plastique plastique)
_game.SetItem(plastique);
else
_game.UseItem(_currentlySelected.Item.Value);
CloseActionMenu();
}
}
private void DropButton_Pressed()
{
var previousItemInList = Mathf.Max(0, ItemSlots.IndexOf(_currentlySelected) - 1);
_game.DropItem(_currentlySelected.Item.Value);
CloseActionMenu();
_gameRepo.CloseInventory();
if (!_player.Inventory.Items.Contains(_currentlySelected.Item.Value))
_currentlySelected = ItemSlots[previousItemInList];
}
private void ThrowButton_Pressed()
{
var previousItemInList = Mathf.Max(0, ItemSlots.IndexOf(_currentlySelected) - 1);
_game.ThrowItem(_currentlySelected.Item.Value);
CloseActionMenu();
_gameRepo.CloseInventory();
if (!_player.Inventory.Items.Contains(_currentlySelected.Item.Value))
_currentlySelected = ItemSlots[previousItemInList];
}
public override void _Input(InputEvent @event)
{
if (ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.Interact))
{
CloseActionMenu();
SfxDatabase.Instance.Play(SoundEffect.CancelUI);
GetViewport().SetInputAsHandled();
}
if (!ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.MoveUp))
{
if (ItemSlots.First(x => x.Visible) != _currentlySelected)
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
}
if (!ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.MoveDown))
{
if (ItemSlots.Last(x => x.Visible) != _currentlySelected)
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
}
if (Input.IsActionJustPressed(GameInputs.MoveDown) && ActionPanel.Visible && InteractButton.HasFocus() && !ThrowButton.Disabled)
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
if (Input.IsActionJustPressed(GameInputs.MoveDown) && ActionPanel.Visible && ThrowButton.HasFocus() && !DropButton.Disabled)
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
if (Input.IsActionJustPressed(GameInputs.MoveUp) && ActionPanel.Visible && ThrowButton.HasFocus() && !InteractButton.Disabled)
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
if (Input.IsActionJustPressed(GameInputs.MoveUp) && ActionPanel.Visible && DropButton.HasFocus() && !ThrowButton.Disabled)
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
if (!ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.InventorySort))
{
_player.Inventory.Sort(_player.EquipmentComponent.EquippedWeapon.Value, _player.EquipmentComponent.EquippedArmor.Value, _player.EquipmentComponent.EquippedAccessory.Value, _player.EquipmentComponent.EquippedAmmo.Value);
SfxDatabase.Instance.Play(SoundEffect.SortInventory);
InventoryMenu_VisibilityChanged();
}
}
private void Slot_ItemPressed(IItemSlot slot)
{
var item = slot.Item.Value;
InteractButton.Disabled = false;
ThrowButton.Disabled = false;
DropButton.Disabled = false;
InteractButton.FocusMode = FocusModeEnum.All;
ThrowButton.FocusMode = FocusModeEnum.All;
DropButton.FocusMode = FocusModeEnum.All;
if (item is EquipableItem equipable)
{
var itemIsEquipped = _player.EquipmentComponent.IsItemEquipped(equipable);
InteractButton.Text = itemIsEquipped ? "Unequip" : "Equip";
InteractButton.Disabled = itemIsEquipped && equipable.Glued;
ThrowButton.Disabled = itemIsEquipped;
ThrowButton.FocusMode = itemIsEquipped ? FocusModeEnum.None : FocusModeEnum.All;
DropButton.Disabled = itemIsEquipped;
DropButton.FocusMode = itemIsEquipped ? FocusModeEnum.None : FocusModeEnum.All;
InteractButton.GrabFocus();
}
else if (item is Plastique plastique)
{
InteractButton.Text = "Set";
InteractButton.GrabFocus();
}
else if (item is ThrowableItem throwable)
{
InteractButton.Disabled = true;
InteractButton.FocusMode = FocusModeEnum.None;
ThrowButton.GrabFocus();
}
else
{
InteractButton.Text = "Use";
InteractButton.GrabFocus();
}
ActionPanel.Show();
}
private void InventoryMenu_VisibilityChanged()
{
foreach (var item in ItemSlots)
item.Hide();
foreach (var item in ItemCountLabels)
item.Text = string.Empty;
for (var i = 0; i < _player.Inventory.Items.Count; i++)
{
var item = _player.Inventory.Items[i];
ItemSlots[i].Item.OnNext(item);
ItemSlots[i].Show();
ItemSlots[i].SetItemEquipmentStatus(_player.EquipmentComponent.IsItemEquipped(item));
if (item is IStackable stackable)
ItemCountLabels[i].Text = $"x{stackable.Count.Value:D2}";
}
if (_currentlySelected != null)
_currentlySelected.GrabFocus();
else
_currentlySelected = ItemSlots.First();
}
private void Slot_FocusEntered(IItemSlot slot)
{
if (_currentlySelected.Item.Value == null)
return;
_currentlySelected = slot;
var item = slot.Item.Value;
ItemName.Text = item.ItemName;
ItemFlavor.Text = item.Description;
}
private void CloseActionMenu()
{
_currentlySelected.GrabFocus();
ActionPanel.Hide();
}
}

View File

@@ -0,0 +1 @@
uid://yh8qxmn058w2

View File

@@ -0,0 +1,607 @@
[gd_scene load_steps=11 format=3 uid="uid://c3e6hbctay1us"]
[ext_resource type="Script" uid="uid://yh8qxmn058w2" path="res://src/ui/inventory_menu/InventoryMenu2.cs" id="1_x1to8"]
[ext_resource type="PackedScene" uid="uid://c005nd0m2eim" path="res://src/ui/inventory_menu/ItemSlot.tscn" id="2_44spe"]
[ext_resource type="FontFile" uid="uid://beh6d5lo5ihq0" path="res://src/ui/fonts/georgiai.ttf" id="2_g7ag1"]
[ext_resource type="StyleBox" uid="uid://bxuy4tnftibfq" path="res://src/options/SelectedOptionsBox.tres" id="3_smunm"]
[ext_resource type="StyleBox" uid="uid://bl15q835s4ene" path="res://src/options/UnselectedOptionsBox.tres" id="4_cq2sk"]
[ext_resource type="FontFile" uid="uid://0syyay37admf" path="res://src/ui/fonts/georgiab.ttf" id="6_ejvue"]
[ext_resource type="LabelSettings" uid="uid://b6f8ggy3ulonb" path="res://src/ui/label_settings/GeorgiaItalic.tres" id="6_g7ag1"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cq2sk"]
bg_color = Color(0, 0, 0, 0.745098)
[sub_resource type="LabelSettings" id="LabelSettings_ejvue"]
line_spacing = 1.0
font = ExtResource("2_g7ag1")
font_size = 50
outline_size = 3
outline_color = Color(0, 0, 0, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_g7ag1"]
bg_color = Color(0, 0, 0, 0.745098)
[node name="InventoryMenu2" type="Control"]
visible = false
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_x1to8")
[node name="InventoryTitlePanel" type="Panel" parent="."]
layout_mode = 1
offset_left = 38.0
offset_top = 40.0
offset_right = 431.0
offset_bottom = 157.0
theme_override_styles/panel = SubResource("StyleBoxFlat_cq2sk")
[node name="MarginContainer" type="MarginContainer" parent="InventoryTitlePanel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="ReferenceRect" type="ReferenceRect" parent="InventoryTitlePanel/MarginContainer"]
layout_mode = 2
border_color = Color(1, 1, 1, 1)
border_width = 2.0
editor_only = false
[node name="InventoryLabel" type="Label" parent="InventoryTitlePanel/MarginContainer/ReferenceRect"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_font_sizes/font_size = 15
text = "INVENTORY"
label_settings = SubResource("LabelSettings_ejvue")
horizontal_alignment = 1
vertical_alignment = 1
[node name="ActionPanel" type="Panel" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = -1
anchor_left = 0.107
anchor_top = 0.86
anchor_right = 0.199
anchor_bottom = 0.915
offset_left = -164.44
offset_top = -35.8
offset_right = -159.08
offset_bottom = 70.8
grow_vertical = 0
focus_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_g7ag1")
[node name="MarginContainer" type="MarginContainer" parent="ActionPanel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5
[node name="ReferenceRect" type="ReferenceRect" parent="ActionPanel/MarginContainer"]
layout_mode = 2
border_color = Color(1, 1, 1, 1)
border_width = 2.0
editor_only = false
[node name="MarginContainer" type="MarginContainer" parent="ActionPanel/MarginContainer"]
layout_mode = 2
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="VBoxContainer" type="VBoxContainer" parent="ActionPanel/MarginContainer/MarginContainer"]
layout_mode = 2
alignment = 1
[node name="InteractButton" type="Button" parent="ActionPanel/MarginContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_top = NodePath(".")
focus_neighbor_right = NodePath(".")
focus_neighbor_bottom = NodePath("../ThrowButton")
theme_override_font_sizes/font_size = 25
theme_override_styles/focus = ExtResource("3_smunm")
theme_override_styles/disabled_mirrored = ExtResource("4_cq2sk")
theme_override_styles/disabled = ExtResource("4_cq2sk")
theme_override_styles/hover_pressed_mirrored = ExtResource("4_cq2sk")
theme_override_styles/hover_pressed = ExtResource("4_cq2sk")
theme_override_styles/hover_mirrored = ExtResource("4_cq2sk")
theme_override_styles/hover = ExtResource("4_cq2sk")
theme_override_styles/pressed_mirrored = ExtResource("4_cq2sk")
theme_override_styles/pressed = ExtResource("4_cq2sk")
theme_override_styles/normal_mirrored = ExtResource("4_cq2sk")
theme_override_styles/normal = ExtResource("4_cq2sk")
text = "Interact"
alignment = 0
[node name="ThrowButton" type="Button" parent="ActionPanel/MarginContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_top = NodePath("../InteractButton")
focus_neighbor_right = NodePath(".")
focus_neighbor_bottom = NodePath("../DropButton")
theme_override_font_sizes/font_size = 25
theme_override_styles/focus = ExtResource("3_smunm")
theme_override_styles/disabled_mirrored = ExtResource("4_cq2sk")
theme_override_styles/disabled = ExtResource("4_cq2sk")
theme_override_styles/hover_pressed_mirrored = ExtResource("4_cq2sk")
theme_override_styles/hover_pressed = ExtResource("4_cq2sk")
theme_override_styles/hover_mirrored = ExtResource("4_cq2sk")
theme_override_styles/hover = ExtResource("4_cq2sk")
theme_override_styles/pressed_mirrored = ExtResource("4_cq2sk")
theme_override_styles/pressed = ExtResource("4_cq2sk")
theme_override_styles/normal_mirrored = ExtResource("4_cq2sk")
theme_override_styles/normal = ExtResource("4_cq2sk")
text = "Throw"
alignment = 0
[node name="DropButton" type="Button" parent="ActionPanel/MarginContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_top = NodePath("../ThrowButton")
focus_neighbor_right = NodePath(".")
focus_neighbor_bottom = NodePath(".")
theme_override_font_sizes/font_size = 25
theme_override_styles/focus = ExtResource("3_smunm")
theme_override_styles/disabled_mirrored = ExtResource("4_cq2sk")
theme_override_styles/disabled = ExtResource("4_cq2sk")
theme_override_styles/hover_pressed_mirrored = ExtResource("4_cq2sk")
theme_override_styles/hover_pressed = ExtResource("4_cq2sk")
theme_override_styles/hover_mirrored = ExtResource("4_cq2sk")
theme_override_styles/hover = ExtResource("4_cq2sk")
theme_override_styles/pressed_mirrored = ExtResource("4_cq2sk")
theme_override_styles/pressed = ExtResource("4_cq2sk")
theme_override_styles/normal_mirrored = ExtResource("4_cq2sk")
theme_override_styles/normal = ExtResource("4_cq2sk")
text = "Drop"
alignment = 0
[node name="InventoryList" type="Panel" parent="."]
layout_mode = 2
offset_left = 760.0
offset_top = 10.0
offset_right = 1419.0
offset_bottom = 1060.0
theme_override_styles/panel = SubResource("StyleBoxFlat_cq2sk")
[node name="MarginContainer" type="MarginContainer" parent="InventoryList"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 20
[node name="ReferenceRect" type="ReferenceRect" parent="InventoryList/MarginContainer"]
layout_mode = 2
border_color = Color(1, 1, 1, 1)
border_width = 2.0
editor_only = false
[node name="MarginContainer" type="MarginContainer" parent="InventoryList/MarginContainer"]
layout_mode = 2
theme_override_constants/margin_left = 125
theme_override_constants/margin_top = 15
theme_override_constants/margin_right = 15
theme_override_constants/margin_bottom = 15
[node name="HBoxContainer" type="HBoxContainer" parent="InventoryList/MarginContainer/MarginContainer"]
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 0
[node name="ItemSlot01" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot02" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot03" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot04" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot05" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot06" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot07" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot08" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot09" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot10" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot11" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot12" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot13" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot14" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot15" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot16" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot17" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot18" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot19" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot20" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="VBoxContainer2" type="VBoxContainer" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 10
theme_override_constants/separation = 0
[node name="ItemCount01" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount02" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount03" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount04" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount05" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount06" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount07" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount08" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount09" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount10" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount11" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount12" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount13" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount14" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount15" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount16" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount17" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount18" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount19" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount20" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemDescriptionBox" type="Panel" parent="."]
layout_mode = 2
offset_left = 37.0
offset_top = 242.0
offset_right = 717.0
offset_bottom = 838.0
theme_override_styles/panel = SubResource("StyleBoxFlat_cq2sk")
[node name="MarginContainer" type="MarginContainer" parent="ItemDescriptionBox"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="ReferenceRect" type="ReferenceRect" parent="ItemDescriptionBox/MarginContainer"]
layout_mode = 2
border_color = Color(1, 1, 1, 1)
border_width = 2.0
editor_only = false
[node name="MarginContainer" type="MarginContainer" parent="ItemDescriptionBox/MarginContainer"]
layout_mode = 2
theme_override_constants/margin_left = 15
theme_override_constants/margin_top = 15
theme_override_constants/margin_right = 15
theme_override_constants/margin_bottom = 15
[node name="VBoxContainer" type="VBoxContainer" parent="ItemDescriptionBox/MarginContainer/MarginContainer"]
layout_mode = 2
theme_override_constants/separation = 50
[node name="ItemName" type="Label" parent="ItemDescriptionBox/MarginContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
label_settings = ExtResource("6_g7ag1")
[node name="ItemFlavor" type="Label" parent="ItemDescriptionBox/MarginContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(500, 150)
layout_mode = 2
label_settings = ExtResource("6_g7ag1")
vertical_alignment = 1
autowrap_mode = 2
[node name="ItemStats" type="Label" parent="ItemDescriptionBox/MarginContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
label_settings = ExtResource("6_g7ag1")

View File

@@ -4,6 +4,7 @@ using Chickensoft.Introspection;
using Godot; using Godot;
using System; using System;
using Zennysoft.Game.Abstractions; using Zennysoft.Game.Abstractions;
using Zennysoft.Game.Implementation;
using Zennysoft.Ma.Adapter; using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -15,105 +16,56 @@ public partial class ItemSlot : Button, IItemSlot
[Dependency] private IPlayer _player => this.DependOn<IPlayer>(); [Dependency] private IPlayer _player => this.DependOn<IPlayer>();
[Node] public Label Equipped { get; set; } = default!;
[Node] public TextureRect ItemTexture { get; set; } = default!; [Node] public TextureRect ItemTexture { get; set; } = default!;
[Node] public Label ItemName { get; set; } = default!;
[Node] public Label ItemCount { get; set; } = default!;
public AutoProp<InventoryItem> Item { get; } = new AutoProp<InventoryItem>(default); public AutoProp<InventoryItem> Item { get; } = new AutoProp<InventoryItem>(default);
private static LabelSettings ItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextBold.tres"); public event Action<IItemSlot> ItemPressed;
private static LabelSettings SelectedItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextFontItalicized.tres"); public event Action<IItemSlot> ItemSelected;
private static LabelSettings EquippedItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextFontEquipped.tres");
private static LabelSettings SelectedEquippedItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextFontSelectedEquipped.tres");
public event Action<InventoryItem> ItemPressed;
public event Action<IItemSlot> ItemEnterFocus;
public event Action<IItemSlot> ItemExitFocus;
public bool IsSelected { get; set; } = false; public bool IsSelected { get; set; } = false;
public void OnResolved() public void OnResolved()
{ {
Item.Changed += Item_Changed; Item.Changed += Item_Changed;
_player.EquipmentComponent.EquippedWeapon.Sync += EquipableItem_Sync;
_player.EquipmentComponent.EquippedArmor.Sync += EquipableItem_Sync;
_player.EquipmentComponent.EquippedAccessory.Sync += EquipableItem_Sync;
FocusEntered += ItemSlot_FocusEntered; FocusEntered += ItemSlot_FocusEntered;
FocusExited += ItemSlot_FocusExited;
Pressed += ItemSlot_Pressed; Pressed += ItemSlot_Pressed;
} }
public void SetItemStyle() public void SetItemEquipmentStatus(bool isEquipped)
{ {
if (_player.EquipmentComponent.IsItemEquipped(Item.Value) && IsSelected) if (isEquipped)
SetEquippedSelectedItemStyle(); Equipped.Text = "E";
else if (_player.EquipmentComponent.IsItemEquipped(Item.Value))
SetEquippedItemStyle();
else if (IsSelected)
SetSelectedItemStyle();
else else
SetToUnselectedStyle(); Equipped.Text = string.Empty;
} }
public void SetToUnselectedStyle() private void ItemSlot_FocusEntered() => ItemSelected?.Invoke(this);
{
SetItemFont();
if (_player.EquipmentComponent.IsItemEquipped(Item.Value))
SetEquippedItemStyle();
}
private void EquipableItem_Sync(EquipableItem item) => SetItemStyle();
private void ItemSlot_Pressed() private void ItemSlot_Pressed()
{ {
if (Item.Value == null) if (Item.Value == null)
return; return;
ItemPressed?.Invoke(Item.Value); ItemPressed?.Invoke(this);
} }
private void ItemSlot_FocusExited() => ItemExitFocus?.Invoke(this);
private void ItemSlot_FocusEntered() => ItemEnterFocus?.Invoke(this);
private void Item_Changed(InventoryItem obj) private void Item_Changed(InventoryItem obj)
{ {
if (obj == null) if (obj == null)
return; return;
ItemName.Text = obj.ItemName; Text = obj.ItemName;
ItemTexture.Texture = obj.GetTexture(); ItemTexture.Texture = obj.GetTexture();
if (obj is IStackable stackableItem)
if (Item.Value is EquipableItem equipableItem && _player.EquipmentComponent.IsItemEquipped(equipableItem))
{ {
ItemCount.Text = $"{stackableItem.Count:D2}"; Equipped.Text = "E";
ItemCount.Visible = true;
} }
else else
{ Equipped.Text = string.Empty;
ItemCount.Text = string.Empty;
ItemCount.Visible = false;
} }
}
private void SetToSelectedStyle() => SetSelectedItemStyle();
private void SetSelectedItemStyle()
{
if (_player.EquipmentComponent.IsItemEquipped(Item.Value))
ItemName.LabelSettings = SelectedEquippedItemFont;
else
ItemName.LabelSettings = SelectedItemFont;
}
private void SetItemFont() => ItemName.LabelSettings = ItemFont;
private void SetEquippedItemStyle() => ItemName.LabelSettings = EquippedItemFont;
private void SetEquippedSelectedItemStyle() => ItemName.LabelSettings = SelectedEquippedItemFont;
} }

View File

@@ -1,65 +1,62 @@
[gd_scene load_steps=5 format=3 uid="uid://c005nd0m2eim"] [gd_scene load_steps=5 format=3 uid="uid://c005nd0m2eim"]
[ext_resource type="Script" uid="uid://cglxk7v8hpesn" path="res://src/ui/inventory_menu/ItemSlot.cs" id="1_yttxt"] [ext_resource type="Script" uid="uid://cglxk7v8hpesn" path="res://src/ui/inventory_menu/ItemSlot.cs" id="1_yttxt"]
[ext_resource type="LabelSettings" uid="uid://dupifadnagodp" path="res://src/ui/label_settings/MainTextRegular.tres" id="3_rf22b"] [ext_resource type="Texture2D" uid="uid://dymrg1fmwho35" path="res://src/items/weapons/textures/Cross Sword.png" id="2_rf22b"]
[ext_resource type="Script" uid="uid://b0rrpkpsfdga8" path="res://src/ui/inventory_menu/ItemLabel.cs" id="3_xlgl0"] [ext_resource type="StyleBox" uid="uid://bxuy4tnftibfq" path="res://src/options/SelectedOptionsBox.tres" id="4_lt1pw"]
[ext_resource type="FontFile" uid="uid://0syyay37admf" path="res://src/ui/fonts/georgiab.ttf" id="4_t6dim"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_lt1pw"]
[node name="ItemSlot" type="Button"] [node name="ItemSlot" type="Button"]
custom_minimum_size = Vector2(100, 60) custom_minimum_size = Vector2(100, 50)
anchors_preset = -1 anchors_preset = -1
anchor_right = 0.885 anchor_right = 0.885
anchor_bottom = 0.093 anchor_bottom = 0.093
offset_right = 0.799927 offset_left = 123.0
offset_bottom = -0.440002 offset_right = -1414.2
theme_override_styles/focus = SubResource("StyleBoxEmpty_lt1pw") offset_bottom = -50.44
theme_override_styles/disabled_mirrored = SubResource("StyleBoxEmpty_lt1pw") grow_vertical = 2
theme_override_styles/disabled = SubResource("StyleBoxEmpty_lt1pw") size_flags_horizontal = 4
theme_override_styles/hover_pressed_mirrored = SubResource("StyleBoxEmpty_lt1pw") size_flags_vertical = 4
theme_override_styles/hover_pressed = SubResource("StyleBoxEmpty_lt1pw") mouse_filter = 2
theme_override_styles/hover_mirrored = SubResource("StyleBoxEmpty_lt1pw") theme_override_constants/h_separation = 20
theme_override_styles/hover = SubResource("StyleBoxEmpty_lt1pw") theme_override_fonts/font = ExtResource("4_t6dim")
theme_override_styles/pressed_mirrored = SubResource("StyleBoxEmpty_lt1pw") theme_override_font_sizes/font_size = 25
theme_override_styles/pressed = SubResource("StyleBoxEmpty_lt1pw") theme_override_styles/focus = ExtResource("4_lt1pw")
theme_override_styles/normal_mirrored = SubResource("StyleBoxEmpty_lt1pw") theme_override_styles/disabled_mirrored = ExtResource("4_lt1pw")
theme_override_styles/normal = SubResource("StyleBoxEmpty_lt1pw") theme_override_styles/disabled = ExtResource("4_lt1pw")
theme_override_styles/hover_pressed_mirrored = ExtResource("4_lt1pw")
theme_override_styles/hover_pressed = ExtResource("4_lt1pw")
theme_override_styles/hover_mirrored = ExtResource("4_lt1pw")
theme_override_styles/hover = ExtResource("4_lt1pw")
theme_override_styles/pressed_mirrored = ExtResource("4_lt1pw")
theme_override_styles/pressed = ExtResource("4_lt1pw")
theme_override_styles/normal_mirrored = ExtResource("4_lt1pw")
theme_override_styles/normal = ExtResource("4_lt1pw")
button_mask = 0 button_mask = 0
text = "Cross Sword"
flat = true flat = true
alignment = 0 alignment = 0
script = ExtResource("1_yttxt") script = ExtResource("1_yttxt")
[node name="HBox" type="HBoxContainer" parent="."] [node name="ItemTexture" type="TextureRect" parent="."]
custom_minimum_size = Vector2(100, 60) unique_name_in_owner = true
layout_mode = 0 layout_mode = 0
offset_right = 1700.0 offset_left = -65.0
offset_bottom = 100.0 offset_top = 6.0
offset_right = -25.0
[node name="ReferenceRect" type="ReferenceRect" parent="HBox"] offset_bottom = 46.0
custom_minimum_size = Vector2(100, 0) texture = ExtResource("2_rf22b")
layout_mode = 2
[node name="ItemTexture" type="TextureRect" parent="HBox"]
unique_name_in_owner = true
layout_mode = 2
expand_mode = 2 expand_mode = 2
stretch_mode = 4
[node name="ReferenceRect2" type="ReferenceRect" parent="HBox"] [node name="Equipped" type="Label" parent="."]
custom_minimum_size = Vector2(40, 0)
layout_mode = 2
[node name="ItemName" type="Label" parent="HBox"]
unique_name_in_owner = true unique_name_in_owner = true
custom_minimum_size = Vector2(550, 50) custom_minimum_size = Vector2(25, 50)
layout_mode = 2 layout_mode = 2
text = "Mask of the Goddess of Destruction" offset_left = -122.0
label_settings = ExtResource("3_rf22b") offset_right = -78.0
offset_bottom = 50.0
theme_override_fonts/font = ExtResource("4_t6dim")
theme_override_font_sizes/font_size = 25
text = "E"
horizontal_alignment = 1
vertical_alignment = 1 vertical_alignment = 1
script = ExtResource("3_xlgl0")
[node name="ItemCount" type="Label" parent="HBox"]
unique_name_in_owner = true
visible = false
layout_mode = 2
text = "x99"
label_settings = ExtResource("3_rf22b")