Class EntityViewRegistry

Namespace
TDMaker.Unity.View
Assembly
TDMaker.Unity.dll

Creates, pools and updates EntityViews from simulation events. Prefabs come from authoring assets or the TDMaker.Unity.View.EntityViewRegistry.overrides list (by view key); otherwise generated primitive sprites are used. Also routes per-template presentation hooks (VFX prefabs through VfxPool, audio cues through AudioCuePlayer) and draws built-in feedback: impact flashes, splash rings and instant-hit beams.

[DefaultExecutionOrder(100)]
[AddComponentMenu("2D Tower Defense Maker/Entity View Registry")]
public sealed class EntityViewRegistry : MonoBehaviour
Inheritance
Object
Component
Behaviour
MonoBehaviour
EntityViewRegistry
Inherited Members
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.didStart
MonoBehaviour.didAwake
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.GetComponentIndex()
Component.CompareTag(TagHandle)
Component.transform
Component.transformHandle
Component.gameObject
Component.tag
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Constructors

EntityViewRegistry()

public EntityViewRegistry()

Fields

RemainsArtKey

Art set key whose sprite replaces the generated body marker (optional).

public const string RemainsArtKey = "remains"

Field Value

string

Properties

ActiveCount

Number of live (not dying) views.

public int ActiveCount { get; }

Property Value

int

ArtSet

The sprite set in use (may be null).

public ArtSet ArtSet { get; set; }

Property Value

ArtSet

BeamLineCount

Number of beam lines currently drawn (including fading ones).

public int BeamLineCount { get; }

Property Value

int

RemainsMarkerCount

Number of body markers currently drawn (including fading ones).

public int RemainsMarkerCount { get; }

Property Value

int

Runner

The runner whose events drive this registry.

public SimulationRunner Runner { get; }

Property Value

SimulationRunner

ShowsRemains

Whether body markers are drawn in the running level (a template raises bodies and markers are on).

public bool ShowsRemains { get; }

Property Value

bool

SpriteMaterial

Material used for generated sprites.

public Material SpriteMaterial { get; }

Property Value

Material

TrapMarkerCount

Number of trap markers currently drawn (including fading ones).

public int TrapMarkerCount { get; }

Property Value

int

Methods

Configure(SimulationRunner, Material)

Assigns the runner; call before enabling.

public void Configure(SimulationRunner source, Material material)

Parameters

source SimulationRunner
material Material

ConfigureHooks(VfxPool, AudioCuePlayer)

Assigns optional hook routers.

public void ConfigureHooks(VfxPool pool, AudioCuePlayer audio)

Parameters

pool VfxPool
audio AudioCuePlayer

Connect()

Initializes pools and subscribes to the runner. Called from OnEnable; tools may call it in edit mode.

public void Connect()

Render(float)

Interpolates views and ages effects. Called from LateUpdate; tools may call it in edit mode.

public void Render(float deltaTime)

Parameters

deltaTime float

ResolveIcon(EntityAssetBase, out Sprite, out Color)

Resolves the sprite and colour a template is drawn with (for HUD icons and placement ghosts): the prefab's first SpriteRenderer when present, otherwise the generated primitive.

public static void ResolveIcon(EntityAssetBase asset, out Sprite sprite, out Color color)

Parameters

asset EntityAssetBase
sprite Sprite
color Color

ResolveIconWithArt(EntityAssetBase, out Sprite, out Color)

Like ResolveIcon(EntityAssetBase, out Sprite, out Color), but prefers the art set's icon for templates without their own prefab.

public void ResolveIconWithArt(EntityAssetBase asset, out Sprite sprite, out Color color)

Parameters

asset EntityAssetBase
sprite Sprite
color Color

TryGetArt(string, out Entry)

Finds the art set entry for a view key, if an art set is assigned and covers it.

public bool TryGetArt(string viewKey, out ArtSet.Entry entry)

Parameters

viewKey string
entry ArtSet.Entry

Returns

bool

TryGetView(int, out EntityView)

Finds the view bound to an entity.

public bool TryGetView(int entityId, out EntityView view)

Parameters

entityId int
view EntityView

Returns

bool