mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-12 11:35:54 +00:00
Enemy spawning
This commit is contained in:
parent
ede8f2028a
commit
29dc9bebe0
20 changed files with 564 additions and 105 deletions
124
Scripts/Actors/PreviewMarker3D.cs
Normal file
124
Scripts/Actors/PreviewMarker3D.cs
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
[Tool]
|
||||
public partial class PreviewMarker3D : Marker3D
|
||||
{
|
||||
private Texture2D _texture;
|
||||
protected Texture2D Texture
|
||||
{
|
||||
get => _texture;
|
||||
set
|
||||
{
|
||||
_texture = value;
|
||||
if (Engine.IsEditorHint())
|
||||
{
|
||||
QueueRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _fixedSize;
|
||||
private bool _billboard;
|
||||
private float _pixelSize = 0.1f;
|
||||
|
||||
[Export]
|
||||
protected bool FixedSize
|
||||
{
|
||||
get => _fixedSize;
|
||||
set
|
||||
{
|
||||
_fixedSize = value;
|
||||
if (Engine.IsEditorHint())
|
||||
{
|
||||
QueueRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Export]
|
||||
protected bool Billboard
|
||||
{
|
||||
get => _billboard;
|
||||
set
|
||||
{
|
||||
_billboard = value;
|
||||
if (Engine.IsEditorHint())
|
||||
{
|
||||
QueueRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Export]
|
||||
protected float PixelSize
|
||||
{
|
||||
get => _pixelSize;
|
||||
set
|
||||
{
|
||||
_pixelSize = value;
|
||||
if (Engine.IsEditorHint())
|
||||
{
|
||||
QueueRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ExportToolButton("Update Icon")] public Callable RedrawButton => Callable.From(Redraw);
|
||||
[ExportToolButton("Clear Children")] public Callable ClearChildrenButton => Callable.From(ClearChildren);
|
||||
private Sprite3D _sprite;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_sprite = GetNodeOrNull<Sprite3D>("Sprite3D");
|
||||
ClearChildren();
|
||||
if (Engine.IsEditorHint())
|
||||
{
|
||||
QueueRedraw();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void Redraw()
|
||||
{
|
||||
QueueRedraw();
|
||||
}
|
||||
|
||||
private void ClearChildren()
|
||||
{
|
||||
var children = GetChildren();
|
||||
foreach (var child in children)
|
||||
{
|
||||
if (child is Sprite3D)
|
||||
{
|
||||
child.QueueFree();
|
||||
}
|
||||
}
|
||||
|
||||
_sprite = null;
|
||||
}
|
||||
|
||||
protected void QueueRedraw()
|
||||
{
|
||||
if (!Engine.IsEditorHint()) return;
|
||||
if (_texture is null) return;
|
||||
|
||||
if (_sprite is null)
|
||||
{
|
||||
GD.Print("Remaking sprite");
|
||||
_sprite = new EditorSprite3D();
|
||||
this.AddChild(_sprite);
|
||||
//_sprite.Owner = GetTree().EditedSceneRoot;
|
||||
}
|
||||
|
||||
_sprite.Texture = _texture;
|
||||
//_sprite.SetRotationDegrees(new Vector3(-45, 45, 0));
|
||||
_sprite.FixedSize = FixedSize;
|
||||
_sprite.SetBillboardMode(Billboard ? BaseMaterial3D.BillboardModeEnum.Enabled : BaseMaterial3D.BillboardModeEnum.Disabled);
|
||||
_sprite.TextureFilter = BaseMaterial3D.TextureFilterEnum.Nearest;
|
||||
_sprite.PixelSize = PixelSize;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue