Plant field hologram rework
This commit is contained in:
parent
ae4043d230
commit
435ca455f0
6 changed files with 23 additions and 21 deletions
|
|
@ -6,7 +6,7 @@ namespace Newlon.Components.Level;
|
|||
|
||||
public partial class PlantField : Node2D
|
||||
{
|
||||
private Sprite2D _plantSetter;
|
||||
private Node2D _plantSetter;
|
||||
private PlantResource _resource;
|
||||
private Seedpacket _slot;
|
||||
private bool _previousCanPlace;
|
||||
|
|
@ -16,13 +16,23 @@ public partial class PlantField : Node2D
|
|||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
_plantSetter = GetChild<Sprite2D>(0);
|
||||
_plantSetter = GetChild<Node2D>(0);
|
||||
}
|
||||
|
||||
public void SetPlant(Seedpacket slot, PlantResource plant)
|
||||
{
|
||||
_resource = plant;
|
||||
_slot = slot;
|
||||
if (plant == null)
|
||||
{
|
||||
_plantSetter.GetChild(0).QueueFree();
|
||||
}
|
||||
else
|
||||
{
|
||||
var scene = plant.Scene.Instantiate<Node2D>();
|
||||
_plantSetter.AddChild(scene);
|
||||
scene.UseParentMaterial = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetPlant()
|
||||
|
|
@ -66,7 +76,6 @@ public partial class PlantField : Node2D
|
|||
|
||||
if (canPlace)
|
||||
_plantSetter.GlobalPosition = expected_pos;
|
||||
_plantSetter.Texture = _resource?.Preview;
|
||||
}
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue