> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor/ks.reactor.ksplayercontrollercache.md).

# Class ksPlayerControllerCache

Namespace: [KS.Reactor](/reactor/api-reference/ks.reactor.md)\
Assembly: KSCommon.dll

Cache mapping player controller types to controller prefabs.

```csharp
public static class ksPlayerControllerCache
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksPlayerControllerCache](/reactor/api-reference/ks.reactor/ks.reactor.ksplayercontrollercache.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Methods

### Cache(Type) <a href="#ks_reactor_ksplayercontrollercache_cache_system_type" id="ks_reactor_ksplayercontrollercache_cache_system_type"></a>

Creates and caches an instance of a [ksPlayerController](/reactor/api-reference/ks.reactor/ks.reactor.ksplayercontroller.md) class.

```csharp
public static bool Cache(Type type)
```

#### Parameters

`type` [Type](https://learn.microsoft.com/dotnet/api/system.type)

type of ksPlayerController to cache.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the controller was cached successfully.

### CacheFromAssembly(Assembly) <a href="#ks_reactor_ksplayercontrollercache_cachefromassembly_system_reflection_assembly" id="ks_reactor_ksplayercontrollercache_cachefromassembly_system_reflection_assembly"></a>

Registers all player controllers in an assembly using reflection.

```csharp
public static void CacheFromAssembly(Assembly assembly)
```

#### Parameters

`assembly` [Assembly](https://learn.microsoft.com/dotnet/api/system.reflection.assembly)

assembly to load from.

### Clear() <a href="#ks_reactor_ksplayercontrollercache_clear" id="ks_reactor_ksplayercontrollercache_clear"></a>

Clears the cache.

```csharp
public static void Clear()
```

### Create(uint) <a href="#ks_reactor_ksplayercontrollercache_create_system_uint32" id="ks_reactor_ksplayercontrollercache_create_system_uint32"></a>

Creates a player controller from a cached controller prefab.

```csharp
public static ksPlayerController Create(uint type)
```

#### Parameters

`type` [uint](https://learn.microsoft.com/dotnet/api/system.uint32)

type of controller to create.

#### Returns

[ksPlayerController](/reactor/api-reference/ks.reactor/ks.reactor.ksplayercontroller.md)

Created player controller, or null if unsuccessful.

### Get(uint) <a href="#ks_reactor_ksplayercontrollercache_get_system_uint32" id="ks_reactor_ksplayercontrollercache_get_system_uint32"></a>

Gets a player controller prefab by type from the cache. If none is cached, creates one and caches it.

```csharp
public static ksPlayerController Get(uint type)
```

#### Parameters

`type` [uint](https://learn.microsoft.com/dotnet/api/system.uint32)

Type of player controller to get

#### Returns

[ksPlayerController](/reactor/api-reference/ks.reactor/ks.reactor.ksplayercontroller.md)

Cached player controller prefab, or null if none was cached and a player controller of the `type` could not be created.

### NextUnusedType() <a href="#ks_reactor_ksplayercontrollercache_nextunusedtype" id="ks_reactor_ksplayercontrollercache_nextunusedtype"></a>

Gets the lowest unused type number.

```csharp
public static uint NextUnusedType()
```

#### Returns

[uint](https://learn.microsoft.com/dotnet/api/system.uint32)

type number.
