mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-06 15:35:54 +00:00
Directional computers
This commit is contained in:
parent
72ce9fb932
commit
7ec45b56b1
13 changed files with 164 additions and 46 deletions
|
|
@ -1,11 +1,13 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Components;
|
||||
using Cirno.Scripts.Enums;
|
||||
|
||||
public partial class Chair : StaticBody2D
|
||||
public partial class Chair : StaticBody2D, IIRotateable
|
||||
{
|
||||
[Export]
|
||||
public ChairDirection Direction { get; private set; } = ChairDirection.Down;
|
||||
public Direction Direction { get; set; } = Direction.Down;
|
||||
|
||||
private AnimatedSprite2D _animatedSprite;
|
||||
|
||||
|
|
@ -20,7 +22,7 @@ public partial class Chair : StaticBody2D
|
|||
{
|
||||
_animatedSprite = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
|
||||
|
||||
_animatedSprite.Play(Direction.ToString());
|
||||
//_animatedSprite.Play(Direction.ToString());
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
|
|
@ -44,13 +46,5 @@ public partial class Chair : StaticBody2D
|
|||
_timer = 0;
|
||||
}
|
||||
|
||||
|
||||
public enum ChairDirection
|
||||
{
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
13
Scripts/Actors/Computer.cs
Normal file
13
Scripts/Actors/Computer.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
using Cirno.Scripts.Components;
|
||||
using Cirno.Scripts.Enums;
|
||||
using Cirno.Scripts.Interactables;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
public partial class Computer : Switch, IIRotateable
|
||||
{
|
||||
[Export]
|
||||
public Direction Direction { get; set; } = Direction.Down;
|
||||
|
||||
}
|
||||
1
Scripts/Actors/Computer.cs.uid
Normal file
1
Scripts/Actors/Computer.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ck54glo7xbuq8
|
||||
8
Scripts/Components/IIRotateable.cs
Normal file
8
Scripts/Components/IIRotateable.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
using Cirno.Scripts.Enums;
|
||||
|
||||
namespace Cirno.Scripts.Components;
|
||||
|
||||
public interface IIRotateable
|
||||
{
|
||||
public Direction Direction { get; set; }
|
||||
}
|
||||
16
Scripts/Components/SpriteAnimationStartupRotator.cs
Normal file
16
Scripts/Components/SpriteAnimationStartupRotator.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using Cirno.Scripts.Enums;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components;
|
||||
|
||||
public partial class SpriteAnimationStartupRotator : AnimatedSprite2D
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
var parent = GetParent<IIRotateable>();
|
||||
|
||||
var sprite = GetParent().GetNode<AnimatedSprite2D>("AnimatedSprite2D");
|
||||
|
||||
sprite.Play(parent.Direction.ToString());
|
||||
}
|
||||
}
|
||||
1
Scripts/Components/SpriteAnimationStartupRotator.cs.uid
Normal file
1
Scripts/Components/SpriteAnimationStartupRotator.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://rlevd6krqglv
|
||||
9
Scripts/Enums/Direction.cs
Normal file
9
Scripts/Enums/Direction.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
namespace Cirno.Scripts.Enums;
|
||||
|
||||
public enum Direction
|
||||
{
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue