Destroyable props

This commit is contained in:
Marco 2025-06-19 17:55:23 +02:00
commit 44ebc70448
52 changed files with 1387 additions and 18428 deletions

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bvsqbnv88wp56"
path="res://.godot/imported/VendingMachine_Texture_emission.png-cde28a10e5003be2454f6273ef5a0ef1.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://3D/BlockbenchModels/VendingMachine/VendingMachine_Texture_emission.png"
dest_files=["res://.godot/imported/VendingMachine_Texture_emission.png-cde28a10e5003be2454f6273ef5a0ef1.ctex"]
[params]
compress/mode=3
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

File diff suppressed because one or more lines are too long

View file

@ -2708,3 +2708,92 @@
"classname" "actor_box_red"
"origin" "148 456 20"
}
// entity 147
{
"classname" "func_group"
"_tb_type" "_tb_group"
"_tb_name" "Test_Light"
"_tb_id" "26"
"_tb_linked_group_id" "{a3f87a51-b8d8-4332-b3f4-320cf7ca7017}"
// brush 0
{
( 136 428 16 ) ( 136 429 16 ) ( 136 428 17 ) Manual/Wall_Light_Test [ 0 -1 0 -4 ] [ 0 0 -1 0 ] 90 1 1
( 136 428 16 ) ( 136 428 17 ) ( 137 428 16 ) Manual/Wall_Light_Test [ 1 0 0 -4 ] [ 0 0 -1 0 ] 90 1 1
( 136 428 16 ) ( 137 428 16 ) ( 136 429 16 ) Manual/Wall_Light_Test [ -1 0 0 4 ] [ 0 -1 0 -4 ] 90 1 1
( 140 444 48 ) ( 140 445 48 ) ( 141 444 48 ) Manual/Wall_Light_Test [ 1 0 0 -4 ] [ 0 -1 0 -4 ] 270 1 1
( 140 444 20 ) ( 141 444 20 ) ( 140 444 21 ) Manual/Wall_Light_Test [ -1 0 0 4 ] [ 0 0 -1 0 ] 90 1 1
( 140 444 20 ) ( 140 444 21 ) ( 140 445 20 ) Manual/Wall_Light_Test [ 0 1 0 4 ] [ 0 0 -1 0 ] 90 1 1
}
}
// entity 148
{
"classname" "func_group"
"_tb_type" "_tb_group"
"_tb_name" "Test_Light"
"_tb_id" "27"
"_tb_linked_group_id" "{a3f87a51-b8d8-4332-b3f4-320cf7ca7017}"
"_tb_transformation" "1 0 0 80 0 1 0 -48 0 0 1 0 0 0 0 1"
// brush 0
{
( 216 380 16 ) ( 216 381 16 ) ( 216 380 17 ) Manual/Wall_Light_Test [ 0 -1 0 -4 ] [ 0 0 -1 0 ] 270 1 1
( 216 380 16 ) ( 216 380 17 ) ( 217 380 16 ) Manual/Wall_Light_Test [ 1 0 0 12 ] [ 0 0 -1 0 ] 270 1 1
( 216 380 16 ) ( 217 380 16 ) ( 216 381 16 ) Manual/Wall_Light_Test [ -1 0 0 -12 ] [ 0 -1 0 -4 ] 270 1 1
( 220 396 48 ) ( 220 397 48 ) ( 221 396 48 ) Manual/Wall_Light_Test [ 1 0 0 12 ] [ 0 -1 0 -4 ] 90 1 1
( 220 396 20 ) ( 221 396 20 ) ( 220 396 21 ) Manual/Wall_Light_Test [ -1 0 0 -12 ] [ 0 0 -1 0 ] 270 1 1
( 220 396 20 ) ( 220 396 21 ) ( 220 397 20 ) Manual/Wall_Light_Test [ 0 1 0 4 ] [ 0 0 -1 0 ] 270 1 1
}
}
// entity 149
{
"classname" "func_group"
"_tb_type" "_tb_group"
"_tb_name" "Test_Light"
"_tb_id" "28"
"_tb_linked_group_id" "{a3f87a51-b8d8-4332-b3f4-320cf7ca7017}"
"_tb_transformation" "1 0 0 80 0 1 0 -32 0 0 1 0 0 0 0 1"
// brush 0
{
( 216 396 16 ) ( 216 397 16 ) ( 216 396 17 ) Manual/Wall_Light_Test [ 0 -1 0 -4 ] [ 0 0 -1 0 ] 90 1 1
( 216 396 16 ) ( 216 396 17 ) ( 217 396 16 ) Manual/Wall_Light_Test [ 1 0 0 12 ] [ 0 0 -1 0 ] 90 1 1
( 216 396 16 ) ( 217 396 16 ) ( 216 397 16 ) Manual/Wall_Light_Test [ -1 0 0 -12 ] [ 0 -1 0 -4 ] 90 1 1
( 220 412 48 ) ( 220 413 48 ) ( 221 412 48 ) Manual/Wall_Light_Test [ 1 0 0 12 ] [ 0 -1 0 -4 ] 270 1 1
( 220 412 20 ) ( 221 412 20 ) ( 220 412 21 ) Manual/Wall_Light_Test [ -1 0 0 -12 ] [ 0 0 -1 0 ] 90 1 1
( 220 412 20 ) ( 220 412 21 ) ( 220 413 20 ) Manual/Wall_Light_Test [ 0 1 0 4 ] [ 0 0 -1 0 ] 90 1 1
}
}
// entity 150
{
"classname" "func_group"
"_tb_type" "_tb_group"
"_tb_name" "Test_Light"
"_tb_id" "29"
"_tb_linked_group_id" "{a3f87a51-b8d8-4332-b3f4-320cf7ca7017}"
"_tb_transformation" "1 0 0 128 0 1 0 -48 0 0 1 0 0 0 0 1"
// brush 0
{
( 264 380 16 ) ( 264 381 16 ) ( 264 380 17 ) Manual/Wall_Light_Test [ 0 -1 0 12 ] [ 0 0 -1 0 ] 0 1 1
( 264 380 16 ) ( 264 380 17 ) ( 265 380 16 ) Manual/Wall_Light_Test [ 1 0 0 -4 ] [ 0 0 -1 0 ] 0 1 1
( 264 380 16 ) ( 265 380 16 ) ( 264 381 16 ) Manual/Wall_Light_Test [ -1 0 0 4 ] [ 0 -1 0 12 ] 0 1 1
( 268 396 48 ) ( 268 397 48 ) ( 269 396 48 ) Manual/Wall_Light_Test [ 1 0 0 -4 ] [ 0 -1 0 12 ] 180 1 1
( 268 396 20 ) ( 269 396 20 ) ( 268 396 21 ) Manual/Wall_Light_Test [ -1 0 0 4 ] [ 0 0 -1 0 ] 0 1 1
( 268 396 20 ) ( 268 396 21 ) ( 268 397 20 ) Manual/Wall_Light_Test [ 0 1 0 -12 ] [ 0 0 -1 0 ] 0 1 1
}
}
// entity 151
{
"classname" "func_group"
"_tb_type" "_tb_group"
"_tb_name" "Test_Light"
"_tb_id" "30"
"_tb_linked_group_id" "{a3f87a51-b8d8-4332-b3f4-320cf7ca7017}"
"_tb_transformation" "1 0 0 160 0 1 0 303.99999999999994 0 0 1 0 0 0 0 1"
// brush 0
{
( 296 732 16 ) ( 296 733 16 ) ( 296 732 17 ) Manual/Wall_Light_Test [ 0 -1 0 -4 ] [ 0 0 -1 0 ] 0 1 1
( 296 732 16 ) ( 296 732 17 ) ( 297 732 16 ) Manual/Wall_Light_Test [ 1 0 0 12 ] [ 0 0 -1 0 ] 0 1 1
( 296 732 16 ) ( 297 732 16 ) ( 296 733 16 ) Manual/Wall_Light_Test [ -1 0 0 -12 ] [ 0 -1 0 -4 ] 0 1 1
( 300 748 48 ) ( 300 749 48 ) ( 301 748 48 ) Manual/Wall_Light_Test [ 1 0 0 12 ] [ 0 -1 0 -4 ] 180 1 1
( 300 748 20 ) ( 301 748 20 ) ( 300 748 21 ) Manual/Wall_Light_Test [ -1 0 0 -12 ] [ 0 0 -1 0 ] 0 1 1
( 300 748 20 ) ( 300 748 21 ) ( 300 749 20 ) Manual/Wall_Light_Test [ 0 1 0 4 ] [ 0 0 -1 0 ] 0 1 1
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -6,6 +6,7 @@
size = Vector3(0.994617, 1.07367, 0.540756)
[node name="AcUnit" type="StaticBody3D"]
collision_layer = 16
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00414919, 0.0126071, -0.00992589)

View file

@ -1,11 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://br01ww57uaky5"]
[gd_scene load_steps=4 format=3 uid="uid://br01ww57uaky5"]
[ext_resource type="Script" uid="uid://ccxnvbthsvka3" path="res://Scripts/Actors/Destructible3D.cs" id="1_hsg1w"]
[ext_resource type="PackedScene" uid="uid://hxn4awevjyui" path="res://3D/BlockbenchModels/Box/Box_Blue.gltf" id="1_ropdl"]
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
size = Vector3(0.763428, 0.469452, 0.77832)
[node name="BoxBlue" type="StaticBody3D"]
[node name="BoxBlue" type="StaticBody3D" groups=["Destroyable"]]
collision_layer = 16
collision_mask = 0
script = ExtResource("1_hsg1w")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00549316, 0.0253752, -0.000488281)

