newlon/scripts/gui/RewardScene.cs
2025-07-21 03:18:01 +05:00

35 lines
980 B
C#

using Godot;
using Newlon;
using Newlon.Components;
using Newlon.Components.Plants;
public partial class RewardScene : Node
{
public override void _Ready()
{
var reward = LevelController.Instance.Reward;
var subviewport = GetNode<SubViewport>("%SubViewport");
var nameLabel = GetNode<Label>("%NameLabel");
var descriptionLabel = GetNode<RichTextLabel>("%DescriptionLabel");
var continueButton = GetNode<Button>("%ContinueButton");
var field = GetNode<Sprite2D>("%Field");
nameLabel.Text = Tr(reward.Name);
descriptionLabel.Text = Tr(reward.Description);
continueButton.Pressed += LevelController.Instance.ReturnToInitiator;
if (reward is PlantReward plantReward && plantReward.Plant.customFrame != null)
{
field.Texture = plantReward.Plant.customFrame.almanachField;
}
var rewardedObject = reward.GetPreview().Instantiate();
if (rewardedObject is Entity entity)
{
entity.DisableBrain();
}
subviewport.AddChild(rewardedObject);
}
}