diff options
Diffstat (limited to 'scripts/actors')
| -rw-r--r-- | scripts/actors/Actor.cs | 10 | ||||
| -rw-r--r-- | scripts/actors/ActorDefinition.cs | 14 | ||||
| -rw-r--r-- | scripts/actors/ActorDefinition.cs.uid | 1 | ||||
| -rw-r--r-- | scripts/actors/actions/MovementAction.cs | 4 |
4 files changed, 26 insertions, 3 deletions
diff --git a/scripts/actors/Actor.cs b/scripts/actors/Actor.cs index 8e33b02..f35939a 100644 --- a/scripts/actors/Actor.cs +++ b/scripts/actors/Actor.cs @@ -2,6 +2,8 @@ using Godot; [GlobalClass] public abstract partial class Actor : Sprite2D { + [Export] + private ActorDefinition definition; private Vector2I gridPosition = Vector2I.Zero; public Vector2I GridPosition { set { @@ -11,6 +13,14 @@ public abstract partial class Actor : Sprite2D { get => gridPosition; } + public bool BlocksMovement { + get => definition.blocksMovement; + } + + public string ActorName { + get => definition.name; + } + public override void _Ready() { base._Ready(); diff --git a/scripts/actors/ActorDefinition.cs b/scripts/actors/ActorDefinition.cs new file mode 100644 index 0000000..58a749c --- /dev/null +++ b/scripts/actors/ActorDefinition.cs @@ -0,0 +1,14 @@ +using Godot; +using System; + +[GlobalClass] +public partial class ActorDefinition : Resource +{ + [ExportCategory("Visuals")] + [Export] + public string name = "unnamed"; + + [ExportCategory("Mechanics")] + [Export] + public bool blocksMovement = true; +} diff --git a/scripts/actors/ActorDefinition.cs.uid b/scripts/actors/ActorDefinition.cs.uid new file mode 100644 index 0000000..ddcfe02 --- /dev/null +++ b/scripts/actors/ActorDefinition.cs.uid @@ -0,0 +1 @@ +uid://crxw1e37xlrrt diff --git a/scripts/actors/actions/MovementAction.cs b/scripts/actors/actions/MovementAction.cs index f29e2e8..8d864bd 100644 --- a/scripts/actors/actions/MovementAction.cs +++ b/scripts/actors/actions/MovementAction.cs @@ -13,9 +13,7 @@ public partial class MovementAction : Action { Vector2I finalDestination = actor.GridPosition + Offset; - TileData tile = game.Dungeon.GetCellTileData(finalDestination); - - if (tile == null || !(bool) tile.GetCustomData("isWalkable")) return; + if (!game.Map.IsTileWalkable(finalDestination)) return; actor.Walk(Offset); } |
