Skip to content

Trigger

Tommo J. Phillips edited this page Oct 22, 2023 · 3 revisions

Trigger

Namespace: TommoJProductions.ModApi.Attachable

Represents a trigger for a part.

public class Trigger : IHasBolts

Inheritance ObjectTrigger
Implements IHasBolts

Fields

loadedTriggers

Represents all loaded/created triggers. in GAME

public static List<Trigger> loadedTriggers;

triggerDictionary

Represents All Triggers that are in game. by trigger type (TriggerData) then by key (Trigger.triggerID)

public static Dictionary<TriggerData, Dictionary<string, Trigger>> triggerDictionary;

Properties

triggerID

Represents the triggers name.

public string triggerID { get; }

Property Value

String

gameObject

Represents the trigger game object.

public GameObject gameObject { get; }

Property Value

GameObject

callback

Represents the trigger callback reference on the triggers gameobject.

public TriggerCallback callback { get; }

Property Value

TriggerCallback

installPoint

Represents the install point gameobject. the trigger and part pivot are children of this gameobject.

public GameObject installPoint { get; }

Property Value

GameObject

partPivot

Represents the parts pivot. parts that are installed to this trigger will be parented here when installed.

public GameObject partPivot { get; }

Property Value

GameObject

boltParent

Represents the triggers bolt parent. all bolts on the part that are only relevant to this trigger are parented to this gameobject. Null if no bolts are assigned to this trigger.

public GameObject boltParent { get; }

Property Value

GameObject

bolts

Represents all for the trigger.

public virtual Bolt[] bolts { get; }

Property Value

Bolt[]

hasBolts

Represents if this trigger has any bolts!

public virtual bool hasBolts { get; }

Property Value

Boolean

triggerPosition

Represents the triggers position.

public Vector3 triggerPosition { get; }

Property Value

Vector3

triggerEuler

Represents the triggers rotation.

public Vector3 triggerEuler { get; }

Property Value

Vector3

triggerSize

Represents the triggers scale.

public Vector3 triggerSize { get; }

Property Value

Vector3

pivotPosition

Represents the pivot position.

public Vector3 pivotPosition { get; }

Property Value

Vector3

pivotEuler

Represents the pivot rotation.

public Vector3 pivotEuler { get; }

Property Value

Vector3

collider

Represents the triggers collider.

public SphereCollider collider { get; }

Property Value

SphereCollider

settings

Represents settings for the trigger.

public TriggerSettings settings { get; }

Property Value

TriggerSettings

Constructors

Trigger()

Initializes a new instance of trigger. Note, Make sure to set up the trigger! Trigger.initTrigger(GameObject, TriggerSettings)

public Trigger()

Trigger(GameObject, TriggerSettings, Bolt[])

Initializes a new instance and creates a trigger at the provided position, rotation and scale.

public Trigger(GameObject parent, TriggerSettings settings, Bolt[] boltRefs)

Parameters

parent GameObject
The parent transform of the install point (part pivot and trigger).

settings TriggerSettings

boltRefs Bolt[]

Methods

initTrigger(GameObject, TriggerSettings)

Initializes the trigger.

public void initTrigger(GameObject parent, TriggerSettings settings)

Parameters

parent GameObject
The parent transform of the install point (part pivot and trigger).

settings TriggerSettings
Trigger settings.

getSaveInfo()

Gets trigger save info

public virtual TriggerSaveInfo getSaveInfo()

Returns

TriggerSaveInfo

enableTriggerCollider(Boolean)

Changes . ()

public void enableTriggerCollider(bool enabled)

Parameters

enabled Boolean
Set enabled or not

enableDisassemblyLogic(Boolean)

Enables / Disables disassembly logic.

public void enableDisassemblyLogic(bool enabled)

Parameters

enabled Boolean
Set enabled or not

initBolts(Bolt[])

initializes bolts.

public virtual void initBolts(Bolt[] bolts)

Parameters

bolts Bolt[]

invokeAssembledEvent(Part)

Exposes Trigger.onPartAssembledToTrigger's Action.Invoke() method.

internal void invokeAssembledEvent(Part assembledPart)

Parameters

assembledPart Part

invokeDisassembledEvent(Part)

Exposes Trigger.onPartDisassembledFromTrigger's Action.Invoke() method.

internal void invokeDisassembledEvent(Part disassembledPart)

Parameters

disassembledPart Part

invokePreAssembledEvent(Part)

Exposes Trigger.onPartPreAssembledToTrigger's Action.Invoke() method.

internal void invokePreAssembledEvent(Part assembledPart)

Parameters

assembledPart Part

invokePreDisassembledEvent(Part)

Exposes Trigger.onPartPreDisassembledFromTrigger's Action.Invoke() method.

internal void invokePreDisassembledEvent(Part disassembledPart)

Parameters

disassembledPart Part

refreshCache()

internal static void refreshCache()

Events

onPartAssembledToTrigger

Represents the on part assembled event. occurs when a part is assembled to this trigger (instance). occurs after assembly logic executes

public event Action<Trigger, Part> onPartAssembledToTrigger;

onPartDisassembledFromTrigger

Represents the on part disassembled event. occurs when a part is disassembled from this trigger (instance). occurs after disassembly logic executes

public event Action<Trigger, Part> onPartDisassembledFromTrigger;

onPartPreAssembledToTrigger

Represents the on part pre assembled event. occurs when a part is assembled to this trigger (instance). occurs after index of trigger is evaluated but before any assembly logic executes.

public event Action<Trigger, Part> onPartPreAssembledToTrigger;

onPartPreDisassembledFromTrigger

Represents the on part pre disassembled event. occurs when a part is disassembled from this trigger (instance). occurs before any disassembly logic executes.

public event Action<Trigger, Part> onPartPreDisassembledFromTrigger;
Clone this wiki locally