View file

@ -1,11 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://c8wwioforxms3"]
[gd_scene load_steps=4 format=3 uid="uid://c8wwioforxms3"]
[ext_resource type="PackedScene" uid="uid://c5k6rsawax3gf" path="res://3D/BlockbenchModels/Box/Box_Green.gltf" id="1_03sp0"]
[ext_resource type="Script" uid="uid://ccxnvbthsvka3" path="res://Scripts/Actors/Destructible3D.cs" id="1_e6kl3"]
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
size = Vector3(0.763428, 0.469452, 0.77832)
[node name="BoxBlue" type="StaticBody3D"]
[node name="BoxBlue" type="StaticBody3D" groups=["Destroyable"]]
collision_layer = 16
collision_mask = 0
script = ExtResource("1_e6kl3")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00549316, 0.0253752, -0.000488281)

View file

@ -1,11 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://jffyxmft3nbw"]
[gd_scene load_steps=4 format=3 uid="uid://jffyxmft3nbw"]
[ext_resource type="PackedScene" uid="uid://ninnis3a3jbn" path="res://3D/BlockbenchModels/Box/Box_Red.gltf" id="1_fi646"]
[ext_resource type="Script" uid="uid://ccxnvbthsvka3" path="res://Scripts/Actors/Destructible3D.cs" id="1_kvqx7"]
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
size = Vector3(0.763428, 0.469452, 0.77832)
[node name="BoxRed" type="StaticBody3D"]
[node name="BoxRed" type="StaticBody3D" groups=["Destroyable"]]
collision_layer = 16
collision_mask = 0
script = ExtResource("1_kvqx7")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00549316, 0.0253752, -0.000488281)

