mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-17 04:03:47 +00:00
Spawn markers in editor
This commit is contained in:
parent
82f4c75ad7
commit
479df3c7c4
8 changed files with 150 additions and 76 deletions
|
|
@ -2,6 +2,7 @@
|
|||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
|
|
@ -52,6 +53,26 @@ public partial class EnemyMarker3D : PreviewMarker3D, IActivable
|
|||
|
||||
private EnemyProxy3D _spawnedEnemy;
|
||||
|
||||
public void _func_godot_apply_properties(Dictionary<string, Variant> props)
|
||||
{
|
||||
//GroupName = (string)props["targetname"];
|
||||
this.AddToGroup("EnemyMarkers");
|
||||
AutoSpawn = props["autospawn"].AsBool();
|
||||
|
||||
var scriptPath = props["resource_path"].AsString();
|
||||
if (!string.IsNullOrWhiteSpace(scriptPath))
|
||||
{
|
||||
Enemy = GD.Load<EnemyResource>(scriptPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.PushWarning($"Spawner {this.Name} has no enemy assigned");
|
||||
}
|
||||
|
||||
Billboard = true;
|
||||
//MarkerId = props["id"].AsInt32();
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Cirno.Scripts.Interactables;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
|
|
@ -28,61 +29,26 @@ public partial class ItemMarker3D : PreviewMarker3D
|
|||
|
||||
[Export] public bool AutoSpawn { get; set; } = false;
|
||||
|
||||
// [ExportToolButton("Update Icon")] public Callable RedrawButton => Callable.From(Redraw);
|
||||
// [ExportToolButton("Clear Children")] public Callable ClearChildrenButton => Callable.From(ClearChildren);
|
||||
public void _func_godot_apply_properties(Dictionary<string, Variant> props)
|
||||
{
|
||||
//GroupName = (string)props["targetname"];
|
||||
this.AddToGroup("ItemMarkers");
|
||||
AutoSpawn = props["autospawn"].AsBool();
|
||||
|
||||
// public override void _Draw()
|
||||
// {
|
||||
// if (!Engine.IsEditorHint()) return;
|
||||
// if (Item is null) return;
|
||||
// if (Item.InventorySprite is null) return;
|
||||
//
|
||||
// DrawTexture(Item.InventorySprite, - new Vector2(Item.InventorySprite.GetWidth() / 2f, Item.InventorySprite.GetHeight() / 2f));
|
||||
// }
|
||||
//
|
||||
// private void Redraw()
|
||||
// {
|
||||
// QueueRedraw();
|
||||
// }
|
||||
var scriptPath = props["resource_path"].AsString();
|
||||
if (!string.IsNullOrWhiteSpace(scriptPath))
|
||||
{
|
||||
Item = GD.Load<LootItem>(scriptPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.PushWarning($"Spawner {this.Name} has no item assigned");
|
||||
}
|
||||
|
||||
// private void ClearChildren()
|
||||
// {
|
||||
// var children = GetChildren();
|
||||
// foreach (var child in children)
|
||||
// {
|
||||
// if (child is Sprite3D)
|
||||
// {
|
||||
// child.QueueFree();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// _sprite = null;
|
||||
// }
|
||||
Billboard = true;
|
||||
//MarkerId = props["id"].AsInt32();
|
||||
}
|
||||
|
||||
// private void QueueRedraw()
|
||||
// {
|
||||
// if (!Engine.IsEditorHint()) return;
|
||||
// if (Item?.InventorySprite is null) return;
|
||||
//
|
||||
// if (_sprite is null)
|
||||
// {
|
||||
// GD.Print("Remaking sprite");
|
||||
// _sprite = new EditorSprite3D();
|
||||
// this.AddChild(_sprite);
|
||||
// //_sprite.Owner = GetTree().EditedSceneRoot;
|
||||
// }
|
||||
//
|
||||
// _sprite.Texture = Item.InventorySprite;
|
||||
// //_sprite.SetRotationDegrees(new Vector3(-45, 45, 0));
|
||||
// _sprite.FixedSize = true;
|
||||
// _sprite.SetBillboardMode(BaseMaterial3D.BillboardModeEnum.Enabled);
|
||||
// _sprite.TextureFilter = BaseMaterial3D.TextureFilterEnum.Nearest;
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
//private Sprite3D _sprite;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public partial class PreviewMarker3D : Marker3D
|
|||
|
||||
private bool _fixedSize;
|
||||
private bool _billboard;
|
||||
private float _pixelSize = 0.1f;
|
||||
private float _pixelSize = 0.05f;
|
||||
|
||||
[Export]
|
||||
protected bool FixedSize
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue