Rotate bullet pattern to face parent

This commit is contained in:
Marco 2025-07-09 12:00:23 +02:00
commit 7d267c406d
19 changed files with 1325 additions and 1245 deletions

View file

@ -1,4 +1,5 @@
using Godot;
using Godot.Collections;
namespace Cirno.Scripts.Interactables._3D;
@ -28,6 +29,29 @@ public partial class AnimatedSwitch3D : Switch3D
SyncAnimation();
}
public override void _func_godot_apply_properties(Dictionary<string, Variant> props)
{
base._func_godot_apply_properties(props);
// TargetGroup = props["target"].AsString();
// if (props.TryGetValue("key", out var prop))
// {
// RequirementKeys = [prop.AsString()];
// }
// if (props.TryGetValue("activationtype", out var type))
// {
// var t = Enum.TryParse(type, true, out ActivationType activationType);
// if (t)
// {
// ActivationType = activationType;
// }
// }
var startEnabled = props["start_enabled"].AsBool();
State = startEnabled ? DoorState.Open : DoorState.Closed;
}
private void SyncAnimation()
{

View file

@ -9,7 +9,7 @@ namespace Cirno.Scripts.Interactables;
[Tool]
public partial class Switch3D : Interactable3D
{
[Export] public string TargetGroup { get; private set; }
[Export] public string TargetGroup { get; protected set; }
[Export] public Node Target { get; set; }
[Export] public Array<Node> Targets { get; private set; } = [];
[Export] public ActivationType ActivationType { get; set; } = ActivationType.Toggle;
@ -31,17 +31,17 @@ public partial class Switch3D : Interactable3D
_denySound = GetNodeOrNull<AudioStreamPlayer>(_denySoundName);
}
public void _func_godot_apply_properties(Dictionary<string, string> props)
public virtual void _func_godot_apply_properties(Dictionary<string, Variant> props)
{
TargetGroup = props["target"];
TargetGroup = props["target"].AsString();
if (props.TryGetValue("key", out var prop))
{
RequirementKeys = [prop];
RequirementKeys = [prop.AsString()];
}
if (props.TryGetValue("activationtype", out var type))
{
var t = Enum.TryParse(type, true, out ActivationType activationType);
var t = Enum.TryParse(type.AsString(), true, out ActivationType activationType);
if (t)
{
ActivationType = activationType;
@ -68,11 +68,11 @@ public partial class Switch3D : Interactable3D
if (!string.IsNullOrWhiteSpace(TargetGroup))
{
ActivationHelper.UseTargets(this, TargetGroup, activationType);
success |= ActivationHelper.UseTargets(this, TargetGroup, activationType);
}
var result = Targets.Aggregate(success,
(current, target) => ActivateTarget(target, activationTypeToUse) | success);
(current, target) => current | ActivateTarget(target, activationTypeToUse));
if (result)
{