View file

@ -1,11 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://c6cdl3y3i3axl"]
[gd_scene load_steps=4 format=3 uid="uid://c6cdl3y3i3axl"]
[ext_resource type="PackedScene" uid="uid://cpwolnoq46foq" path="res://3D/BlockbenchModels/Box/Box_Yellow.gltf" id="1_0rxnx"]
[ext_resource type="Script" uid="uid://ccxnvbthsvka3" path="res://Scripts/Actors/Destructible3D.cs" id="1_l0sp5"]
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
size = Vector3(0.763428, 0.469452, 0.77832)
[node name="BoxBlue" type="StaticBody3D"]
[node name="BoxBlue" type="StaticBody3D" groups=["Destroyable"]]
collision_layer = 16
collision_mask = 0
script = ExtResource("1_l0sp5")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00549316, 0.0253752, -0.000488281)

View file

@ -6,6 +6,7 @@
size = Vector3(0.796058, 1.47291, 0.740692)
[node name="Capacitor" type="StaticBody3D"]
collision_layer = 16
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00640631, 0.29627, 0.0265655)

View file

@ -6,7 +6,7 @@
height = 0.882874
[node name="BoxBlue" type="StaticBody3D"]
collision_layer = 17
collision_layer = 16
collision_mask = 0
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]

View file

