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

Bolt

Namespace: TommoJProductions.ModApi.Attachable

The Base Bolt. All basic bolt function of a bolt. Overridable.

public class Bolt

Inheritance ObjectBolt

Fields

ignoreInput

if , scrolling on this bolt will do nothing.

public bool ignoreInput;

spannerWaitTime

The spanner wait time.

public static float spannerWaitTime;

rachetWaitTime

The rachet wait time.

public static float rachetWaitTime;

Properties

settings

The bolts settings.

public virtual BoltSettings settings { get; protected set; }

Property Value

BoltSettings

wait

The bolt waiting value. when true, the bolt has been tightened/loosened and is waiting for x amount of time base on the tool used before continuing to update the model transform, play the bolt audio, invoke events bolt tighten/loosen events.

public virtual bool wait { get; set; }

Property Value

Boolean

scrollInput

The last scroll input.

public virtual int scrollInput { get; set; }

Property Value

Int32

tightness

The bolts tightness (0 - 8)

public virtual int tightness { get; set; }

Property Value

Int32

isTight

Returns true if this bolt is tight.

public virtual bool isTight { get; }

Property Value

Boolean

isLoose

Returns true if this bolt is loose.

public virtual bool isLoose { get; }

Property Value

Boolean

startPosition

The start position of the bolt.

public virtual Vector3 startPosition { get; set; }

Property Value

Vector3

startEulerAngles

The start rotation of the bolt.

public virtual Vector3 startEulerAngles { get; set; }

Property Value

Vector3

positionVectorStep

The position vector step (direction * step). How much and in what direction does the bolt move per tightness step.

public virtual Vector3 positionVectorStep { get; }

Property Value

Vector3

rotationVectorStep

The rotation vector (direction * step). How much and in what direction does the bolt rotate per tightness step.

public virtual Vector3 rotationVectorStep { get; }

Property Value

Vector3

maxTightness

The max tightness of the bolt.

public virtual int maxTightness { get; }

Property Value

Int32

boltID

The Bolts ID

public string boltID { get; }

Property Value

String

model

The bolt model

public GameObject model { get; }

Property Value

GameObject

callback

The callback

public BoltCallback callback { get; }

Property Value

BoltCallback

routine

the bolt func routine.

public Coroutine routine { get; }

Property Value

Coroutine

Constructors

Bolt()

public Bolt()

Bolt(BoltSettings, Vector3, Vector3)

Assigns bolt values.

public Bolt(BoltSettings settings, Vector3 position, Vector3 eulerAngles)

Parameters

settings BoltSettings
the settings for the bolt.

position Vector3
the position of the bolt

eulerAngles Vector3
the rotation of the bolt.

Bolt(Int32, BoltSettings, Vector3, Vector3)

Assigns bolt values.

public Bolt(int tightness, BoltSettings settings, Vector3 position, Vector3 eulerAngles)

Parameters

tightness Int32
The the tightness of the bolt.

settings BoltSettings
the settings for the bolt.

position Vector3
the position of the bolt

eulerAngles Vector3
the rotation of the bolt.

Methods

updateTightness(Single, Int32)

Waits specified time then updates model transform, invokes events, plays bolt sound.

 virtual IEnumerator updateTightness(float waitTime, int tightness)

Parameters

waitTime Single
the wait time.

tightness Int32
the tightness.

Returns

IEnumerator
USAGE:

boltFunction(BoltCallback)

The bolt logic. runs continuously while looking at the bolt. Stops every bolt from having a UnityEngine Update call.

 virtual IEnumerator boltFunction(BoltCallback bcb)

Parameters

bcb BoltCallback
The callback that invoked this.

Returns

IEnumerator
USAGE:

stepTightness(Int32)

Steps the current step by 1 in either direction and returns the value. clamped between 0 - 8.

public virtual int stepTightness(int direction)

Parameters

direction Int32
Increase or decrease the tightness.

Returns

Int32

init(Int32, BoltSettings, Vector3, Vector3)

Assigns bolt values. (tightness, settings, start (initial) transform.

public virtual void init(int tightness, BoltSettings baseSettings, Vector3 position, Vector3 eulerAngles)

Parameters

tightness Int32
The tightness of the bolt.

baseSettings BoltSettings
the bolt settings.

position Vector3
the position of the bolt.

eulerAngles Vector3
the rotation of the bolt.

setupBoltModel()

Sets up the bolt model base on the settings. (model type, transform)

protected virtual void setupBoltModel()

setTightnessAndUpdateModel(Int32)

Sets tightness and updates the model postion.

public virtual void setTightnessAndUpdateModel(int tightnessValue)

Parameters

tightnessValue Int32
bolt tightness

updateModelPosition()

Updates the model position and rotation based on start and tightness values.

public virtual void updateModelPosition()

createBolt(Int32, Transform)

Initializes this bolt. setups model and sets the parent to param, .

public virtual void createBolt(int tightness, Transform parent)

Parameters

tightness Int32
bolt tightness

parent Transform
The parent of the bolt.

destoryBolt()

Destorys the bolt.

public virtual void destoryBolt()

activateBolt(Boolean)

De/Activates the model.

public virtual void activateBolt(bool active)

Parameters

active Boolean
activate or not.

enableBoltLogic(Boolean)

Enables / Disables bolt logic.

public virtual void enableBoltLogic(bool enabled)

Parameters

enabled Boolean
Set enabled or not

bcb_mouseEnter(BoltCallback)

On mouse enter. Starts the bolt coroutine and sets Bolt.routine to that coroutine.

public virtual void bcb_mouseEnter(BoltCallback bcb)

Parameters

bcb BoltCallback
The callback that invoked the bolt mouse enter event.

bcb_mouseExit(BoltCallback)

On mouse exit. Stops the bolt coroutine and sets Bolt.routine to .

public virtual void bcb_mouseExit(BoltCallback bcb)

Parameters

bcb BoltCallback
The callback that invoked the mouse exit event.

invokeOnScrew()

Invokes the Bolt.onScrew event.

public virtual void invokeOnScrew()

invokeOnTight()

Invokes the Bolt.onTight event.

public virtual void invokeOnTight()

invokeOnLoose()

Invokes the Bolt.onLoose event.

public virtual void invokeOnLoose()

invokeOutTight()

Invokes the Bolt.outTight event.

public virtual void invokeOutTight()

invokeOutLoose()

Invokes the Bolt.outLoose event.

public virtual void invokeOutLoose()

validateBolts(Bolt[])

Vaildiates bolts after bolts have been initialized.

public static bool validateBolts(Bolt[] bolts)

Parameters

bolts Bolt[]

Returns

Boolean
returns true if no errors were detected with the bolts.

Exceptions

Exception
Throws an exception is any issues were detected. to prevent part from initializing.

getBoltSaveInfo(Bolt[], Boolean)

Gets bolt save info in an array.

public static Int32[] getBoltSaveInfo(Bolt[] bolts, bool hasBolts)

Parameters

bolts Bolt[]

hasBolts Boolean

Returns

Int32[]
All tightness values in an int array.

Events

onScrew

Represents the post onscrew event. occurs when this bolt is screwed in or out. called after all other bolt events are called. Bolt.onLoose, Bolt.onTight.

public event Action onScrew;

onTight

Represents the on tight event. occurs when this bolt becomes tight (screwed to tight state)

public event Action onTight;

onLoose

Represents the on loose event. occurs when this bolt becomes loose (screwed to loose state)

public event Action onLoose;

outTight

Represents the out tight event. occurs when this bolt was tight but was screw out. (screwed from tight state)

public event Action outTight;

outLoose

Represents the out loose event. occurs when this bolt was loose but was screw in (screwed from loose state)

public event Action outLoose;

Clone this wiki locally