mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 18:45:53 +00:00
Fixed spawnable enemies alpha
This commit is contained in:
parent
e356c593eb
commit
6c9222e47e
5 changed files with 252 additions and 162 deletions
|
|
@ -41,12 +41,15 @@ public partial class EnemyMarker3D : PreviewMarker3D, IActivable
|
|||
{
|
||||
if (_autoSpawn)
|
||||
{
|
||||
SetSpriteAlpha(1);
|
||||
Alpha = 1.0f;
|
||||
// SetSpriteAlpha(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSpriteAlpha(0.5f);
|
||||
Alpha = 0.5f;
|
||||
//SetSpriteAlpha(0.5f);
|
||||
}
|
||||
QueueRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -59,8 +62,20 @@ public partial class EnemyMarker3D : PreviewMarker3D, IActivable
|
|||
{
|
||||
//GroupName = (string)props["targetname"];
|
||||
this.AddToGroup("EnemyMarkers");
|
||||
AutoSpawn = props["autospawn"].AsBool();
|
||||
|
||||
_billboard = true;
|
||||
_autoSpawn = props["autospawn"].AsBool();
|
||||
if (_autoSpawn)
|
||||
{
|
||||
_alpha = 1.0f;
|
||||
// SetSpriteAlpha(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_alpha = 0.5f;
|
||||
//SetSpriteAlpha(0.5f);
|
||||
}
|
||||
|
||||
var scriptPath = props["resource_path"].AsString();
|
||||
if (!string.IsNullOrWhiteSpace(scriptPath))
|
||||
{
|
||||
|
|
@ -73,10 +88,28 @@ public partial class EnemyMarker3D : PreviewMarker3D, IActivable
|
|||
|
||||
TargetName = props["targetname"].AsStringName();
|
||||
|
||||
Billboard = true;
|
||||
|
||||
|
||||
//QueueRedraw(); // Redraw should be automatic when enemy was changed and texture updated
|
||||
//MarkerId = props["id"].AsInt32();
|
||||
}
|
||||
|
||||
protected override void QueueRedraw()
|
||||
{
|
||||
if (!Engine.IsEditorHint()) return;
|
||||
if (_autoSpawn)
|
||||
{
|
||||
_alpha = 1.0f;
|
||||
// SetSpriteAlpha(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_alpha = 0.5f;
|
||||
//SetSpriteAlpha(0.5f);
|
||||
}
|
||||
base.QueueRedraw();
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace Cirno.Scripts.Actors;
|
|||
[Tool]
|
||||
public partial class PreviewMarker3D : Marker3D
|
||||
{
|
||||
private Texture2D _texture;
|
||||
protected Texture2D _texture;
|
||||
protected Texture2D Texture
|
||||
{
|
||||
get => _texture;
|
||||
|
|
@ -19,9 +19,9 @@ public partial class PreviewMarker3D : Marker3D
|
|||
}
|
||||
}
|
||||
|
||||
private bool _fixedSize;
|
||||
private bool _billboard;
|
||||
private float _pixelSize = 0.05f;
|
||||
protected bool _fixedSize;
|
||||
protected bool _billboard;
|
||||
protected float _pixelSize = 0.05f;
|
||||
|
||||
[Export]
|
||||
protected bool FixedSize
|
||||
|
|
@ -64,6 +64,21 @@ public partial class PreviewMarker3D : Marker3D
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected float _alpha = 1.0f;
|
||||
|
||||
protected float Alpha
|
||||
{
|
||||
get => _alpha;
|
||||
set
|
||||
{
|
||||
_alpha = value;
|
||||
if (Engine.IsEditorHint())
|
||||
{
|
||||
QueueRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ExportToolButton("Update Icon")] public Callable RedrawButton => Callable.From(Redraw);
|
||||
[ExportToolButton("Clear Children")] public Callable ClearChildrenButton => Callable.From(ClearChildren);
|
||||
|
|
@ -99,7 +114,7 @@ public partial class PreviewMarker3D : Marker3D
|
|||
_sprite = null;
|
||||
}
|
||||
|
||||
protected void QueueRedraw()
|
||||
protected virtual void QueueRedraw()
|
||||
{
|
||||
if (!Engine.IsEditorHint()) return;
|
||||
if (_texture is null) return;
|
||||
|
|
@ -112,12 +127,18 @@ public partial class PreviewMarker3D : Marker3D
|
|||
//_sprite.Owner = GetTree().EditedSceneRoot;
|
||||
}
|
||||
|
||||
_sprite.Modulate = new Color(_sprite.Modulate.R, _sprite.Modulate.G, _sprite.Modulate.B, Alpha);
|
||||
|
||||
_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;
|
||||
|
||||
//GD.Print($"Modulating alpha: {Alpha}");
|
||||
|
||||
//_sprite.SetModulate(new Color(_sprite.Modulate.R, _sprite.Modulate.G, _sprite.Modulate.B, Alpha));
|
||||
}
|
||||
|
||||
protected void SetSpriteAlpha(float alpha)
|
||||
|
|
@ -130,7 +151,7 @@ public partial class PreviewMarker3D : Marker3D
|
|||
}
|
||||
else
|
||||
{
|
||||
GD.Print("Sprite was null");
|
||||
//GD.Print("Sprite was null");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue