Spinning chairs

This commit is contained in:
Marco 2025-03-10 15:49:28 +01:00
commit 72ce9fb932
16 changed files with 290 additions and 24 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=52 format=4 uid="uid://dqyfnby0t7gu1"]
[gd_scene load_steps=54 format=4 uid="uid://dqyfnby0t7gu1"]
[ext_resource type="Script" uid="uid://doxmbokehw8ci" path="res://Scripts/GameManager.cs" id="1_c3v4x"]
[ext_resource type="Resource" uid="uid://cs3ihltcn2166" path="res://Resources/Items/IcicleGun.tres" id="3_6314l"]
@ -40,7 +40,9 @@
[ext_resource type="PackedScene" uid="uid://dyvrwksve4ulg" path="res://Scenes/Items/Yin_Yang_Gun_Pickup.tscn" id="30_bea3m"]
[ext_resource type="PackedScene" uid="uid://sjxkj5jdndxb" path="res://Scenes/Items/Yin_Yang_Ammo.tscn" id="31_3a4iu"]
[ext_resource type="PackedScene" uid="uid://cnhgvn2salyxl" path="res://Scenes/Items/Icicle_Repeater.tscn" id="32_luw81"]
[ext_resource type="PackedScene" uid="uid://bjb1xv0ny1qim" path="res://Scenes/Props/Chair.tscn" id="33_7ft0s"]
[ext_resource type="Script" uid="uid://bgertv72tq1dt" path="res://Scripts/Components/FSM/NewPlayerStateMachine.cs" id="34_2vu2h"]
[ext_resource type="Script" uid="uid://b5fesrd4lv8t1" path="res://Scripts/Resources/Events/EventResource.cs" id="35_16ubp"]
[ext_resource type="Script" uid="uid://btwuahxvreivs" path="res://Scripts/Components/FSM/Player/NewInit.cs" id="35_mpb62"]
[ext_resource type="Script" uid="uid://dl50bcl8dx3k8" path="res://Scripts/Components/FSM/TestModule.cs" id="36_4rfvg"]
@ -252,9 +254,12 @@ position = Vector2(382, 170)
[node name="IcicleRepeater" parent="Tilemaps/Actors" instance=ExtResource("32_luw81")]
position = Vector2(354, 172)
[node name="Chair" parent="Tilemaps/Actors" instance=ExtResource("33_7ft0s")]
position = Vector2(260, 194)
[node name="ScriptableAreaTrigger" parent="Tilemaps" instance=ExtResource("28_fuxq3")]
position = Vector2(230, 250)
Events = Array[Object]([SubResource("Resource_pgobb")])
Events = Array[ExtResource("35_16ubp")]([SubResource("Resource_pgobb")])
[node name="CameraController" type="Camera2D" parent="."]
process_mode = 1

File diff suppressed because one or more lines are too long

117
Scenes/Props/Chair.tscn Normal file
View file

@ -0,0 +1,117 @@
[gd_scene load_steps=14 format=3 uid="uid://bjb1xv0ny1qim"]
[ext_resource type="Texture2D" uid="uid://c8rj2wjj7ho3j" path="res://Sprites/Props/Chair.png" id="1_a0rvv"]
[ext_resource type="Script" uid="uid://0hfmpf6i0icv" path="res://Scripts/Actors/Chair.cs" id="1_yxrrg"]
[sub_resource type="AtlasTexture" id="AtlasTexture_yxrrg"]
atlas = ExtResource("1_a0rvv")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_eq5fp"]
atlas = ExtResource("1_a0rvv")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_vlpit"]
atlas = ExtResource("1_a0rvv")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_hgjbl"]
atlas = ExtResource("1_a0rvv")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_3qtkp"]
atlas = ExtResource("1_a0rvv")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ge7ok"]
atlas = ExtResource("1_a0rvv")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_t37n8"]
atlas = ExtResource("1_a0rvv")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_fu0sf"]
atlas = ExtResource("1_a0rvv")
region = Rect2(48, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_hgjbl"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_yxrrg")
}],
"loop": true,
"name": &"Down",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_eq5fp")
}],
"loop": true,
"name": &"Left",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_vlpit")
}],
"loop": true,
"name": &"Right",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_hgjbl")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3qtkp")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ge7ok")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_t37n8")
}],
"loop": true,
"name": &"Spin",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_fu0sf")
}],
"loop": true,
"name": &"Up",
"speed": 5.0
}]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_a0rvv"]
size = Vector2(7, 10)
[sub_resource type="CircleShape2D" id="CircleShape2D_yxrrg"]
radius = 5.09902
[node name="Chair" type="StaticBody2D"]
collision_layer = 68
collision_mask = 0
script = ExtResource("1_yxrrg")
SpinTime = 1.0
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_hgjbl")
animation = &"Down"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0.5, -1)
shape = SubResource("RectangleShape2D_a0rvv")
[node name="Area2D" type="Area2D" parent="."]
collision_layer = 64
collision_mask = 8
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("CircleShape2D_yxrrg")
[connection signal="area_entered" from="Area2D" to="." method="OnBulletCollision"]

View file