@ -1,10 +1,14 @@
[gd_scene load_steps=3 format=3 uid="uid://bubtvv3pa06py"]
[gd_scene load_steps=4 format=3 uid="uid://bubtvv3pa06py"]
[ext_resource type="PackedScene" uid="uid://b12y0mtx6ibo8" path="res://3D/BlockbenchModels/Door/Door.gltf" id="1_7axon"]
[sub_resource type="AnimationLibrary" id="AnimationLibrary_y1ovr"]
[node name="Door3d" type="Node3D"]
[sub_resource type="BoxShape3D" id="BoxShape3D_7axon"]
size = Vector3(1.99927, 2.00482, 0.140869)
[node name="Door3d" type="AnimatableBody3D"]
collision_layer = 16
[node name="blockbench_export" parent="." instance=ExtResource("1_7axon")]
@ -12,3 +16,7 @@
libraries = {
&"": SubResource("AnimationLibrary_y1ovr")
}
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00500488, 0.00234985, -0.00524902)
shape = SubResource("BoxShape3D_7axon")

View file

@ -14,6 +14,7 @@ point_count = 2
[node name="Door" type="Path3D" node_paths=PackedStringArray("Elevator")]
curve = SubResource("Curve3D_dobkm")
script = ExtResource("1_dobkm")
TargetName = &""
Elevator = NodePath("PathFollow3D")
[node name="PathFollow3D" type="PathFollow3D" parent="."]

View file

@ -6,7 +6,8 @@
height = 0.160095
radius = 0.44043
[node name="TubeJunction" type="StaticBody3D"]
[node name="TubeJunction" type="StaticBody3D" groups=["Solid"]]
collision_mask = 0
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.109167, -0.239903, -0.1134)

View file

@ -5,7 +5,8 @@
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
size = Vector3(1.01587, 0.868431, 0.871704)
[node name="TubeJunction" type="StaticBody3D"]
[node name="TubeJunction" type="StaticBody3D" groups=["Solid"]]
collision_mask = 0
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00793457, 0.00475672, 0.0043335)

View file

@ -5,7 +5,7 @@
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
size = Vector3(1.01587, 0.868431, 0.871704)
[node name="TubeStraight" type="StaticBody3D"]
[node name="TubeStraight" type="StaticBody3D" groups=["Solid"]]
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00793457, 0.00475672, 0.0043335)

View file

@ -1,11 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://d2kqcbr5rufxb"]
[gd_scene load_steps=4 format=3 uid="uid://d2kqcbr5rufxb"]
[ext_resource type="PackedScene" uid="uid://etmm2bm8mj06" path="res://3D/BlockbenchModels/WoodenBox/Wooden_Box.gltf" id="1_2t24b"]
[ext_resource type="Script" uid="uid://ccxnvbthsvka3" path="res://Scripts/Actors/Destructible3D.cs" id="1_nnmn3"]
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
size = Vector3(1, 0.498138, 0.543457)
[node name="BoxTest" type="StaticBody3D"]
[node name="BoxTest" type="StaticBody3D" groups=["Destroyable"]]
collision_layer = 16
collision_mask = 0
script = ExtResource("1_nnmn3")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0022127, -0.0178223)

View file

@ -6,6 +6,7 @@
size = Vector3(2.05377, 0.101501, 2.00244)
[node name="Elevator" type="AnimatableBody3D"]
collision_layer = 16
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00820923, 0.0038147, -0.000732422)

View file

@ -40,6 +40,7 @@ radius = 1.5708
[node name="IsoPlayerFsm" type="CharacterBody3D" node_paths=PackedStringArray("PlayerFSM")]
collision_layer = 2
collision_mask = 17
script = ExtResource("1_cc7e7")
PlayerFSM = NodePath("StateMachine")

View file

@ -86,7 +86,7 @@ public partial class Barrel : Area2D, IDestructible
//var explosion = this.CreateSibling<Bullet>(ExplosionData.BulletScene);
explosion.Speed = 0;
explosion.Initialize(ExplosionData.MakeBullet(this.GlobalPosition), _gameManager);
explosion.Initialize(ExplosionData.MakeBullet(this.GlobalPosition));
}
private void ApplyExplosionDamage()

View file

@ -0,0 +1,150 @@
using System.Linq;
using Cirno.Scripts.Controllers;
using Cirno.Scripts.Resources;
using Cirno.Scripts.Utils;
using Cirno.Scripts.Weapons;
using Godot;
using Godot.Collections;
namespace Cirno.Scripts.Actors;
public partial class Destructible3D : StaticBody3D, IDestructible
{
[Export] public bool Indestructible { get; private set; }
[Export] public float Health = 1f;
[Export] public PackedScene DebrisScene { get; set; }
[Export] public PackedScene ExplosionParticles { get; set; }
[Export] public BulletResource ExplosionData { get; set; }
[Export] public BulletOwner BulletGroup { get; set; } = BulletOwner.None;
[Export] public Array<DamageResistance> DamageResistances { get; set; } = [];
[ExportCategory("On Death Activation")]
[Export]
public ActivationType ActivationType { get; private set; } = ActivationType.Toggle;
[Export]
public Node Target { get; private set;}
[Signal]
public delegate void ExplodedEventHandler();
private float _currentHealth = 0f;
private bool _isDestroyed = false;
public override void _Ready()
{
_currentHealth = Health;
}
private void Explode()
{
//ApplyExplosionDamage();
EmitSignal(SignalName.Exploded, this, _currentHealth);
ActivateOnDeath();
CreateExplosion();
CreateParticles();
CreateDebris();
QueueFree();
//GameManager.Instance.RebakeNavigation();
//GameManager.Instance.RecalculateTilemap(this.GlobalPosition);
}
private void ActivateOnDeath()
{
if (Target is IActivable node)
{
node.Activate(ActivationType);
}
}
private void CreateExplosion()
{
if (ExplosionData == null) return;
var explosion = PoolingManager.Instance.SpawnBullet<Bullet3D>(ExplosionData);
explosion.GlobalPosition = this.GlobalPosition;
explosion.Speed = 0;
explosion.Initialize(ExplosionData.MakeBullet(new Vector2(this.GlobalPosition.X, this.GlobalPosition.Y)));
}
// private void ApplyExplosionDamage()
// {
// var spaceState = GetWorld2D().DirectSpaceState;
// var query = new PhysicsShapeQueryParameters2D();
// var shape = new CircleShape2D { Radius = ExplosionRadius };
//
// query.SetShape(shape);
// query.Transform = new Transform2D(0, GlobalPosition);
// query.CollideWithBodies = false;
// query.CollideWithAreas = true;
// //query.CollisionMask = ;
//
// var results = spaceState.IntersectShape(query);
//
// GD.Print($"Shapes in range: {results.Count}");
//
// foreach (var result in results)
// {
// if (result.TryGetValue("collider", out var colliderObj))
// {
//
// var collider = colliderObj.As<Node2D>();
//
//
// if (collider.GetParent<Area2D>() is IDestructible destructible)
// {
// GD.Print($"HITTING {collider.Name}");
// destructible.Hit(ExplosionDamage);
// }
// else {
// GD.Print($"Collider {collider.Name} was not idestructible");
// }
// }
// }
// }
private void CreateDebris()
{
if (DebrisScene == null) return;
this.CreateSibling<Destructible3D>(DebrisScene);
}
private void CreateParticles()
{
if (ExplosionParticles == null) {
return;
}
var particle = this.CreateSibling<GpuParticles3D>(ExplosionParticles);
if (particle == null) return;
particle.Emitting = true;
}
public void Hit(float damage, DamageType damageType = DamageType.Neutral)
{
if (_isDestroyed || Indestructible) return;
var dmg = DamageResistances.Aggregate(damage, (current, resistance) => current * resistance.CalculateDamage(current, damageType));
_currentHealth -= dmg;
if (_currentHealth > 0) return;
_isDestroyed = true;
Explode();
}
public bool IsDestroyed()
{
return _isDestroyed;
}
}

View file

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

View file

@ -51,11 +51,11 @@ public partial class Bullet : Area2D, IBullet
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
}
public void Initialize(BulletInfo bulletInfo, GameManager gameManager)
public void Initialize(BulletInfo bulletInfo)
{
_bulletInfo = bulletInfo;
_gameManager = gameManager;
_gameManager = GameManager.Instance;
_elapsedTime = 0f;

View file

@ -43,7 +43,7 @@ public partial class DeathAnimationHandler : ActorModule
var explosion = _actor.CreateSibling<Bullet>(ExplosionData.BulletScene);
explosion.Speed = 0;
explosion.Initialize(ExplosionData.MakeBullet(_actor.GlobalPosition), GameManager.Instance);
explosion.Initialize(ExplosionData.MakeBullet(_actor.GlobalPosition));
}
private void CreateParticles()

View file

@ -34,7 +34,7 @@ public partial class BulletSpawner : Node2D
bulletInfo = bulletInfo.Modifier.ModifyBullet(bulletInfo, i, bulletInfo.BulletCount);
}
bullet.Initialize(bulletInfo, _gameManager);
bullet.Initialize(bulletInfo);
// float modifiedSpeed = bulletInfo.Modifier?.ModifySpeed(bulletInfo.Speed, i, bulletInfo.BulletCount) ?? bulletInfo.Speed;
// bullet.Speed = modifiedSpeed;

