mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 15:35:54 +00:00
Fixed healing stations
This commit is contained in:
parent
d4b420052e
commit
f1ddee18c4
9 changed files with 84 additions and 30 deletions
|
|
@ -74,8 +74,8 @@ animation = &"Default"
|
|||
z_index = 2
|
||||
emitting = false
|
||||
amount = 50
|
||||
process_material = SubResource("ParticleProcessMaterial_we5sc")
|
||||
lifetime = 0.8
|
||||
process_material = SubResource("ParticleProcessMaterial_we5sc")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
[connection signal="body_exited" from="." to="." method="_on_body_exited"]
|
||||
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
|
||||
[connection signal="area_exited" from="." to="." method="_on_area_Exited"]
|
||||
|
|
|
|||
|
|
@ -252,11 +252,13 @@ shape = SubResource("CircleShape2D_7n10g")
|
|||
[node name="Error" type="AudioStreamPlayer2D" parent="InteractionProvider"]
|
||||
stream = ExtResource("24_5tmtw")
|
||||
|
||||
[node name="InteractionController" type="Area2D" parent="."]
|
||||
[node name="InteractionController" type="Area2D" parent="." node_paths=PackedStringArray("Health", "Shield")]
|
||||
visible = false
|
||||
collision_layer = 2
|
||||
collision_mask = 0
|
||||
script = ExtResource("27_vwjki")
|
||||
Health = NodePath("../DamageReceiver/HealthProvider")
|
||||
Shield = NodePath("../DamageReceiver/ShieldProvider")
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="InteractionController"]
|
||||
shape = SubResource("CircleShape2D_g3wua")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using Cirno.Scripts.Components.Actors;
|
||||
|
||||
public partial class InteractionController : Area2D
|
||||
{
|
||||
[Export] public ActorResourceProvider Health { get; private set; }
|
||||
[Export] public ActorResourceProvider Shield { get; private set; }
|
||||
|
||||
private bool _enabled = false;
|
||||
|
||||
public bool Enabled
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
[sub_resource type="Resource" id="Resource_6wo78"]
|
||||
script = ExtResource("4_u1i8n")
|
||||
EggIndex = 0
|
||||
StartingEquipment = Array[ExtResource("5_u1i8n")]([])
|
||||
StartingEquipment = []
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_rff8l"]
|
||||
size = Vector2(30, 52.5)
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Components.FSM;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Activables;
|
||||
|
|
@ -22,7 +23,7 @@ public partial class HealthStation : Activable
|
|||
|
||||
private bool _isHealing = false;
|
||||
|
||||
private PlayerMovement _cachedPlayer;
|
||||
private InteractionController _cachedPlayer;
|
||||
|
||||
private double _healingTimer = 0;
|
||||
|
||||
|
|
@ -49,18 +50,20 @@ public partial class HealthStation : Activable
|
|||
{
|
||||
base._Process(delta);
|
||||
|
||||
if (_isHealing && _cachedPlayer != null)
|
||||
if (!_isHealing || _cachedPlayer == null) return;
|
||||
_healingTimer += delta;
|
||||
|
||||
if (!(_healingTimer >= 1)) return;
|
||||
if (_cachedPlayer.Health is not null)
|
||||
{
|
||||
_healingTimer += delta;
|
||||
|
||||
if (_healingTimer >= 1)
|
||||
{
|
||||
_cachedPlayer.CurrentHealth += HealthPerSecond;
|
||||
_cachedPlayer.CurrentShield += ShieldPerSecond;
|
||||
|
||||
_healingTimer = 0;
|
||||
}
|
||||
_cachedPlayer.Health.CurrentResource += HealthPerSecond;
|
||||
}
|
||||
if (_cachedPlayer.Shield is not null)
|
||||
{
|
||||
_cachedPlayer.Shield.CurrentResource += ShieldPerSecond;
|
||||
}
|
||||
|
||||
_healingTimer = 0;
|
||||
}
|
||||
|
||||
public override void Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
|
|
@ -89,23 +92,22 @@ public partial class HealthStation : Activable
|
|||
}
|
||||
}
|
||||
|
||||
private void _on_body_entered(CharacterBody2D area)
|
||||
private void _on_area_entered(Area2D area)
|
||||
{
|
||||
// Heal player if active
|
||||
if (!IsEnabled) return;
|
||||
if (area is not PlayerMovement player) return;
|
||||
|
||||
_cachedPlayer = player;
|
||||
if (area is not InteractionController interactionController) return;
|
||||
|
||||
_cachedPlayer = interactionController;
|
||||
|
||||
_isHealing = true;
|
||||
_particles.Emitting = true;
|
||||
}
|
||||
|
||||
private void _on_body_exited(CharacterBody2D area)
|
||||
private void _on_area_Exited(Area2D area)
|
||||
{
|
||||
if (!_isHealing) return;
|
||||
if (!IsEnabled) return;
|
||||
if (area is not PlayerMovement player) return;
|
||||
if (area is not InteractionController player) return;
|
||||
|
||||
// Stop healing player if active
|
||||
|
||||
|
|
@ -113,5 +115,29 @@ public partial class HealthStation : Activable
|
|||
_particles.Emitting = false;
|
||||
}
|
||||
|
||||
// private void _on_body_entered(CharacterBody2D area)
|
||||
// {
|
||||
// // Heal player if active
|
||||
// if (!IsEnabled) return;
|
||||
// if (area is not PlayerStateMachine player) return;
|
||||
//
|
||||
// _cachedPlayer = player;
|
||||
//
|
||||
// _isHealing = true;
|
||||
// _particles.Emitting = true;
|
||||
// }
|
||||
//
|
||||
// private void _on_body_exited(CharacterBody2D area)
|
||||
// {
|
||||
// if (!_isHealing) return;
|
||||
// if (!IsEnabled) return;
|
||||
// if (area is not PlayerStateMachine player) return;
|
||||
//
|
||||
// // Stop healing player if active
|
||||
//
|
||||
// _isHealing = false;
|
||||
// _particles.Emitting = false;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
BIN
Tilesets/factory.aseprite
(Stored with Git LFS)
BIN
Tilesets/factory.aseprite
(Stored with Git LFS)
Binary file not shown.
BIN
Tilesets/factory.png
(Stored with Git LFS)
BIN
Tilesets/factory.png
(Stored with Git LFS)
Binary file not shown.
|
|
@ -940,15 +940,25 @@ texture = ExtResource("1_70kxh")
|
|||
12:9/0 = 0
|
||||
11:9/0 = 0
|
||||
11:0/0 = 0
|
||||
11:0/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||
12:0/0 = 0
|
||||
12:0/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||
13:0/0 = 0
|
||||
13:0/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||
14:0/0 = 0
|
||||
14:0/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||
14:1/0 = 0
|
||||
14:1/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||
13:1/0 = 0
|
||||
13:1/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||
12:1/0 = 0
|
||||
12:1/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||
11:1/0 = 0
|
||||
11:1/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||
11:2/0 = 0
|
||||
11:2/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||
11:3/0 = 0
|
||||
11:3/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||
12:2/0 = 0
|
||||
12:2/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||
12:3/0 = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue