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

Part

Namespace: TommoJProductions.ModApi.Attachable

Represents an installable and boltable part.

public class Part : UnityEngine.MonoBehaviour, IHasBolts

Inheritance Object → Object → Component → Behaviour → MonoBehaviour → Part
Implements IHasBolts

Properties

defaultSaveInfo

Represents the default save info for this part.

public PartSaveInfo defaultSaveInfo { get; set; }

Property Value

PartSaveInfo

partSettings

Represents the parts settings.

public PartSettings partSettings { get; }

Property Value

PartSettings

partID

Represents the runtime id of this part.

public string partID { get; }

Property Value

String

bolted

Represents if the part is completely bolted or not.

public bool bolted { get; }

Property Value

Boolean

installed

Represents if the part is installed or not.

public bool installed { get; }

Property Value

Boolean

hasBolts

Represents if this part has any bolts!

public virtual bool hasBolts { get; }

Property Value

Boolean

hasAnyBolts

if this part or the install point its installed to has bolts.

public bool hasAnyBolts { get; }

Property Value

Boolean

inherentlyPickedUp

Represents if this part is inherently picked up. (is a child of a part that is currently picked up)

public bool inherentlyPickedUp { get; internal set; }

Property Value

Boolean

pickedUp

Represents if this part is currently picked up.

public bool pickedUp { get; internal set; }

Property Value

Boolean

inTrigger

Represents if the part is in a trigger.

public bool inTrigger { get; }

Property Value

Boolean

tightnessStep

Represents the tightness step. calculated in . how much the breakforce of the install point joint increases per bolt screw.

public float tightnessStep { get; }

Property Value

Single

maxTightnessTotal

Represents max tightness of all bolts.(8 * Part.bolts.Length). if any present on part. (Part.hasBolts)

public float maxTightnessTotal { get; }

Property Value

Single

tightnessTotal

Represents tightness of all bolts (BoltSaveInfo.boltTightness * Part.bolts.Length). if any present on part. (Part.hasBolts)

public float tightnessTotal { get; }

Property Value

Single

cachedMass

Represents the cachedMass. Cached on initPart, assemble and disassemble.

public float cachedMass { get; }

Property Value

Single

bolts

Represents all bolts for the part.

public virtual Bolt[] bolts { get; }

Property Value

Bolt[]

boltParent

Represents the bolt parent. all bolts will be a child of this game object. NOTE null if no bolts are on this part or the part has bolts but none of them are relevant to the part alone. bolts could be assigned to a trigger.

public GameObject boltParent { get; }

Property Value

GameObject

triggerData

Represents the Parts Trigger type. The part will be installable to any Trigger with the same trigger type. (TriggerData)

public TriggerData triggerData { get; }

Property Value

TriggerData

joint

Represents the fixed joint when using AssembleType.joint and installed.

public FixedJoint joint { get; }

Property Value

FixedJoint

cachedRigidBody

Represents the cached rigidbody.

public Rigidbody cachedRigidBody { get; }

Property Value

Rigidbody

installPoint

Represents the install point that the part is installed to. (Trigger).

public Trigger installPoint { get; }

Property Value

Trigger

transform

Cached part transform

public Transform transform { get; }

Property Value

Transform

gameObject

Cached part gameobject

public GameObject gameObject { get; }

Property Value

GameObject

useGUILayout

public bool useGUILayout { get; set; }

Property Value

Boolean

enabled

public bool enabled { get; set; }

Property Value

Boolean

isActiveAndEnabled

public bool isActiveAndEnabled { get; }

Property Value

Boolean

transform

public Transform transform { get; }

Property Value

Transform

gameObject

public GameObject gameObject { get; }

Property Value

GameObject

tag

public string tag { get; set; }

Property Value

String

name

public string name { get; set; }

Property Value

String

hideFlags

public HideFlags hideFlags { get; set; }

Property Value

HideFlags

Constructors

Part()

public Part()

Methods

OnJointBreak(Single)

Represents the joint break runtime call

protected virtual void OnJointBreak(float breakForce)

Parameters

breakForce Single

partInTrigger(Trigger)

Represents the part in a trigger logic.

public virtual IEnumerator partInTrigger(Trigger trigger)

Parameters

trigger Trigger
The trigger callback that invoked this call.

Returns

IEnumerator

initPart(PartSaveInfo, TriggerData, PartSettings, Bolt[])

Initializes this part. with save info reference

public virtual void initPart(PartSaveInfo saveInfo, TriggerData triggerData, PartSettings partSettingsRef, Bolt[] boltRefs)

Parameters

saveInfo PartSaveInfo
The save info to load this part with.

triggerData TriggerData
The Trigger Data. This Part can be installed to triggers that have the same Trigger Data.

partSettingsRef PartSettings
The part settings to load this part with.

boltRefs Bolt[]
The bolts for this part

initPart(TriggerData, PartSettings, Bolt[])

Initializes this part with bolts and without save info reference.

public virtual void initPart(TriggerData triggerData, PartSettings partSettingsRef, Bolt[] boltRefs)

Parameters

triggerData TriggerData
The Trigger Data. This Part can be installed to triggers that have the same Trigger Data.

partSettingsRef PartSettings
The part settings to load this part with.

boltRefs Bolt[]
The bolts for this part

initPart(PartInitData)

Initializes this part.

public virtual void initPart(PartInitData data)

Parameters

data PartInitData
The data to load this part with.

assemble(Trigger, Boolean)

installs this part to the install point.

public virtual void assemble(Trigger installPoint, bool playSound)

Parameters

installPoint Trigger
The install point

playSound Boolean
Play assemble sound?

