mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 12:45:55 +00:00
Box models and item drops
This commit is contained in:
parent
cc9c4e5aa1
commit
2fe9618942
132 changed files with 9210 additions and 999 deletions
9
Scripts/Actors/EditorSprite3D.cs
Normal file
9
Scripts/Actors/EditorSprite3D.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
[Tool]
|
||||
public partial class EditorSprite3D : Sprite3D
|
||||
{
|
||||
|
||||
}
|
||||
1
Scripts/Actors/EditorSprite3D.cs.uid
Normal file
1
Scripts/Actors/EditorSprite3D.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://iih7baty86xt
|
||||
118
Scripts/Actors/ItemMarker3D.cs
Normal file
118
Scripts/Actors/ItemMarker3D.cs
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
using Cirno.Scripts.Interactables;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
[Tool]
|
||||
public partial class ItemMarker3D : Marker3D
|
||||
{
|
||||
private LootItem _item;
|
||||
|
||||
[Export]
|
||||
public LootItem Item
|
||||
{
|
||||
get => _item;
|
||||
set
|
||||
{
|
||||
_item = value;
|
||||
if (Engine.IsEditorHint())
|
||||
{
|
||||
QueueRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[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 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();
|
||||
}
|
||||
|
||||
private void ClearChildren()
|
||||
{
|
||||
var children = GetChildren();
|
||||
foreach (var child in children)
|
||||
{
|
||||
if (child is Sprite3D)
|
||||
{
|
||||
child.QueueFree();
|
||||
}
|
||||
}
|
||||
|
||||
_sprite = null;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
_sprite = GetNodeOrNull<Sprite3D>("Sprite3D");
|
||||
if (Engine.IsEditorHint())
|
||||
{
|
||||
QueueRedraw();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ClearChildren();
|
||||
|
||||
if (AutoSpawn)
|
||||
{
|
||||
Spawn(false);
|
||||
}
|
||||
}
|
||||
|
||||
// public override void _Process(double delta)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
|
||||
public ItemPickup3D Spawn(bool deleteMarker)
|
||||
{
|
||||
if (Engine.IsEditorHint()) return null;
|
||||
if (Item is null) return null;
|
||||
|
||||
if (deleteMarker)
|
||||
{
|
||||
this.QueueFree();
|
||||
}
|
||||
|
||||
return Item.Spawn3D(this);
|
||||
}
|
||||
}
|
||||
1
Scripts/Actors/ItemMarker3D.cs.uid
Normal file
1
Scripts/Actors/ItemMarker3D.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b88cmj87g78mx
|
||||
Loading…
Add table
Add a link
Reference in a new issue