View file

@ -238,7 +238,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
//var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, item.WeaponData.BulletData.BulletScene, this.GlobalPosition);
bullet.Initialize(bulletData, _gameManager);
bullet.Initialize(bulletData);
//bullet.SetDirection(ShootDirection);
bullet.SetDirection(_facingDirection);

View file

@ -25,7 +25,7 @@ public partial class SpiderbombEffectResource : ItemEffectResource
var bulletData = item.WeaponData.MakeBullet(parent.Machine.MainObject.GlobalPosition);
bullet.Initialize(bulletData, GameManager.Instance);
bullet.Initialize(bulletData);
bullet.SetDirection(parent.FacingDirection);
bullet.RotateSpriteDegrees(-90);
//bullet.SetDirection(_facingDirection);

View file

@ -0,0 +1,24 @@
using Godot;
namespace Cirno.Scripts.Utils;
[Tool]
public partial class MapProxy3D : Node3D
{
[ExportToolButton("Rebuild")] public Callable RebuildButton => Callable.From(Rebuild);
public void Rebuild()
{
if (!Engine.IsEditorHint()) return;
var children = GetChildren();
foreach (var child in children)
{
if (child.HasMethod("verify_and_build"))
{
child.Call("verify_and_build");
}
}
}
}

View file

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

64
Scripts/Utils/Tools3D.cs Normal file
View file

@ -0,0 +1,64 @@
using Godot;
namespace Cirno.Scripts.Utils;
public static class Tools3D
{
public static T CreateChild<T>(this Node3D node, PackedScene prefab) where T : Node3D
{
return CreateChild<T>(node, prefab, node.GlobalPosition);
}
public static T CreateChild<T>(this Node3D node, PackedScene prefab, Vector3 position) where T : Node3D
{
return CreateChildOf<T>(node, node, prefab, position);
// if (prefab == null) return null;
// var newInstance = prefab.Instantiate<T>();
// node.GetParent().CallDeferred("add_child", newInstance);
// // Need to use parent instead of owner because tilemap scenes have no owner
// //node.Owner.CallDeferred("add_child", newInstance);
// newInstance.Transform = node.GlobalTransform;
// newInstance.Position = position;
//
// return newInstance;
}
public static T CreateSibling<T>(this Node3D node, PackedScene prefab) where T : Node3D
{
return CreateChildOf<T>(node, node.GetParent<Node3D>(), prefab, node.GlobalPosition);
}
public static T CreateSibling<T>(this Node3D node, PackedScene prefab, Vector3 position) where T : Node3D
{
return CreateChildOf<T>(node, node.GetParent<Node3D>(), prefab, position);
}
public static T CreateChildOf<T>(this Node3D node, Node3D parentNode, PackedScene prefab) where T : Node3D
{
return CreateChildOf<T>(node, parentNode, prefab, node.GlobalPosition);
}
public static T CreateChildOf<T>(this Node3D node, Node3D parentNode, PackedScene prefab, Vector3 position) where T : Node3D
{
if (prefab == null)
{
GD.PrintErr("Tried to instantiate a null prefab");
return null;
}
if (parentNode == null)
{
GD.PrintErr("Tried to instantiate child of a null parent");
return null;
}
var newInstance = prefab.Instantiate<T>();
//node.GetParent().CallDeferred("add_child", newInstance);
parentNode.CallDeferred("add_child", newInstance);
//newInstance.Transform = node.GlobalTransform;
newInstance.Position = parentNode.ToLocal(position);
return newInstance;
}
}

View file

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

View file

@ -189,7 +189,7 @@ public partial class Weapon : Node2D
GetBulletStrengthMultiplier(bulletData.Damage, bulletData.OriginalBulletResource.MaxDamage, 20);
}
bullet.Initialize(bulletData, _gameManager);
bullet.Initialize(bulletData);
//bullet.SetDirection(ShootDirection);
bullet.SetDirection(spreadDirection);

View file

