Camera triggers

This commit is contained in:
Marco 2025-06-30 10:02:37 +02:00
commit b0d0161ab0
8 changed files with 1136 additions and 1074 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,9 @@
[gd_resource type="Resource" script_class="FuncGodotFGDModelPointClass" load_steps=4 format=3 uid="uid://m0xahs14etiy"]
[gd_resource type="Resource" script_class="FuncGodotFGDModelPointClass" load_steps=6 format=3 uid="uid://m0xahs14etiy"]
[ext_resource type="Resource" uid="uid://5bc1qysixhmh" path="res://3D/TrenchBroom/EntityDefinitions/base/actor_base.tres" id="1_yxg7b"]
[ext_resource type="Resource" uid="uid://kerywjgft7vh" path="res://3D/TrenchBroom/EntityDefinitions/base/target_base.tres" id="2_mqd4f"]
[ext_resource type="PackedScene" uid="uid://b0rhxqjs52fsv" path="res://3D/Scenes/Props/Camera_3D.tscn" id="2_yxg7b"]
[ext_resource type="Resource" uid="uid://bd4h6ha84s74b" path="res://3D/TrenchBroom/EntityDefinitions/base/activation_type_base.tres" id="3_ewgk3"]
[ext_resource type="Script" uid="uid://dkmyelig23ub5" path="res://addons/func_godot/src/fgd/func_godot_fgd_model_point_class.gd" id="3_mqd4f"]
[resource]
@ -18,7 +20,7 @@ apply_scale_on_map_build = false
classname = "actor_securitycamera"
description = "Security Camera"
func_godot_internal = false
base_classes = Array[Resource]([ExtResource("1_yxg7b")])
base_classes = Array[Resource]([ExtResource("1_yxg7b"), ExtResource("2_mqd4f"), ExtResource("3_ewgk3")])
class_properties = {}
class_property_descriptions = {}
auto_apply_to_matching_node_properties = false

View file

@ -0,0 +1,8 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://bbhjx7h3wjg2l"]
[ext_resource type="Texture2D" uid="uid://c3mq8nofcrc01" path="res://textures/Floors/Floor_Tiled_Blue_5.png" id="1_s6nau"]
[resource]
albedo_texture = ExtResource("1_s6nau")
metallic_specular = 0.0
texture_filter = 2

View file

@ -1,14 +1,37 @@
using Godot;
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;
@ -20,5 +43,9 @@ public partial class SecurityCamera3D : Destructible3D
if (Engine.IsEditorHint()) return;
GD.Print($"{body.Name} Sighted!");
AlarmManager.Instance?.SoundAlarm(this.GlobalPosition);
if (!string.IsNullOrWhiteSpace(TargetGroup))
{
ActivationHelper.UseTargets(this, TargetGroup);
}
}
}

View file

@ -1,4 +1,6 @@
using System.Linq;
using System;
using System.Linq;
using Cirno.Scripts.Utils;
using Godot;
using Godot.Collections;
@ -33,6 +35,14 @@ public partial class Switch3D : Interactable3D
{
RequirementKeys = [prop];
}
if (props.TryGetValue("activationtype", out var type))
{
var t = Enum.TryParse(type, true, out ActivationType activationType);
if (t)
{
ActivationType = activationType;
}
}
//TargetFunc = props["targetfunc"];
//TargetName = props["targetname"];
}
@ -51,7 +61,7 @@ public partial class Switch3D : Interactable3D
if (!string.IsNullOrWhiteSpace(TargetGroup))
{
UseTargets(this, TargetGroup);
ActivationHelper.UseTargets(this, TargetGroup);
}
return Targets.Aggregate(success, (current, target) => ActivateTarget(target, activationTypeToUse) | success);
@ -64,19 +74,19 @@ public partial class Switch3D : Interactable3D
return true;
}
private void UseTargets(Node activator, string target)
{
GD.Print($"Trying to use targets called: {target}");
var targetList = GetTree().GetNodesInGroup(target);
foreach (var t in targetList)
{
//string f;
GD.Print($"Trying to use {t.Name}");
if (t is IActivable activable)
{
GD.Print($"Activating {t.Name}");
activable.Toggle();
}
}
}
// private void UseTargets(Node activator, string target)
// {
// GD.Print($"Trying to use targets called: {target}");
// var targetList = activator.GetTree().GetNodesInGroup(target);
// foreach (var t in targetList)
// {
// //string f;
// GD.Print($"Trying to use {t.Name}");
// if (t is IActivable activable)
// {
// GD.Print($"Activating {t.Name}");
// activable.Toggle();
// }
// }
// }
}

View file

@ -0,0 +1,22 @@
using Godot;
namespace Cirno.Scripts.Utils;
public static class ActivationHelper
{
public static void UseTargets(Node activator, string target)
{
GD.Print($"Trying to use targets called: {target}");
var targetList = activator.GetTree().GetNodesInGroup(target);
foreach (var t in targetList)
{
//string f;
GD.Print($"Trying to use {t.Name}");
if (t is IActivable activable)
{
GD.Print($"Activating {t.Name}");
activable.Toggle();
}
}
}
}

View file

@ -0,0 +1 @@
uid://yaelg8hdimia