disassemble(Boolean)

Disassemble this part from the installed point

public virtual void disassemble(bool playSound)

Parameters

playSound Boolean

getSaveInfo(Boolean)

Gets save info for this part and its bolts (if the part has any). (pos, rot, installed, install index, tightness)

public virtual PartSaveInfo getSaveInfo(bool getBoltInfo)

Parameters

getBoltInfo Boolean

Returns

PartSaveInfo

enableDisassembleLogic(Boolean)

Sets the triggers disasemble logic enable (install point).

public virtual void enableDisassembleLogic(bool active)

Parameters

active Boolean
active or not [part]

cacheRigidbody()

caches and stores a reference to the parts rigidbody.

public virtual void cacheRigidbody()

makePartPickable(Boolean)

Makes the part a pickable item depending on the provided values.

public void makePartPickable(bool pickable)

Parameters

pickable Boolean
Make part pickable?

resetBoltTightness()

resets all bolts tightness on this part

public void resetBoltTightness()

setMaxBoltTightness()

sets all bolt tightness to the max tightness.

public void setMaxBoltTightness()

doesSaveDataExist()

if part autosave data exists.

public bool doesSaveDataExist()

Returns

Boolean

vaildiatePart(PartSettings)

Vaildates the part and reports to mod console. called at: Part.initPart(PartSaveInfo, TriggerData, PartSettings, Bolt[]).

protected virtual void vaildiatePart(PartSettings partSettings)

Parameters

partSettings PartSettings

updateTotalBoltTightness()

Updates from current state of . see: BoltSaveInfo.boltTightness and BoltSaveInfo.addNutTightness

protected internal virtual void updateTotalBoltTightness()

updateMaxTotalBoltTightness()

updates the max tightness of the bolts.

protected virtual void updateMaxTotalBoltTightness()

updateJointBreakForce()

Updates joint breakforce. (bolts)

protected internal virtual void updateJointBreakForce()

boltTightnessCheck()

checks all bolts for their Bolt.tightness. invokes, Part.enableDisassembleLogic(Boolean) and invokes Part.onPartBolted, Part.onPartUnBolted events.

protected virtual void boltTightnessCheck()

vaildiateBolts(Bolt[])

Vaildiates bolt refs. called prior to initialization of bolts on the part.

protected virtual bool vaildiateBolts(Bolt[] boltRefs)

Parameters

boltRefs Bolt[]
the bolt refs to vaildiate.

Returns

Boolean
True if no issues were detected with the bolt references.

colliderCheck(Trigger)

Check for deciding if part is in trigger to be installed

protected virtual bool colliderCheck(Trigger trigger)

Parameters

trigger Trigger
the trigger.

Returns

Boolean

holdingCheck(Trigger)

Represents the holding check for a Part. Used for starting and checking trigger routine. Part.partInTrigger(Trigger)

protected virtual bool holdingCheck(Trigger trigger)

Parameters

trigger Trigger
The trigger

Returns

Boolean

initBolts(Bolt[])

initializes the bolts.

public virtual void initBolts(Bolt[] bolts)

Parameters

bolts Bolt[]

onTriggerEnter(Trigger)

invoked when this part enters one of its triggers.

protected internal virtual void onTriggerEnter(Trigger trigger)

Parameters

trigger Trigger
the trigger callback that invoked this.

onTriggerExit(Trigger)

invoked when this part exits one of its triggers.

protected internal virtual void onTriggerExit(Trigger trigger)

Parameters

trigger Trigger
the trigger callback that invoked this.

boltOnScrew()

invoked when any bolt on this part is screwed in or out.

protected internal virtual void boltOnScrew()

invokePickedUpEvent()

invokes the picked up event

internal void invokePickedUpEvent()

invokeThrownEvent()

invokes the thrown event.

internal void invokeThrownEvent()

invokeDroppedEvent()

invokes the dropped event.

internal void invokeDroppedEvent()

<disassemble>g__func|117_1(Bolt)

internal static bool <disassemble>g__func|117_1(Bolt b)

Parameters

b Bolt

Returns

Boolean

Events

onAssemble

Represents the on assemble event.invoked after assembly logic executes

public event Action onAssemble;

onDisassemble

Represents the on disassemble event. invoked after disassembly logic executes

public event Action onDisassemble;

onPreAssemble

Represents the on pre assemble event. invoked before assembly logic executes

public event Action onPreAssemble;

onPreDisassemble

Represents the on pre disassemble event. invoked before disassembly logic executes

public event Action onPreDisassemble;

onPreInitPart

Represents the on pre init part event. invoked after fields are assigned but before init part logic has run.

public event Action onPreInitPart;

onPostInitPart

Represents the on post init part event. invoked after init part logic has run.

public event Action onPostInitPart;

onPartBolted

Represents the on part bolted. invoked when the part has been completely bolted..

public event Action onPartBolted;

onPartUnBolted

Represents the on part unbolted. invoked when the part has been completely unbolted.

public event Action onPartUnBolted;

onBoltScrew

Represents the on bolt screwed. occurs when any of the bolts have been screwed (up or down).

public event Action onBoltScrew;

onPartPickUp

Represents the on part picked up event. occurs when this part has been picked up.

public event Action onPartPickUp;

onPartThrow

Represents the on part thrown event. occurs when this part has been thrown.

public event Action onPartThrow;

onPartDrop

Represents the on part dropped event. occurs when this part has been dropped.

public event Action onPartDrop;

onJointBreak

Represents the on joint break event. occurs when this parts Joint breaks. invoked after disassembly logic executes.

public event Action<float> onJointBreak;
Clone this wiki locally