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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -3175,6 +3175,17 @@
}
// entity 221
{
"classname" "actor_valve"
"origin" "72 -216 32"
"target" "door_test1"
}
// entity 222
{
"classname" "actor_tube_straight"
"origin" "72 -216 24"
}
// entity 223
{
"classname" "func_group"
"_tb_type" "_tb_layer"
"_tb_name" "Solid"
@ -5458,282 +5469,282 @@
( -296 -928 96 ) ( -296 -929 96 ) ( -296 -928 97 ) Floors/Floor255 [ 0 -1 0 0 ] [ 0 0 1 0 ] 180 1 -1
}
}
// entity 222
// entity 224
{
"classname" "actor_box_wood"
"origin" "172 -96 20"
"_tb_layer" "3"
}
// entity 223
// entity 225
{
"classname" "actor_box_blue"
"origin" "-80 -96 28"
"_tb_layer" "3"
}
// entity 224
// entity 226
{
"classname" "actor_box_red"
"origin" "-80 -88 20"
"_tb_layer" "3"
}
// entity 225
// entity 227
{
"classname" "actor_terminal"
"origin" "-60 -152 28"
"angle" "90"
"_tb_layer" "3"
}
// entity 226
// entity 228
{
"classname" "actor_ac_unit"
"origin" "-32 -156 24"
"angle" "270"
"_tb_layer" "3"
}
// entity 227
// entity 229
{
"classname" "actor_table"
"origin" "-56 -152 20"
"angle" "90"
"_tb_layer" "3"
}
// entity 228
// entity 230
{
"classname" "actor_box_wood"
"origin" "-72 -116 20"
"angles" "0 -30 0"
"_tb_layer" "3"
}
// entity 229
// entity 231
{
"classname" "actor_table"
"origin" "-8 -92 20"
"_tb_layer" "3"
}
// entity 230
// entity 232
{
"classname" "actor_box_wood"
"origin" "-84 -152 20"
"_tb_layer" "3"
}
// entity 231
// entity 233
{
"classname" "actor_box_wood"
"origin" "-76 -152 20"
"_tb_layer" "3"
}
// entity 232
// entity 234
{
"classname" "actor_box_wood"
"origin" "-80 -104 20"
"_tb_layer" "3"
}
// entity 233
// entity 235
{
"classname" "actor_tank"
"origin" "168 -544 64"
"_tb_layer" "3"
}
// entity 234
// entity 236
{
"classname" "actor_tank"
"origin" "168 -576 64"
"_tb_layer" "3"
}
// entity 235
// entity 237
{
"classname" "actor_box_wood"
"origin" "160 -600 60"
"_tb_layer" "3"
}
// entity 236
// entity 238
{
"classname" "actor_box_wood"
"origin" "160 -616 60"
"_tb_layer" "3"
}
// entity 237
// entity 239
{
"classname" "actor_box_red"
"origin" "164 -632 60"
"_tb_layer" "3"
}
// entity 238
// entity 240
{
"classname" "actor_box_blue"
"origin" "164 -632 68"
"_tb_layer" "3"
}
// entity 239
// entity 241
{
"classname" "actor_box_wood"
"origin" "276 -192 20"
"_tb_layer" "3"
}
// entity 240
// entity 242
{
"classname" "actor_elevator_1"
"origin" "216 -376 15"
"_tb_layer" "3"
}
// entity 241
// entity 243
{
"classname" "actor_tube_straight"
"origin" "-80 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 242
// entity 244
{
"classname" "actor_tube_straight"
"origin" "-64 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 243
// entity 245
{
"classname" "actor_tube_straight"
"origin" "-48 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 244
// entity 246
{
"classname" "actor_tube_straight"
"origin" "-32 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 245
// entity 247
{
"classname" "actor_tube_straight"
"origin" "-16 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 246
// entity 248
{
"classname" "actor_tube_straight"
"origin" "0 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 247
// entity 249
{
"classname" "actor_tube_straight"
"origin" "16 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 248
// entity 250
{
"classname" "actor_tube_straight"
"origin" "32 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 249
// entity 251
{
"classname" "actor_tube_straight"
"origin" "48 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 250
// entity 252
{
"classname" "actor_tube_straight"
"origin" "64 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 251
// entity 253
{
"classname" "actor_tube_straight"
"origin" "80 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 252
// entity 254
{
"classname" "actor_tube_straight"
"origin" "96 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 253
// entity 255
{
"classname" "actor_tube_straight"
"origin" "112 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 254
// entity 256
{
"classname" "actor_tube_straight"
"origin" "128 -48 -16"
"angle" "270"
"_tb_layer" "3"
}
// entity 255
// entity 257
{
"classname" "actor_tube_corner"
"origin" "144 -48 -16"
"angle" "90"
"_tb_layer" "3"
}
// entity 256
// entity 258
{
"classname" "actor_tank"
"origin" "-216 -32 -16"
"angle" "90"
"_tb_layer" "3"
}
// entity 257
// entity 259
{
"classname" "actor_tube_straight"
"origin" "-200 -32 -16"
"angle" "90"
"_tb_layer" "3"
}
// entity 258
// entity 260
{
"classname" "actor_tube_straight"
"origin" "-184 -32 -16"
"angle" "90"
"_tb_layer" "3"
}
// entity 259
// entity 261
{
"classname" "actor_tube_straight"
"origin" "-152 -32 -16"
"angle" "90"
"_tb_layer" "3"
}
// entity 260
// entity 262
{
"classname" "actor_barrel_1"
"origin" "-252 -8 -16"
"_tb_layer" "3"
}
// entity 261
// entity 263
{
"classname" "actor_box_red"
"origin" "-264 -24 -20"
"_tb_layer" "3"
}
// entity 262
// entity 264
{
"classname" "actor_box_red"
"origin" "-264 -24 -12"
"_tb_layer" "3"
}
// entity 263
// entity 265
{
"classname" "actor_box_green"
"origin" "-264 -8 -20"
"_tb_layer" "3"
}
// entity 264
// entity 266
{
"classname" "func_group"
"_tb_type" "_tb_group"
@ -5752,7 +5763,7 @@
( -248 -64 0 ) ( -248 -64 1 ) ( -248 -63 0 ) special/clip [ -8.269460797427576e-16 1 0 0 ] [ 0 0 -1 -8 ] 270 1 1
}
}
// entity 265
// entity 267
{
"classname" "func_group"
"_tb_type" "_tb_group"
@ -5770,122 +5781,122 @@
( -104 -208 48 ) ( -104 -208 49 ) ( -104 -207 48 ) Manual/Blue_Panel_Wall_Thin [ 0 1 0 8 ] [ 0 0 -1 -16 ] 0 1 1
}
}
// entity 266
// entity 268
{
"classname" "actor_capacitor_mini"
"origin" "-248 104 -16"
"_tb_layer" "3"
}
// entity 267
// entity 269
{
"classname" "actor_tank_large"
"origin" "-304 -24 -8"
"_tb_layer" "3"
}
// entity 268
// entity 270
{
"classname" "actor_chest_1"
"origin" "-252 -24 -16"
"_tb_layer" "3"
}
// entity 269
// entity 271
{
"classname" "actor_chest_1"
"origin" "40 -200 24"
"_tb_layer" "3"
}
// entity 270
// entity 272
{
"classname" "actor_elevator_1"
"origin" "-168 112 -25"
"targetname" "elevator_2"
"_tb_layer" "3"
}
// entity 271
// entity 273
{
"classname" "actor_terminal_big"
"origin" "92 -248 28"
"angle" "90"
"_tb_layer" "3"
}
// entity 272
// entity 274
{
"classname" "actor_barrel_1"
"origin" "176 -144 24"
"_tb_layer" "3"
}
// entity 273
// entity 275
{
"classname" "actor_barrel_1"
"origin" "176 -300 24"
"_tb_layer" "3"
}
// entity 274
// entity 276
{
"classname" "actor_barrel_1"
"origin" "188 -144 24"
"_tb_layer" "3"
}
// entity 275
// entity 277
{
"classname" "actor_barrel_1"
"origin" "-256 -36 -16"
"_tb_layer" "3"
}
// entity 276
// entity 278
{
"classname" "actor_barrel_1"
"origin" "-300 56 -16"
"_tb_layer" "3"
}
// entity 277
// entity 279
{
"classname" "actor_barrel_1"
"origin" "-300 68 -16"
"_tb_layer" "3"
}
// entity 278
// entity 280
{
"classname" "actor_barrel_1"
"origin" "-292 64 -16"
"_tb_layer" "3"
}
// entity 279
// entity 281
{
"classname" "actor_tube_straight"
"origin" "-168 -32 -16"
"angle" "90"
"_tb_layer" "3"
}
// entity 280
// entity 282
{
"classname" "actor_tube_straight"
"origin" "-128 48 -32"
"angles" "0 0 90"
"_tb_layer" "3"
}
// entity 281
// entity 283
{
"classname" "actor_tube_straight"
"origin" "-128 48 -48"
"angles" "0 0 90"
"_tb_layer" "3"
}
// entity 282
// entity 284
{
"classname" "actor_tube_straight"
"origin" "-128 64 -36"
"angles" "0 0 90"
"_tb_layer" "3"
}
// entity 283
// entity 285
{
"classname" "actor_tube_straight"
"origin" "-128 64 -52"
"angles" "0 0 90"
"_tb_layer" "3"
}
// entity 284
// entity 286
{
"classname" "actor_capacitor_mini"
"origin" "8 320 -16"
@ -5893,7 +5904,7 @@
"activationtype" "Open"
"_tb_layer" "3"
}
// entity 285
// entity 287
{
"classname" "func_group"
"_tb_type" "_tb_layer"
@ -5902,7 +5913,7 @@
"_tb_layer_sort_index" "1"
"_tb_layer_hidden" "1"
}
// entity 286
// entity 288
{
"classname" "func_shroud"
"targetname" "secret_door_1"
@ -5918,7 +5929,7 @@
( 0 480 24 ) ( 0 480 25 ) ( 0 481 24 ) Manual/Black [ 0 1 0 0 ] [ 0 0 -1 0 ] 90 1 1
}
}
// entity 287
// entity 289
{
"classname" "func_shroud"
"targetname" "secret_door_1"
@ -5934,7 +5945,7 @@
( -84 376 24 ) ( -84 376 25 ) ( -84 377 24 ) Manual/Black [ 0 1 0 0 ] [ 0 0 -1 0 ] 90 1 1
}
}
// entity 288
// entity 290
{
"classname" "func_shroud"
"targetname" "door5"
@ -5950,7 +5961,7 @@
( 344 -112 64 ) ( 344 -112 65 ) ( 344 -111 64 ) Manual/Black [ 0 1 0 0 ] [ 0 0 -1 0 ] 180 1 1
}
}
// entity 289
// entity 291
{
"classname" "func_shroud"
"targetname" "secret_door_1"
@ -5966,7 +5977,7 @@
( -84 320 24 ) ( -84 320 25 ) ( -84 321 24 ) Manual/Black [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1
}
}
// entity 290
// entity 292
{
"classname" "func_shroud"
"targetname" "secret_door_2"

View file

@ -7,7 +7,7 @@
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
size = Vector3(0.69390893, 0.868431, 0.871704)
[node name="TubeEmitter" type="StaticBody3D" groups=["Solid"]]
[node name="TubeEmitter" type="StaticBody3D" groups=["Permeable", "Solid"]]
script = ExtResource("1_0vfab")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
@ -15,7 +15,8 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.15304595, 0.00475672, 0.004
shape = SubResource("BoxShape3D_hsg1w")
[node name="blockbench_export" parent="." instance=ExtResource("1_i2hpd")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 0, 0)
[node name="BulletSpawner3D" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.34088433, 0, 0)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.42878178, 0, 0)
script = ExtResource("3_xohn2")

View file

@ -8,26 +8,14 @@
[resource]
script = ExtResource("3_y02cg")
target_map_editor = 0
models_sub_folder = ""
scale_expression = ""
generate_size_property = false
target_map_editor = 1
rotation_offset = Vector3(0, 180, 0)
generate_gd_ignore_file = false
scene_file = ExtResource("2_5ms1a")
apply_rotation_on_map_build = true
apply_scale_on_map_build = false
classname = "actor_controlpad"
description = "Control Pad"
func_godot_internal = false
base_classes = Array[Resource]([ExtResource("1_5ms1a"), ExtResource("2_65tcb"), ExtResource("3_ybdcc")])
class_properties = {}
class_property_descriptions = {}
auto_apply_to_matching_node_properties = false
meta_properties = {
"size": AABB(-4, -4, -4, 4, 4, 4),
"studio": "\"3D\\MapModels/actor_controlpad.glb\""
"size": AABB(-4, -4, -4, 4, 4, 4)
}
node_class = ""
name_property = ""
metadata/_custom_type_script = "uid://c83r7t467hm4m"

View file

@ -0,0 +1,26 @@
[gd_resource type="Resource" script_class="FuncGodotFGDModelPointClass" load_steps=5 format=3 uid="uid://cy6802obllcmv"]
[ext_resource type="Resource" uid="uid://5bc1qysixhmh" path="res://3D/TrenchBroom/EntityDefinitions/base/actor_base.tres" id="1_7mq2y"]
[ext_resource type="Resource" uid="uid://kerywjgft7vh" path="res://3D/TrenchBroom/EntityDefinitions/base/target_base.tres" id="2_4hikn"]
[ext_resource type="PackedScene" uid="uid://dvmkfm2l3vcf7" path="res://3D/Scenes/Props/Valve_3D.tscn" id="4_7mq2y"]
[ext_resource type="Script" uid="uid://dkmyelig23ub5" path="res://addons/func_godot/src/fgd/func_godot_fgd_model_point_class.gd" id="5_hgjgd"]
[resource]
script = ExtResource("5_hgjgd")
target_map_editor = 1
rotation_offset = Vector3(0, 180, 0)
scene_file = ExtResource("4_7mq2y")
apply_scale_on_map_build = false
classname = "actor_valve"
description = "Valve"
base_classes = Array[Resource]([ExtResource("1_7mq2y"), ExtResource("2_4hikn")])
class_properties = {
"start_enabled": false
}
class_property_descriptions = {
"start_enabled": "Starts open?"
}
meta_properties = {
"size": AABB(-8, -8, -4, 8, 8, 4)
}
metadata/_custom_type_script = "uid://c83r7t467hm4m"

View file

@ -1,4 +1,4 @@
[gd_resource type="Resource" script_class="FuncGodotFGDFile" load_steps=42 format=3 uid="uid://b700sa4be6dfa"]
[gd_resource type="Resource" script_class="FuncGodotFGDFile" load_steps=43 format=3 uid="uid://b700sa4be6dfa"]
[ext_resource type="Resource" uid="uid://ia1t5p4mhom3" path="res://3D/TrenchBroom/EntityDefinitions/point/lights/light_omni.tres" id="1_7vcj1"]
[ext_resource type="Script" uid="uid://cknmd0lgmorx2" path="res://addons/func_godot/src/fgd/func_godot_fgd_file.gd" id="1_lykim"]
@ -41,8 +41,9 @@
[ext_resource type="Resource" uid="uid://fbovhni8adhg" path="res://3D/TrenchBroom/EntityDefinitions/point/triggers/Alarm_Trigger_3D.tres" id="38_mdgca"]
[ext_resource type="Resource" uid="uid://c8jy0j0d0nw0x" path="res://3D/TrenchBroom/EntityDefinitions/point/actors/Actor_Stairs_mini.tres" id="39_d6b4f"]
[ext_resource type="Resource" uid="uid://5jxyln87hluw" path="res://3D/TrenchBroom/EntityDefinitions/point/actors/actor_tube_straight_long.tres" id="40_l3pck"]
[ext_resource type="Resource" uid="uid://cy6802obllcmv" path="res://3D/TrenchBroom/EntityDefinitions/point/actors/actor_valve.tres" id="41_q8hab"]
[resource]
script = ExtResource("1_lykim")
entity_definitions = Array[Resource]([ExtResource("1_7vcj1"), ExtResource("2_u7uvb"), ExtResource("3_u7uvb"), ExtResource("4_1nmxk"), ExtResource("5_ljb2x"), ExtResource("6_seuvu"), ExtResource("7_fmwex"), ExtResource("8_c8m8m"), ExtResource("9_14sjf"), ExtResource("10_xik3w"), ExtResource("11_dgiqm"), ExtResource("12_1teik"), ExtResource("13_f0hti"), ExtResource("14_6ld6e"), ExtResource("15_g8j5j"), ExtResource("16_7h4of"), ExtResource("17_m3sbm"), ExtResource("18_m3sbm"), ExtResource("19_hvhb8"), ExtResource("20_3v5us"), ExtResource("21_g67cj"), ExtResource("22_iy67w"), ExtResource("23_b5lmu"), ExtResource("24_ndas4"), ExtResource("25_n7wsi"), ExtResource("26_v48k5"), ExtResource("27_ombvk"), ExtResource("28_31lma"), ExtResource("29_louv0"), ExtResource("30_wfgfu"), ExtResource("31_elv2e"), ExtResource("32_elv2e"), ExtResource("33_aawmv"), ExtResource("34_wy0ht"), ExtResource("35_3jqmy"), ExtResource("36_p5b6l"), ExtResource("37_53o7h"), ExtResource("38_mdgca"), ExtResource("39_d6b4f"), ExtResource("40_l3pck")])
entity_definitions = Array[Resource]([ExtResource("1_7vcj1"), ExtResource("2_u7uvb"), ExtResource("3_u7uvb"), ExtResource("4_1nmxk"), ExtResource("5_ljb2x"), ExtResource("6_seuvu"), ExtResource("7_fmwex"), ExtResource("8_c8m8m"), ExtResource("9_14sjf"), ExtResource("10_xik3w"), ExtResource("11_dgiqm"), ExtResource("12_1teik"), ExtResource("13_f0hti"), ExtResource("14_6ld6e"), ExtResource("15_g8j5j"), ExtResource("16_7h4of"), ExtResource("17_m3sbm"), ExtResource("18_m3sbm"), ExtResource("19_hvhb8"), ExtResource("20_3v5us"), ExtResource("21_g67cj"), ExtResource("22_iy67w"), ExtResource("23_b5lmu"), ExtResource("24_ndas4"), ExtResource("25_n7wsi"), ExtResource("26_v48k5"), ExtResource("27_ombvk"), ExtResource("28_31lma"), ExtResource("29_louv0"), ExtResource("30_wfgfu"), ExtResource("31_elv2e"), ExtResource("32_elv2e"), ExtResource("33_aawmv"), ExtResource("34_wy0ht"), ExtResource("35_3jqmy"), ExtResource("36_p5b6l"), ExtResource("37_53o7h"), ExtResource("38_mdgca"), ExtResource("39_d6b4f"), ExtResource("40_l3pck"), ExtResource("41_q8hab")])
metadata/_custom_type_script = "uid://cknmd0lgmorx2"

View file

@ -0,0 +1,18 @@
[gd_resource type="Resource" script_class="BulletScript3D" load_steps=6 format=3 uid="uid://cfhjwydjjjxat"]
[ext_resource type="Resource" uid="uid://qrqsywgiij7i" path="res://Resources/Bullets/3D/simple_enemy_bullet_small_3D.tres" id="1_hnqww"]
[ext_resource type="Script" uid="uid://b5s5mjuk1rng5" path="res://Scripts/Resources/TimeModifier.cs" id="2_q5dwt"]
[ext_resource type="Script" uid="uid://bxiprx5nwmpnu" path="res://Scripts/AttackPatterns/ShootingPattern3D.cs" id="3_ko0d0"]
[ext_resource type="Script" uid="uid://w8hcpu68ssq" path="res://Scripts/Resources/BulletScripts/BulletScript3D.cs" id="4_hhjh3"]
[sub_resource type="Resource" id="Resource_7yyul"]
script = ExtResource("3_ko0d0")
BulletResource = ExtResource("1_hnqww")
UseParentRotationOffset = true
spread = 180.0
metadata/_custom_type_script = "uid://bxiprx5nwmpnu"
[resource]
script = ExtResource("4_hhjh3")
Patterns = Array[Object]([SubResource("Resource_7yyul")])
metadata/_custom_type_script = "uid://w8hcpu68ssq"

View file

@ -17,6 +17,7 @@ public partial class ShootingPattern3D : AttackPattern
[Export] public int bulletCount = 16;
[Export] public float rotationSpeed = 0f;
[Export] public bool UseParentRotationOffset { get; set; } = false;
[Export] public float _rotationOffset = 0f;
[Export] public float duration = 5f;
[Export] public float spread = 360f;
@ -184,6 +185,12 @@ public partial class ShootingPattern3D : AttackPattern
Vector2 direction = pattern.BulletResource.Direction;
// Rotate with parent rotation
if (pattern.UseParentRotationOffset)
{
direction = direction.Rotated(-ScriptHost.ParentObject.GlobalRotation.Y + Mathf.DegToRad(90));
}
// TODO: Fix player aiming for 3D
if (pattern._targetPlayer && GameController.Instance.PlayerPosition.HasValue)
{

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)
{

View file

@ -4,8 +4,9 @@ namespace Cirno.Scripts.Utils;
public static class ActivationHelper
{
public static void UseTargets(Node activator, string target, ActivationType activationType = ActivationType.Toggle)
public static bool UseTargets(Node activator, string target, ActivationType activationType = ActivationType.Toggle)
{
var res = false;
GD.Print($"Trying to use targets called: {target}");
var targetList = activator.GetTree().GetNodesInGroup(target);
foreach (var t in targetList)
@ -15,8 +16,10 @@ public static class ActivationHelper
if (t is IActivable activable)
{
GD.Print($"Activating {t.Name}");
activable.Activate(activationType);
res |= activable.Activate(activationType);
}
}
return res;
}
}

View file

@ -332,9 +332,13 @@ public partial class Bullet3D : Area3D, IBullet
Destroy();
}
private readonly StringName SolidGroup = "Solid";
private readonly StringName PermeableGroup = "Permeable";
private readonly StringName DestroyableGroup = "Destroyable";
private void _on_body_entered(Node3D body)
{
if (body.IsInGroup("Destroyable") && body is IDestructible destructible &&
if (body.IsInGroup(DestroyableGroup) && body is IDestructible destructible &&
CanHit(BulletOwner, destructible.BulletGroup))
{
// hit
@ -344,7 +348,7 @@ public partial class Bullet3D : Area3D, IBullet
return;
}
if (body.IsInGroup("Solid"))
if (body.IsInGroup(SolidGroup) && !body.IsInGroup(PermeableGroup))
{
//Debug.WriteLine("Collision");
RequestCollisionDestruction();

View file

@ -175,6 +175,7 @@ Acid=""
Destroyable=""
navigation_polygon_source_geometry_group=""
navigation_mesh_source_group=""
Permeable="Bullets pass through"
[importer_defaults]