Map Triggers

This commit is contained in:
Marco 2025-06-18 11:33:27 +02:00
commit 054c0998ad
34 changed files with 5896 additions and 477 deletions

View file

@ -1,11 +1,16 @@
[gd_resource type="Resource" script_class="FuncGodotFGDPointClass" load_steps=4 format=3 uid="uid://bmfarpfcbbfa5"]
[gd_resource type="Resource" script_class="FuncGodotFGDModelPointClass" load_steps=4 format=3 uid="uid://bmfarpfcbbfa5"]
[ext_resource type="Resource" uid="uid://5bc1qysixhmh" path="res://3D/TrenchBroom/EntityDefinitions/base/actor_base.tres" id="1_2x8yp"]
[ext_resource type="PackedScene" uid="uid://bb2pjblwkb7ub" path="res://3D/Scenes/Props/Vending_Machine_3D.tscn" id="2_2x8yp"]
[ext_resource type="Script" uid="uid://c83r7t467hm4m" path="res://addons/func_godot/src/fgd/func_godot_fgd_point_class.gd" id="3_jepr3"]
[ext_resource type="Script" uid="uid://dkmyelig23ub5" path="res://addons/func_godot/src/fgd/func_godot_fgd_model_point_class.gd" id="3_2x8yp"]
[resource]
script = ExtResource("3_jepr3")
script = ExtResource("3_2x8yp")
target_map_editor = 0
models_sub_folder = ""
scale_expression = ""
generate_size_property = false
generate_gd_ignore_file = false
scene_file = ExtResource("2_2x8yp")
apply_rotation_on_map_build = true
apply_scale_on_map_build = false
@ -17,8 +22,8 @@ class_properties = {}
class_property_descriptions = {}
auto_apply_to_matching_node_properties = false
meta_properties = {
"model": "\"3D/MapModels/VendingMachine.glb\"",
"size": AABB(-8, -8, -12, 8, 8, 12)
"size": AABB(-8, -8, -12, 8, 8, 12),
"studio": "\"3D/MapModels/actor_vendingmachine.glb\""
}
node_class = ""
name_property = ""

View file

@ -0,0 +1,30 @@
[gd_resource type="Resource" script_class="FuncGodotFGDModelPointClass" load_steps=4 format=3 uid="uid://ceio7tm5eopbb"]
[ext_resource type="Resource" uid="uid://5bc1qysixhmh" path="res://3D/TrenchBroom/EntityDefinitions/base/actor_base.tres" id="1_5ms1a"]
[ext_resource type="PackedScene" uid="uid://du6hlcoq0iip4" path="res://3D/Scenes/Props/control_pad_3d.tscn" id="2_5ms1a"]
[ext_resource type="Script" uid="uid://dkmyelig23ub5" path="res://addons/func_godot/src/fgd/func_godot_fgd_model_point_class.gd" id="3_y02cg"]
[resource]
script = ExtResource("3_y02cg")
target_map_editor = 0
models_sub_folder = ""
scale_expression = ""
generate_size_property = false
generate_gd_ignore_file = false
scene_file = ExtResource("2_5ms1a")
apply_rotation_on_map_build = true
apply_scale_on_map_build = false
classname = "actor_vendingmachine"
description = "Vending Machine"
func_godot_internal = false
base_classes = Array[Resource]([ExtResource("1_5ms1a")])
class_properties = {}
class_property_descriptions = {}
auto_apply_to_matching_node_properties = false
meta_properties = {
"size": AABB(-8, -8, -12, 8, 8, 12),
"studio": "\"3D/MapModels/actor_vendingmachine.glb\""
}
node_class = ""
name_property = ""
metadata/_custom_type_script = "uid://c83r7t467hm4m"

View file

