You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
844 B
28 lines
844 B
using Godot;
|
|
using System;
|
|
|
|
public partial class RegionVisual : Node
|
|
{
|
|
[Export] private Sprite2D _sliceSprite;
|
|
[Export] private Label _textLabel;
|
|
[Export] private Node2D _labelPivot;
|
|
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
//_sliceSprite.Material = new Material()
|
|
}
|
|
|
|
public void Setup(Vector2 normalAngles, Color color, string regionText)
|
|
{
|
|
var mat = (_sliceSprite.Material as ShaderMaterial)!;
|
|
mat.SetShaderParameter("angles", normalAngles);
|
|
mat.SetShaderParameter("fillColor", color);
|
|
|
|
var averageAngleRadians = (normalAngles.X + normalAngles.Y) * float.Pi; // '/ 2' from the average and '* 2' from the radians cancel out
|
|
_labelPivot.Rotation = averageAngleRadians;
|
|
_textLabel.Rotation = -averageAngleRadians;
|
|
|
|
_textLabel.Text = regionText;
|
|
}
|
|
} |