Skip to main content

Sense

An abstract class in Root.Township, Alta.Intelligence.

Asset for something an AI agent can measure about a target (distance, visibility and so on) as a number. Sense assets are loaded from Resources/Senses.

Constructors​

MemberWhat it is
protected Sense()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

3 private and internal fields
MemberWhat it is
private static List<Sense> allEvery sense registered by Initialize. Exposed as All.
private SenseOld oldEquivalentThe legacy SenseOld enum value this sense replaces, or None.
private static Dictionary<SenseOld, Sense> oldMappingMaps legacy SenseOld values to their sense assets, for GetSense.

Properties​

MemberWhat it is
static List<Sense> All { get; }Every sense that has been initialized.

Methods​

MemberWhat it is
abstract float Get(IAgent requester, ITarget target)The sense's value for a target, from the asking agent's point of view.
virtual float GetInverseLerp(IAgent requester, ITarget target, float from, float to)The value mapped to 0 to 1 between from and to, clamped.
static Sense GetSense(SenseOld old)The sense that replaces an old SenseOld enum value, or null.
virtual void Initialize()Adds the sense to All and maps its old enum value.
static void InitializeAll()Loads every sense under Resources/Senses and initializes them.
1 private and internal method
MemberWhat it is
private void OnValidate()Editor: re-registers the sense and renames the asset to match its old enum value if it has one.

Used in​

Members of other types that take, return or hold a Sense: