Fix restorative
This commit is contained in:
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
public interface IHealthPack
|
public interface IHealthPack
|
||||||
{
|
{
|
||||||
public double RestoreAmount { get; }
|
public int RestoreAmount { get; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ public interface IGameRepo : IDisposable
|
|||||||
|
|
||||||
event Action<EquipableItem>? UnequippedItem;
|
event Action<EquipableItem>? UnequippedItem;
|
||||||
|
|
||||||
event Action<IHealthPack>? RestorativePickedUp;
|
|
||||||
|
|
||||||
event Action<IEnemy>? EnemyDied;
|
event Action<IEnemy>? EnemyDied;
|
||||||
|
|
||||||
void Pause();
|
void Pause();
|
||||||
@@ -56,8 +54,6 @@ public interface IGameRepo : IDisposable
|
|||||||
|
|
||||||
public void OnPlayerAttackedWall();
|
public void OnPlayerAttackedWall();
|
||||||
|
|
||||||
public void OnRestorativePickedUp(IHealthPack restorative);
|
|
||||||
|
|
||||||
public void CloseInventory();
|
public void CloseInventory();
|
||||||
|
|
||||||
public void GameEnded();
|
public void GameEnded();
|
||||||
@@ -85,7 +81,6 @@ public class GameRepo : IGameRepo
|
|||||||
public event Action? PlayerAttackedEnemy;
|
public event Action? PlayerAttackedEnemy;
|
||||||
public event Action<EquipableItem>? EquippedItem;
|
public event Action<EquipableItem>? EquippedItem;
|
||||||
public event Action<EquipableItem>? UnequippedItem;
|
public event Action<EquipableItem>? UnequippedItem;
|
||||||
public event Action<IHealthPack>? RestorativePickedUp;
|
|
||||||
public event Action<IEnemy>? EnemyDied;
|
public event Action<IEnemy>? EnemyDied;
|
||||||
public IAutoProp<bool> IsPaused => _isPaused;
|
public IAutoProp<bool> IsPaused => _isPaused;
|
||||||
private readonly AutoProp<bool> _isPaused;
|
private readonly AutoProp<bool> _isPaused;
|
||||||
@@ -151,11 +146,6 @@ public class GameRepo : IGameRepo
|
|||||||
PlayerAttackedWall?.Invoke();
|
PlayerAttackedWall?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnRestorativePickedUp(IHealthPack restorative)
|
|
||||||
{
|
|
||||||
RestorativePickedUp?.Invoke(restorative);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CloseInventory()
|
public void CloseInventory()
|
||||||
{
|
{
|
||||||
CloseInventoryEvent?.Invoke();
|
CloseInventoryEvent?.Invoke();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using Zennysoft.Ma.Adapter;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Zennysoft.Game.Implementation;
|
using Zennysoft.Game.Implementation;
|
||||||
|
using Zennysoft.Ma.Adapter.Entity;
|
||||||
|
|
||||||
[Meta(typeof(IAutoNode))]
|
[Meta(typeof(IAutoNode))]
|
||||||
public partial class Game : Node3D, IGame
|
public partial class Game : Node3D, IGame
|
||||||
@@ -172,9 +173,10 @@ public partial class Game : Node3D, IGame
|
|||||||
|
|
||||||
OnLoadLevelRequest += LoadLevel;
|
OnLoadLevelRequest += LoadLevel;
|
||||||
|
|
||||||
GameRepo.RestorativePickedUp += GameEventDepot_RestorativePickedUp;
|
|
||||||
GameRepo.CloseInventoryEvent += ExitInventoryAction;
|
GameRepo.CloseInventoryEvent += ExitInventoryAction;
|
||||||
|
|
||||||
|
GameRepo.EnemyDied += GameRepo_EnemyDied;
|
||||||
|
|
||||||
_player.Inventory.BroadcastMessage += BroadcastMessage;
|
_player.Inventory.BroadcastMessage += BroadcastMessage;
|
||||||
|
|
||||||
_map.FloorLoaded += OnFloorLoadFinished;
|
_map.FloorLoaded += OnFloorLoadFinished;
|
||||||
@@ -189,6 +191,11 @@ public partial class Game : Node3D, IGame
|
|||||||
InGameUI.PlayerInfoUI.Activate();
|
InGameUI.PlayerInfoUI.Activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GameRepo_EnemyDied(IEnemy obj)
|
||||||
|
{
|
||||||
|
DropRestorative(obj.GlobalPosition);
|
||||||
|
}
|
||||||
|
|
||||||
private void BroadcastMessage(string obj)
|
private void BroadcastMessage(string obj)
|
||||||
{
|
{
|
||||||
InGameUI.InventoryMessageUI.DisplayMessage(obj);
|
InGameUI.InventoryMessageUI.DisplayMessage(obj);
|
||||||
@@ -404,7 +411,7 @@ public partial class Game : Node3D, IGame
|
|||||||
var restorativeScene = GD.Load<PackedScene>("res://src/items/restorative/Restorative.tscn");
|
var restorativeScene = GD.Load<PackedScene>("res://src/items/restorative/Restorative.tscn");
|
||||||
var restorative = restorativeScene.Instantiate<Restorative>();
|
var restorative = restorativeScene.Instantiate<Restorative>();
|
||||||
AddChild(restorative);
|
AddChild(restorative);
|
||||||
restorative.GlobalPosition = vector;
|
restorative.GlobalPosition = new Vector3(vector.X, 2f, vector.Z) + (-_player.GetGlobalBasis().Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UseTeleportPrompt_CloseTeleportPrompt()
|
private void UseTeleportPrompt_CloseTeleportPrompt()
|
||||||
@@ -427,8 +434,6 @@ public partial class Game : Node3D, IGame
|
|||||||
GameRepo.Resume();
|
GameRepo.Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GameEventDepot_RestorativePickedUp(IHealthPack obj) => _player.VTComponent.Restore((int)obj.RestoreAmount);
|
|
||||||
|
|
||||||
private void IsPaused_Sync(bool isPaused) => GetTree().Paused = isPaused;
|
private void IsPaused_Sync(bool isPaused) => GetTree().Paused = isPaused;
|
||||||
|
|
||||||
private void FinishedLoadingSaveFile() => EmitSignal(SignalName.SaveFileLoaded);
|
private void FinishedLoadingSaveFile() => EmitSignal(SignalName.SaveFileLoaded);
|
||||||
@@ -606,7 +611,6 @@ public partial class Game : Node3D, IGame
|
|||||||
|
|
||||||
OnLoadLevelRequest -= LoadLevel;
|
OnLoadLevelRequest -= LoadLevel;
|
||||||
|
|
||||||
GameRepo.RestorativePickedUp -= GameEventDepot_RestorativePickedUp;
|
|
||||||
GameRepo.CloseInventoryEvent -= ExitInventoryAction;
|
GameRepo.CloseInventoryEvent -= ExitInventoryAction;
|
||||||
|
|
||||||
_player.Inventory.BroadcastMessage -= BroadcastMessage;
|
_player.Inventory.BroadcastMessage -= BroadcastMessage;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using Chickensoft.AutoInject;
|
using Chickensoft.AutoInject;
|
||||||
using Chickensoft.Introspection;
|
using Chickensoft.Introspection;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
using System.Linq;
|
||||||
using Zennysoft.Game.Abstractions;
|
using Zennysoft.Game.Abstractions;
|
||||||
|
using Zennysoft.Ma.Adapter;
|
||||||
|
|
||||||
namespace Zennysoft.Game.Ma;
|
namespace Zennysoft.Game.Ma;
|
||||||
|
|
||||||
@@ -10,7 +12,10 @@ public partial class Restorative : Node3D, IHealthPack
|
|||||||
{
|
{
|
||||||
public override void _Notification(int what) => this.Notify(what);
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
|
|
||||||
|
[Dependency] protected IPlayer _player => this.DependOn(() => GetParent().GetChildren().OfType<IPlayer>().Single());
|
||||||
|
|
||||||
[Node] public Area3D Pickup { get; set; } = default!;
|
[Node] public Area3D Pickup { get; set; } = default!;
|
||||||
|
|
||||||
public double RestoreAmount => 4;
|
[Export]
|
||||||
|
public int RestoreAmount { get; set; } = 4;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://dofju2wfj12y4"]
|
[gd_scene load_steps=4 format=3 uid="uid://dofju2wfj12y4"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://qjvotbwutcb5" path="res://src/items/restorative/Restorative.cs" id="1_3beyl"]
|
[ext_resource type="Script" uid="uid://qjvotbwutcb5" path="res://src/items/restorative/Restorative.cs" id="1_3beyl"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d07kcaqe682l1" path="res://src/items/ammo/textures/AirGeo.png" id="2_6y0d4"]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_o8f22"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_o8f22"]
|
||||||
radius = 0.13613
|
radius = 0.120977
|
||||||
height = 1.09613
|
height = 1.09613
|
||||||
|
|
||||||
[node name="Restorative" type="Node3D"]
|
[node name="Restorative" type="Node3D"]
|
||||||
script = ExtResource("1_3beyl")
|
script = ExtResource("1_3beyl")
|
||||||
|
|
||||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.363669, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.205191, 0)
|
||||||
pixel_size = 0.025
|
pixel_size = 0.025
|
||||||
billboard = 2
|
billboard = 2
|
||||||
texture_filter = 0
|
texture_filter = 0
|
||||||
render_priority = 100
|
render_priority = 100
|
||||||
|
texture = ExtResource("2_6y0d4")
|
||||||
|
|
||||||
[node name="Pickup" type="Area3D" parent="."]
|
[node name="Pickup" type="Area3D" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
@@ -22,5 +24,5 @@ collision_layer = 4
|
|||||||
collision_mask = 0
|
collision_mask = 0
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Pickup"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Pickup"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.348749, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.190116, 0)
|
||||||
shape = SubResource("CapsuleShape3D_o8f22")
|
shape = SubResource("CapsuleShape3D_o8f22")
|
||||||
|
|||||||
@@ -1557,7 +1557,7 @@ billboard = 2
|
|||||||
sprite_frames = SubResource("SpriteFrames_ypixh")
|
sprite_frames = SubResource("SpriteFrames_ypixh")
|
||||||
autoplay = "default"
|
autoplay = "default"
|
||||||
|
|
||||||
[node name="FLAME1" type="AudioStreamPlayer3D" parent="VFX/Flame1"]
|
[node name="FLAME1" type="AudioStreamPlayer3D" parent="VFX/Flame1" groups=["DimmableAudio"]]
|
||||||
transform = Transform3D(1.62602, 0, 0, 0, 2.24719, 0, 0, 0, 2.24719, -0.237626, -1.0051, -0.623936)
|
transform = Transform3D(1.62602, 0, 0, 0, 2.24719, 0, 0, 0, 2.24719, -0.237626, -1.0051, -0.623936)
|
||||||
stream = ExtResource("23_fbuno")
|
stream = ExtResource("23_fbuno")
|
||||||
autoplay = true
|
autoplay = true
|
||||||
@@ -1581,7 +1581,7 @@ billboard = 2
|
|||||||
sprite_frames = SubResource("SpriteFrames_ypixh")
|
sprite_frames = SubResource("SpriteFrames_ypixh")
|
||||||
autoplay = "default"
|
autoplay = "default"
|
||||||
|
|
||||||
[node name="FLAME2" type="AudioStreamPlayer3D" parent="VFX/Flame2"]
|
[node name="FLAME2" type="AudioStreamPlayer3D" parent="VFX/Flame2" groups=["DimmableAudio"]]
|
||||||
transform = Transform3D(1.62602, 0, 0, 0, 2.24719, 0, 0, 0, 2.24719, -0.237626, -1.0051, -0.623936)
|
transform = Transform3D(1.62602, 0, 0, 0, 2.24719, 0, 0, 0, 2.24719, -0.237626, -1.0051, -0.623936)
|
||||||
stream = ExtResource("23_fbuno")
|
stream = ExtResource("23_fbuno")
|
||||||
autoplay = true
|
autoplay = true
|
||||||
|
|||||||
@@ -770,7 +770,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
|||||||
_playerEffectService.Instakill(enemy);
|
_playerEffectService.Instakill(enemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CollisionDetector_AreaEntered(Area3D area)
|
private async void CollisionDetector_AreaEntered(Area3D area)
|
||||||
{
|
{
|
||||||
if (area.GetParent() is InventoryItem inventoryItem)
|
if (area.GetParent() is InventoryItem inventoryItem)
|
||||||
{
|
{
|
||||||
@@ -792,6 +792,9 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
|||||||
}
|
}
|
||||||
if (area.GetParent() is Restorative restorative)
|
if (area.GetParent() is Restorative restorative)
|
||||||
{
|
{
|
||||||
|
await ToSignal(GetTree().CreateTimer(0.2f), "timeout");
|
||||||
|
VTComponent.Restore(restorative.RestoreAmount);
|
||||||
|
SfxDatabase.Instance.Play(SoundEffect.HealVT);
|
||||||
restorative.QueueFree();
|
restorative.QueueFree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1356,7 +1356,7 @@ tracks/3/keys = {
|
|||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_jhq84"]
|
[sub_resource type="Animation" id="Animation_jhq84"]
|
||||||
resource_name = "Rondo"
|
resource_name = "Rondo"
|
||||||
length = 1.23334
|
length = 1.26667
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/imported = false
|
tracks/0/imported = false
|
||||||
tracks/0/enabled = true
|
tracks/0/enabled = true
|
||||||
@@ -1376,10 +1376,10 @@ tracks/1/path = NodePath("SubViewportContainer/SubViewport/WeaponAttack: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, 1.23333),
|
"times": PackedFloat32Array(0, 1.26667),
|
||||||
"transitions": PackedFloat32Array(1, 1),
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
"update": 0,
|
"update": 0,
|
||||||
"values": [0, 37]
|
"values": [0, 38]
|
||||||
}
|
}
|
||||||
tracks/2/type = "value"
|
tracks/2/type = "value"
|
||||||
tracks/2/imported = false
|
tracks/2/imported = false
|
||||||
@@ -7929,6 +7929,9 @@ animations = [{
|
|||||||
}, {
|
}, {
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_y8v4x")
|
"texture": SubResource("AtlasTexture_y8v4x")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": null
|
||||||
}],
|
}],
|
||||||
"loop": false,
|
"loop": false,
|
||||||
"name": &"Rondo",
|
"name": &"Rondo",
|
||||||
|
|||||||
Reference in New Issue
Block a user