mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-08 04:55:53 +00:00
Destructible triggers
This commit is contained in:
parent
f013987bab
commit
7aee230b3c
56 changed files with 1457 additions and 1106 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Controllers;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Utils;
|
||||
|
|
@ -8,6 +9,7 @@ using Godot.Collections;
|
|||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
[Tool]
|
||||
public partial class Destructible3D : StaticBody3D, IDestructible
|
||||
{
|
||||
[Export] public bool Indestructible { get; private set; }
|
||||
|
|
@ -26,6 +28,7 @@ public partial class Destructible3D : StaticBody3D, IDestructible
|
|||
public ActivationType ActivationType { get; private set; } = ActivationType.Toggle;
|
||||
[Export]
|
||||
public Node Target { get; private set;}
|
||||
[Export] public string TargetGroup { get; private set; }
|
||||
|
||||
[Signal]
|
||||
public delegate void ExplodedEventHandler();
|
||||
|
|
@ -39,6 +42,19 @@ public partial class Destructible3D : StaticBody3D, IDestructible
|
|||
_currentHealth = Health;
|
||||
}
|
||||
|
||||
public void _func_godot_apply_properties(Dictionary<string, string> props)
|
||||
{
|
||||
TargetGroup = props["target"];
|
||||
if (props.TryGetValue("activationtype", out var type))
|
||||
{
|
||||
var t = Enum.TryParse(type, true, out ActivationType activationType);
|
||||
if (t)
|
||||
{
|
||||
ActivationType = activationType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Explode()
|
||||
{
|
||||
//ApplyExplosionDamage();
|
||||
|
|
@ -60,6 +76,11 @@ public partial class Destructible3D : StaticBody3D, IDestructible
|
|||
{
|
||||
node.Activate(ActivationType);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(TargetGroup))
|
||||
{
|
||||
ActivationHelper.UseTargets(this, TargetGroup, ActivationType);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateExplosion()
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public partial class Switch3D : Interactable3D
|
|||
|
||||
if (!string.IsNullOrWhiteSpace(TargetGroup))
|
||||
{
|
||||
ActivationHelper.UseTargets(this, TargetGroup);
|
||||
ActivationHelper.UseTargets(this, TargetGroup, activationType);
|
||||
}
|
||||
|
||||
return Targets.Aggregate(success, (current, target) => ActivateTarget(target, activationTypeToUse) | success);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace Cirno.Scripts.Utils;
|
|||
|
||||
public static class ActivationHelper
|
||||
{
|
||||
public static void UseTargets(Node activator, string target)
|
||||
public static void UseTargets(Node activator, string target, ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
GD.Print($"Trying to use targets called: {target}");
|
||||
var targetList = activator.GetTree().GetNodesInGroup(target);
|
||||
|
|
@ -15,7 +15,7 @@ public static class ActivationHelper
|
|||
if (t is IActivable activable)
|
||||
{
|
||||
GD.Print($"Activating {t.Name}");
|
||||
activable.Toggle();
|
||||
activable.Activate(activationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue