SpaceRTS - Starter Pack  1.3
GameBase.ProxyRef Class Reference

Represents a Component reference that can be assigned directly through editor or must be taken from a component proxy in runtime. More...

Public Types

enum  RefType { RefType.Direct, RefType.UseProxy }
 Types of references for the component cache. More...
 

Public Member Functions

Get< T > ()
 The casted component stored in the cache. More...
 
void SetDirect (Component val)
 Set the cached reference and sets the the allowedType as RefType.Direct. More...
 
 ProxyRef ()
 Parameterless constructor. Sets the allowedType field as typeof(Component). More...
 
 ProxyRef (System.Type type, string defaultName="")
 Constructor that sets the component allowed type and the default property name for the ComponentProxy setting. More...
 
void Assign (ComponentProxy proxy)
 Assign a cached reference stored in the ComponentProxy according with the internal property name. More...
 
void Assign (GameEntity entity)
 Assigns the component reference stored in the GameEntity VisualProxy according with the stored property name. More...
 
void SafeAssign (GameEntity entity)
 Assigns the cached component only if internally was configured to use a proxy component More...
 
void Clear ()
 Forces to clear the cache reference of the component. More...
 
void SafeClear ()
 Removes the component reference only if internally was configured to use a proxy component. More...
 

Static Public Member Functions

static bool IsInvalid (ProxyRef val)
 Indicates whether the specified ProxyRef is null or has an invalid cached reference. More...
 

Public Attributes

string refname
 The name of the property in the ComponentProxy to use. This value is not used if the refType is Direct. More...
 
Component cache
 The cache reference for the component to use. More...
 
RefType refType = RefType.UseProxy
 Indicates if the component cache must be assigned directly or through a ComponentProxy property. More...
 
System.Type allowedType
 The Component type allowed to be assigned in the editor. More...
 

Detailed Description

Represents a Component reference that can be assigned directly through editor or must be taken from a component proxy in runtime.

Member Enumeration Documentation

◆ RefType

Types of references for the component cache.

Enumerator
Direct 

The reference cache must be assigned directly

UseProxy 

The reference cache must be taken from a ComponentProxy property.

Constructor & Destructor Documentation

◆ ProxyRef() [1/2]

GameBase.ProxyRef.ProxyRef ( )

Parameterless constructor. Sets the allowedType field as typeof(Component).

◆ ProxyRef() [2/2]

GameBase.ProxyRef.ProxyRef ( System.Type  type,
string  defaultName = "" 
)

Constructor that sets the component allowed type and the default property name for the ComponentProxy setting.

Parameters
typeThe valid type for reference assignment.
defaultNameThe default name for the ComponentProxy property.

Member Function Documentation

◆ Assign() [1/2]

void GameBase.ProxyRef.Assign ( ComponentProxy  proxy)

Assign a cached reference stored in the ComponentProxy according with the internal property name.

Parameters
proxyThe ComponentProxy where to take the reference.

◆ Assign() [2/2]

void GameBase.ProxyRef.Assign ( GameEntity  entity)

Assigns the component reference stored in the GameEntity VisualProxy according with the stored property name.

Parameters
entityThe GameEntity that contains a VisualProxy where to take the reference.

◆ Clear()

void GameBase.ProxyRef.Clear ( )

Forces to clear the cache reference of the component.

◆ Get< T >()

T GameBase.ProxyRef.Get< T > ( )

The casted component stored in the cache.

Template Parameters
TThe Component type to convert in the result.
Returns
The casted component reference in the cache or null if not found or the conversion is invalid.
Type Constraints
T :Component 

◆ IsInvalid()

static bool GameBase.ProxyRef.IsInvalid ( ProxyRef  val)
static

Indicates whether the specified ProxyRef is null or has an invalid cached reference.

Parameters
valThe ProxyRef to test.
Returns
true if the val parameter is null or contains an invalid cached reference; otherwise false.

◆ SafeAssign()

void GameBase.ProxyRef.SafeAssign ( GameEntity  entity)

Assigns the cached component only if internally was configured to use a proxy component

Parameters
entityThe GameEntity that contains a VisualProxy where to take the reference.

◆ SafeClear()

void GameBase.ProxyRef.SafeClear ( )

Removes the component reference only if internally was configured to use a proxy component.

◆ SetDirect()

void GameBase.ProxyRef.SetDirect ( Component  val)

Set the cached reference and sets the the allowedType as RefType.Direct.

Parameters
valThe new component reference value to cache.

Member Data Documentation

◆ allowedType

System.Type GameBase.ProxyRef.allowedType

The Component type allowed to be assigned in the editor.

◆ cache

Component GameBase.ProxyRef.cache

The cache reference for the component to use.

◆ refname

string GameBase.ProxyRef.refname

The name of the property in the ComponentProxy to use. This value is not used if the refType is Direct.

◆ refType

RefType GameBase.ProxyRef.refType = RefType.UseProxy

Indicates if the component cache must be assigned directly or through a ComponentProxy property.