@ -26,8 +26,6 @@ public partial class Bullet3D : Area3D, IBullet
private List<ModifierWrapper> _modifiers = new();
private GameManager _gameManager;
public bool IsGrazed { get; set; } = false;
public bool IsFrozen { get; private set; } = false;
@ -49,11 +47,10 @@ public partial class Bullet3D : Area3D, IBullet
_collisionShape = GetNode<CollisionShape3D>("CollisionShape");
}
public void Initialize(BulletInfo bulletInfo, GameManager gameManager)
public void Initialize(BulletInfo bulletInfo)
{
_bulletInfo = bulletInfo;
_gameManager = gameManager;
_elapsedTime = 0f;
@ -163,12 +160,12 @@ public partial class Bullet3D : Area3D, IBullet
public void FacePlayer()
{
if (_gameManager.Player != null)
{
//_direction = (_gameManager.PlayerPosition.Value - this.GlobalPosition).Normalized();
RotateBullet(0); // quick hack to rotate lasers
//LookAt(player.GlobalPosition);
}
// if (_gameManager.Player != null)
// {
// //_direction = (_gameManager.PlayerPosition.Value - this.GlobalPosition).Normalized();
// RotateBullet(0); // quick hack to rotate lasers
// //LookAt(player.GlobalPosition);
// }
}
@ -236,6 +233,16 @@ public partial class Bullet3D : Area3D, IBullet
private void _on_body_entered(Node3D body)
{
if (body.IsInGroup("Destroyable") && body is IDestructible destructible &&
CanHit(BulletOwner, destructible.BulletGroup))
{
// hit
destructible.Hit(Damage, DamageType);
RequestCollisionDestruction();
return;
}
if (body.IsInGroup("Solid"))
{
//Debug.WriteLine("Collision");

View file

@ -18,7 +18,7 @@ public interface IBullet
public delegate void OnDestroyEventHandler();
public void Initialize(BulletInfo bulletInfo, GameManager gameManager);
public void Initialize(BulletInfo bulletInfo);
public void Enable();
public void Disable(bool hideSprite = true);

View file

@ -182,7 +182,7 @@ public partial class Weapon3D : Node3D
GetBulletStrengthMultiplier(bulletData.Damage, bulletData.OriginalBulletResource.MaxDamage, 20);
}
bullet.Initialize(bulletData, _gameManager);
bullet.Initialize(bulletData);
//bullet.SetDirection(ShootDirection);
bullet.SetDirection(spreadDirection);

View file

@ -410,4 +410,5 @@ common/physics_jitter_fix=0.0
textures/canvas_textures/default_texture_filter=0
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"
occlusion_culling/use_occlusion_culling=true
2d/snap/snap_2d_vertices_to_pixel=true

BIN
textures/Manual/Wall_Light_Test.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
textures/Manual/Wall_Light_Test.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bdkux5ycdch23"
path="res://.godot/imported/Wall_Light_Test.png-83ad9694c7cea8a527345fffdfd9a545.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/Manual/Wall_Light_Test.png"
dest_files=["res://.godot/imported/Wall_Light_Test.png-83ad9694c7cea8a527345fffdfd9a545.ctex"]
[params]
compress/mode=3
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View file

@ -0,0 +1,11 @@
[gd_resource type="StandardMaterial3D" load_steps=3 format=3 uid="uid://fc0n5jo05seu"]
[ext_resource type="Texture2D" uid="uid://bdkux5ycdch23" path="res://textures/Manual/Wall_Light_Test.png" id="1_sys1j"]
[ext_resource type="Texture2D" uid="uid://i7eec28mjnbe" path="res://textures/Manual/Wall_Light_Test_emission.png" id="2_0okc3"]
[resource]
albedo_texture = ExtResource("1_sys1j")
metallic_specular = 0.0
emission_enabled = true
emission_texture = ExtResource("2_0okc3")
texture_filter = 2

BIN
textures/Manual/Wall_Light_Test_emission.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://i7eec28mjnbe"
path="res://.godot/imported/Wall_Light_Test_emission.png-268ce0432bd69b31191aac56b2d258b2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/Manual/Wall_Light_Test_emission.png"
dest_files=["res://.godot/imported/Wall_Light_Test_emission.png-268ce0432bd69b31191aac56b2d258b2.ctex"]
[params]
compress/mode=3
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

BIN
textures/special/trigger.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://sleku10uych1"
path="res://.godot/imported/trigger.png-f879e271e7fabd1268f430358dfe2613.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/special/trigger.png"
dest_files=["res://.godot/imported/trigger.png-f879e271e7fabd1268f430358dfe2613.ctex"]
[params]
compress/mode=3
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0