@ -125,7 +125,7 @@ WaitForCompletion = true
[sub_resource type="Resource" id="Resource_b25hy"]
script = ExtResource("46_i0omr")
TimelineName = "testintro"
TimelineName = &"timeline"
WaitForCompletion = true
[sub_resource type="CircleShape2D" id="CircleShape2D_8wuck"]
@ -133,14 +133,14 @@ WaitForCompletion = true
[sub_resource type="Resource" id="Resource_ji7au"]
resource_local_to_scene = true
script = ExtResource("46_i0omr")
TimelineName = "computer2"
TimelineName = &"timeline"
WaitForCompletion = true
metadata/_custom_type_script = "uid://ddv26x2qilprb"
[sub_resource type="Resource" id="Resource_fasrq"]
resource_local_to_scene = true
script = ExtResource("46_i0omr")
TimelineName = "computer_control_1"
TimelineName = &"timeline"
WaitForCompletion = true
metadata/_custom_type_script = "uid://ddv26x2qilprb"
@ -157,12 +157,12 @@ WaitForCompletion = true
[sub_resource type="Resource" id="Resource_s3g2w"]
script = ExtResource("46_i0omr")
TimelineName = "Mission1_Briefing"
TimelineName = &"timeline"
WaitForCompletion = true
[sub_resource type="Resource" id="Resource_068l7"]
script = ExtResource("46_i0omr")
TimelineName = "rumia_defeat"
TimelineName = &"timeline"
WaitForCompletion = true
[sub_resource type="Resource" id="Resource_l3nop"]
@ -189,7 +189,7 @@ WaitForCompletion = true
[sub_resource type="Resource" id="Resource_b1dht"]
script = ExtResource("46_i0omr")
TimelineName = "Rumia_Intro"
TimelineName = &"timeline"
WaitForCompletion = true
[sub_resource type="Resource" id="Resource_xrgpy"]

34
Scripts/Activables/NPC.cs Normal file
View file

@ -0,0 +1,34 @@
using Cirno.Scripts.Interactables;
using Cirno.Scripts.Resources.Events;
using Godot;
using Godot.Collections;
namespace Cirno.Scripts.Activables;
public partial class NPC : Area2D, IInteractable
{
[Export] public Array<EventResource> Events;
private ScriptableBase _scriptable;
public override void _Ready()
{
_scriptable = new ScriptableBase();
_scriptable.Events = Events;
this.CallDeferred("add_child", _scriptable);
}
public bool Activate(ActivationType activationType = ActivationType.Toggle)
{
_scriptable?.Activate(activationType);
return true;
}
public bool CanActivate()
{
return true;
}
}

View file

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

View file

@ -8,7 +8,7 @@ namespace Cirno.Scripts.Activables;
public partial class ScriptableBase : Node2D, IActivable
{
[Export] public Array<EventResource> Events;
[Export] public Array<EventResource> Events { get; set; } = [];
private EventResource CurrentEvent => Events[_currentEventIndex];

56
Scripts/Actors/Chair.cs Normal file
View file

@ -0,0 +1,56 @@
using Godot;
using System;
using System.Threading.Tasks;
public partial class Chair : StaticBody2D
{
[Export]
public ChairDirection Direction { get; private set; } = ChairDirection.Down;
private AnimatedSprite2D _animatedSprite;
[Export]
public StringName SpinAnimationName = "Spin";
[Export] public float SpinTime { get; private set; } = 4f;
private double _timer = 0f;
public override void _Ready()
{
_animatedSprite = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
_animatedSprite.Play(Direction.ToString());
}
public override void _Process(double delta)
{
if (_animatedSprite.Animation != SpinAnimationName) return;
_timer += delta;
if (_timer >= SpinTime)
{
_timer = 0;
_animatedSprite.SpeedScale = 0;
}
}
private void OnBulletCollision(Area2D area)
{
_animatedSprite.SpeedScale = 1;
_animatedSprite.Play("Spin");
_timer = 0;
}
public enum ChairDirection
{
Up,
Down,
Left,
Right,
}
}

View file

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

View file

@ -5,7 +5,7 @@ namespace Cirno.Scripts.Resources.Events;
[GlobalClass]
public partial class DialogueStartEvent : EventResource
{
[Export] public string TimelineName = "timeline";
[Export] public StringName TimelineName = "timeline";
private Node _dialogic;
private GameManager _gameManager;
private bool _isComplete = false;
@ -27,7 +27,7 @@ public partial class DialogueStartEvent : EventResource
_dialogic.Connect("timeline_ended", Callable.From(OnTimelineEnded));
var dialogicNode =_dialogic.Call("start", TimelineName);
var dialogicNode =_dialogic.Call("start", TimelineName.ToString());
((Node)dialogicNode).ProcessMode = Node.ProcessModeEnum.Always;
_gameManager.ChangeState(GameState.Dialogue);
}

BIN
Sprites/Props/Chair.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Sprites/Props/Chair.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c8rj2wjj7ho3j"
path="res://.godot/imported/Chair.png-71b51e6aaa3ae232f968e10fe552cd20.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Props/Chair.png"
dest_files=["res://.godot/imported/Chair.png-71b51e6aaa3ae232f968e10fe552cd20.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
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=1

BIN
Tilesets/factory.aseprite (Stored with Git LFS)

Binary file not shown.

BIN
Tilesets/factory.png (Stored with Git LFS)

Binary file not shown.

View file

@ -1019,6 +1019,10 @@ texture = ExtResource("1_70kxh")
13:6/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
12:6/0 = 0
12:6/0/physics_layer_1/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
11:11/0 = 0
11:11/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
11:10/0 = 0
11:10/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
[sub_resource type="TileSetScenesCollectionSource" id="TileSetScenesCollectionSource_qg3vu"]
resource_name = "Props"