mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
51 lines
No EOL
1.5 KiB
C#
51 lines
No EOL
1.5 KiB
C#
using System;
|
|
using Cirno.Scripts.Utils;
|
|
using Godot;
|
|
using Godot.Collections;
|
|
|
|
namespace Cirno.Scripts.Actors._3D;
|
|
|
|
[Tool]
|
|
public partial class SecurityCamera3D : Destructible3D
|
|
{
|
|
[Export] public StringName SweepAnimation { get; private set; } = "SweepLoop";
|
|
|
|
[Export] public string TargetGroup { get; private set; }
|
|
[Export] public ActivationType ActivationType { get; set; } = ActivationType.Toggle;
|
|
|
|
[Signal]
|
|
public delegate void AnimationStartEventHandler(string animationName);
|
|
[Signal]
|
|
public delegate void OnActivatedEventHandler(ActivationType activationType);
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void _Ready()
|
|
{
|
|
if (Engine.IsEditorHint()) return;
|
|
EmitSignalAnimationStart(SweepAnimation);
|
|
}
|
|
|
|
public void OnBodySighted(Node3D body)
|
|
{
|
|
if (Engine.IsEditorHint()) return;
|
|
GD.Print($"{body.Name} Sighted!");
|
|
AlarmManager.Instance?.SoundAlarm(this.GlobalPosition);
|
|
if (!string.IsNullOrWhiteSpace(TargetGroup))
|
|
{
|
|
ActivationHelper.UseTargets(this, TargetGroup);
|
|
}
|
|
}
|
|
} |