@ -1,6 +1,7 @@
[gd_resource type="Resource" script_class="FuncGodotFGDPointClass" load_steps=4 format=3 uid="uid://jn17j3xk5f3m"]
[gd_resource type="Resource" script_class="FuncGodotFGDPointClass" load_steps=5 format=3 uid="uid://jn17j3xk5f3m"]
[ext_resource type="Resource" uid="uid://5bc1qysixhmh" path="res://3D/TrenchBroom/EntityDefinitions/base/actor_base.tres" id="1_opmpi"]
[ext_resource type="Resource" uid="uid://c1utxplehq2jl" path="res://3D/TrenchBroom/EntityDefinitions/base/targetname_base.tres" id="2_d6vd7"]
[ext_resource type="PackedScene" uid="uid://b3io3bage2qyb" path="res://3D/Scenes/Props/Elevator_Path_3D.tscn" id="2_opmpi"]
[ext_resource type="Script" uid="uid://c83r7t467hm4m" path="res://addons/func_godot/src/fgd/func_godot_fgd_point_class.gd" id="3_t8pgb"]
@ -12,7 +13,7 @@ apply_scale_on_map_build = false
classname = "actor_elevator_1"
description = "Elevator Type 1"
func_godot_internal = false
base_classes = Array[Resource]([ExtResource("1_opmpi")])
base_classes = Array[Resource]([ExtResource("1_opmpi"), ExtResource("2_d6vd7")])
class_properties = {}
class_property_descriptions = {}
auto_apply_to_matching_node_properties = false

View file

@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://msq50x6rk4po" path="res://addons/func_godot/src/fgd/func_godot_fgd_solid_class.gd" id="1_oh5jt"]
[ext_resource type="Resource" uid="uid://ermxog0n4mvn" path="res://3D/TrenchBroom/EntityDefinitions/base/trigger_base.tres" id="1_xcmav"]
[ext_resource type="Script" uid="uid://dp6h7yqh8x1gv" path="res://3D/TrenchBroom/EntityScripts/Triggers/trigger_area.gd" id="3_5p7mv"]
[ext_resource type="Script" uid="uid://bafphlee7g81i" path="res://3D/TrenchBroom/EntityScripts/Triggers/TriggerArea.cs" id="3_xcmav"]
[resource]
script = ExtResource("1_oh5jt")
@ -15,7 +15,7 @@ build_occlusion = false
render_layers = 0
collision_shape_type = 1
collision_layer = 4
collision_mask = 4
collision_mask = 2
collision_priority = 1.0
collision_shape_margin = 0.04
add_textures_metadata = false
@ -23,7 +23,7 @@ add_vertex_metadata = false
add_face_position_metadata = false
add_face_normal_metadata = false
add_collision_shape_face_range_metadata = false
script_class = ExtResource("3_5p7mv")
script_class = ExtResource("3_xcmav")
classname = "trigger_area"
description = "Area node that activates its target group when entered."
func_godot_internal = false

View file

@ -0,0 +1,8 @@
using Godot;
using System;
[Tool]
public partial class ActivableSetter : Node
{
}

View file

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

View file

@ -0,0 +1,105 @@
using Godot;
using System;
using Cirno.Scripts;
using Cirno.Scripts.Components.FSM._3DPlayer;
using Godot.Collections;
[Tool]
public partial class TriggerArea : Area3D
{
[Export] public string Target { get; private set; }
[Export] public string TargetFunc { get; private set; }
[Export] public string TargetName { get; private set; }
public enum TriggerStates
{
READY,
USED
}
private TriggerStates _triggerState = TriggerStates.READY;
private float _timeout = 0f;
private Node _lastActivator;
public void _func_godot_apply_properties(Dictionary<string, string> props)
{
Target = props["target"];
TargetFunc = props["targetfunc"];
TargetName = props["targetname"];
}
public void _on_ent_entered(Node ent)
{
GD.Print($"Trigger entered by {ent.Name}");
if (_triggerState is TriggerStates.READY)
{
if (ent is IsoPlayerFSMProxy)
{
GD.Print($"Entity {ent} is player, trying to use");
Use();
}
else
{
GD.Print($"{ent.Name} was not interaction controller");
}
}
else
{
GD.Print("Trigger was not ready");
}
}
public void Use()
{
if (_triggerState is TriggerStates.READY)
{
_triggerState = TriggerStates.USED;
ToggleCollision(false);
UseTargets(this, Target);
}
}
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 ToggleCollision(bool toggle)
{
}
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
if (Engine.IsEditorHint()) return;
//TBGAME.set_targetname(self, targetname)
if (!string.IsNullOrEmpty(TargetName))
{
this.AddToGroup(TargetName);
}
}
public TriggerArea()
{
Monitoring = true;
Monitorable = false;
BodyEntered += _on_ent_entered;
//AreaEntered += _on_ent_entered;
}
}

View file

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