> 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.ksscript-2.md).

# Class ksScript\<Parent, Script>

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

Base class for Reactor scripts.

```csharp
public abstract class ksScript<Parent, Script> : ksScript<Parent, Script>.IInternals where Parent : class where Script : ksScript<Parent, Script>
```

#### Type Parameters

`Parent`

Type the script can be attached to.

`Script`

Type of script this is.

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksScript\<Parent, Script>](/reactor/api-reference/ks.reactor/ks.reactor.ksscript-2.md)

#### Implements

[ksScript\<Parent, Script>.IInternals](/reactor/api-reference/ks.reactor/ks.reactor.ksscript-2/ks.reactor.ksscript-2.iinternals.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)

## Properties

### Assets <a href="#ks_reactor_ksscript_2_assets" id="ks_reactor_ksscript_2_assets"></a>

Asset loader.

```csharp
public ksBaseAssetLoader Assets { get; }
```

#### Property Value

[ksBaseAssetLoader](/reactor/api-reference/ks.reactor/ks.reactor.ksbaseassetloader.md)

### InstanceType <a href="#ks_reactor_ksscript_2_instancetype" id="ks_reactor_ksscript_2_instancetype"></a>

Gets the most derived type of this script.

```csharp
public Type InstanceType { get; }
```

#### Property Value

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

### IsAttached <a href="#ks_reactor_ksscript_2_isattached" id="ks_reactor_ksscript_2_isattached"></a>

Is the script attached?

```csharp
public bool IsAttached { get; }
```

#### Property Value

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

### Scripts <a href="#ks_reactor_ksscript_2_scripts" id="ks_reactor_ksscript_2_scripts"></a>

List this script is in.

```csharp
public ksScriptList<Parent, Script> Scripts { get; }
```

#### Property Value

[ksScriptList](/reactor/api-reference/ks.reactor/ks.reactor.ksscriptlist-2.md)\<Parent, Script>

## Methods

### Attached() <a href="#ks_reactor_ksscript_2_attached" id="ks_reactor_ksscript_2_attached"></a>

Called immediately when the script is attached. Other scripts may not be attached or have their ksEditable field loaded yet, so it is not safe to access other scripts. Initialization that depends on other scripts should be done from [Initialize](/reactor/api-reference/ks.reactor.md#KS_Reactor_ksScript_602_Initialize). [Attached](/reactor/api-reference/ks.reactor.md#KS_Reactor_ksScript_602_Attached) is called on each script in the order they were configured.

```csharp
public virtual void Attached()
```

### Clone() <a href="#ks_reactor_ksscript_2_clone" id="ks_reactor_ksscript_2_clone"></a>

Creates a copy of the script with the value of all members tagged with ksEditable or ksCloneable copied. Arrays, lists, and dictionaries are cloned. Other object references will reference the same object.

```csharp
public virtual Script Clone()
```

#### Returns

Script

Cloned script.

### Detached() <a href="#ks_reactor_ksscript_2_detached" id="ks_reactor_ksscript_2_detached"></a>

Called when the script is detached. Remove event listeners and perform other clean up logic here.

```csharp
public virtual void Detached()
```

### Initialize() <a href="#ks_reactor_ksscript_2_initialize" id="ks_reactor_ksscript_2_initialize"></a>

Called after all other scripts on all entities are attached. [Initialize](/reactor/api-reference/ks.reactor.md#KS_Reactor_ksScript_602_Initialize) is called on each script in the order they were configured.

```csharp
public virtual void Initialize()
```
