AI/Needs/Need.cs
public class Need : Component
{
[Property, ReadOnly]
public NeedDefinition Template { get; private set; }
private float _level;
[Sync( SyncFlags.FromHost )]
[Property, ReadOnly]
public float Level
{
get => _level;
set
{
_level = value.Clamp( 0, 1f );
}
}
public void Init( NeedDefinition template )
{
Template = template;
Level = System.Random.Shared.Float( template.InitialRange.x, template.InitialRange.y );
}
public bool IsActionable() => Level > Template.ActionThreshold;
public float GetPriority() => Level * Template.Priority;
}