mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Boss teleporter
This commit is contained in:
parent
d5eda3c7b4
commit
a1e87af061
10 changed files with 178 additions and 13 deletions
72
Scripts/Actors/TeleporterMarker.cs
Normal file
72
Scripts/Actors/TeleporterMarker.cs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
using Cirno.Scripts.Activables;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
[Tool]
|
||||
public partial class TeleporterMarker : FeatureMarker
|
||||
{
|
||||
private Texture2D _markerTexture;
|
||||
private Teleporter _spawnedTeleporter;
|
||||
public Teleporter SpawnedTeleporter => _spawnedTeleporter;
|
||||
|
||||
[Export]
|
||||
public TeleporterMarkerType Type { get; set; }
|
||||
|
||||
[Export]
|
||||
public Texture2D MarkerTexture
|
||||
{
|
||||
get => _markerTexture;
|
||||
set
|
||||
{
|
||||
_markerTexture = value;
|
||||
if (Engine.IsEditorHint())
|
||||
{
|
||||
QueueRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Draw()
|
||||
{
|
||||
if (!Engine.IsEditorHint()) return;
|
||||
if (MarkerTexture is null) return;
|
||||
|
||||
DrawTexture(MarkerTexture, -new Vector2(MarkerTexture.GetWidth() / 2f, MarkerTexture.GetHeight() / 2f));
|
||||
}
|
||||
|
||||
public TeleporterMarker Spawn(RogueliteMapTheme mapTheme)
|
||||
{
|
||||
if (Engine.IsEditorHint()) return null;
|
||||
if (_spawnedTeleporter is not null) return this;
|
||||
|
||||
_spawnedTeleporter = this.CreateSibling<Teleporter>(mapTheme.TeleporterPrefab);
|
||||
|
||||
if (Type is TeleporterMarkerType.Receiver or TeleporterMarkerType.Start)
|
||||
{
|
||||
_spawnedTeleporter.IsEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_spawnedTeleporter.IsEnabled = true;
|
||||
}
|
||||
|
||||
if (Type is TeleporterMarkerType.InvisibleReceiver)
|
||||
{
|
||||
_spawnedTeleporter.Invisible = true;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public enum TeleporterMarkerType
|
||||
{
|
||||
Receiver,
|
||||
InvisibleReceiver,
|
||||
Start,
|
||||
BranchReturn,
|
||||
Boss,
|
||||
NextLevel
|
||||
}
|
||||
1
Scripts/Actors/TeleporterMarker.cs.uid
Normal file
1
Scripts/Actors/TeleporterMarker.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://g6oraxgd87ij
|
||||
Loading…
Add table
Add a link
Reference in a new issue