-
Notifications
You must be signed in to change notification settings - Fork 17
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
Represents the default save info for this part.
public PartSaveInfo defaultSaveInfo { get; set; }
Represents the parts settings.
public PartSettings partSettings { get; }
Represents the runtime id of this part.
public string partID { get; }
Represents if the part is completely bolted or not.
public bool bolted { get; }
Represents if the part is installed or not.
public bool installed { get; }
Represents if this part has any bolts!
public virtual bool hasBolts { get; }
if this part or the install point its installed to has bolts.
public bool hasAnyBolts { get; }
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; }
Represents if this part is currently picked up.
public bool pickedUp { get; internal set; }
Represents if the part is in a trigger.
public bool inTrigger { get; }
Represents the tightness step. calculated in . how much the breakforce of the install point joint increases per bolt screw.
public float tightnessStep { get; }
Represents max tightness of all bolts.(8 * Part.bolts.Length). if any present on part. (Part.hasBolts)
public float maxTightnessTotal { get; }
Represents tightness of all bolts (BoltSaveInfo.boltTightness * Part.bolts.Length). if any present on part. (Part.hasBolts)
public float tightnessTotal { get; }
Represents the cachedMass. Cached on initPart, assemble and disassemble.
public float cachedMass { get; }
Represents all bolts for the part.
public virtual Bolt[] bolts { get; }
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; }
GameObject
Represents the Parts Trigger type. The part will be installable to any Trigger with the same trigger type. (TriggerData)
public TriggerData triggerData { get; }
Represents the fixed joint when using AssembleType.joint and installed.
public FixedJoint joint { get; }
FixedJoint
Represents the cached rigidbody.
public Rigidbody cachedRigidBody { get; }
Rigidbody
Represents the install point that the part is installed to. (Trigger).
public Trigger installPoint { get; }
Cached part transform
public Transform transform { get; }
Transform
Cached part gameobject
public GameObject gameObject { get; }
GameObject
public bool useGUILayout { get; set; }
public bool enabled { get; set; }
public bool isActiveAndEnabled { get; }
public Transform transform { get; }
Transform
public GameObject gameObject { get; }
GameObject
public string tag { get; set; }
public string name { get; set; }
public HideFlags hideFlags { get; set; }
HideFlags
public Part()
Represents the joint break runtime call
protected virtual void OnJointBreak(float breakForce)
breakForce
Single
Represents the part in a trigger logic.
public virtual IEnumerator partInTrigger(Trigger trigger)
trigger
Trigger
The trigger callback that invoked this call.
Initializes this part. with save info reference
public virtual void initPart(PartSaveInfo saveInfo, TriggerData triggerData, PartSettings partSettingsRef, Bolt[] boltRefs)
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
Initializes this part with bolts and without save info reference.
public virtual void initPart(TriggerData triggerData, PartSettings partSettingsRef, Bolt[] boltRefs)
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
Initializes this part.
public virtual void initPart(PartInitData data)
data
PartInitData
The data to load this part with.
installs this part to the install point.
public virtual void assemble(Trigger installPoint, bool playSound)
installPoint
Trigger
The install point
playSound
Boolean
Play assemble sound?
Disassemble this part from the installed point
public virtual void disassemble(bool playSound)
playSound
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)
getBoltInfo
Boolean
Sets the triggers disasemble logic enable (install point).
public virtual void enableDisassembleLogic(bool active)
active
Boolean
active or not [part]
caches and stores a reference to the parts rigidbody.
public virtual void cacheRigidbody()
Makes the part a pickable item depending on the provided values.
public void makePartPickable(bool pickable)
pickable
Boolean
Make part pickable?
resets all bolts tightness on this part
public void resetBoltTightness()
sets all bolt tightness to the max tightness.
public void setMaxBoltTightness()
if part autosave data exists.
public bool doesSaveDataExist()
Vaildates the part and reports to mod console. called at: Part.initPart(PartSaveInfo, TriggerData, PartSettings, Bolt[]).
protected virtual void vaildiatePart(PartSettings partSettings)
partSettings
PartSettings
Updates from current state of . see: BoltSaveInfo.boltTightness and BoltSaveInfo.addNutTightness
protected internal virtual void updateTotalBoltTightness()
updates the max tightness of the bolts.
protected virtual void updateMaxTotalBoltTightness()
Updates joint breakforce. (bolts)
protected internal virtual void updateJointBreakForce()
checks all bolts for their Bolt.tightness. invokes, Part.enableDisassembleLogic(Boolean) and invokes Part.onPartBolted, Part.onPartUnBolted events.
protected virtual void boltTightnessCheck()
Vaildiates bolt refs. called prior to initialization of bolts on the part.
protected virtual bool vaildiateBolts(Bolt[] boltRefs)
boltRefs
Bolt[]
the bolt refs to vaildiate.
Boolean
True if no issues were detected with the bolt references.
Check for deciding if part is in trigger to be installed
protected virtual bool colliderCheck(Trigger trigger)
trigger
Trigger
the trigger.
Represents the holding check for a Part. Used for starting and checking trigger routine. Part.partInTrigger(Trigger)
protected virtual bool holdingCheck(Trigger trigger)
trigger
Trigger
The trigger
initializes the bolts.
public virtual void initBolts(Bolt[] bolts)
bolts
Bolt[]
invoked when this part enters one of its triggers.
protected internal virtual void onTriggerEnter(Trigger trigger)
trigger
Trigger
the trigger callback that invoked this.
invoked when this part exits one of its triggers.
protected internal virtual void onTriggerExit(Trigger trigger)
trigger
Trigger
the trigger callback that invoked this.
invoked when any bolt on this part is screwed in or out.
protected internal virtual void boltOnScrew()
invokes the picked up event
internal void invokePickedUpEvent()
invokes the thrown event.
internal void invokeThrownEvent()
invokes the dropped event.
internal void invokeDroppedEvent()
internal static bool <disassemble>g__func|117_1(Bolt b)
b
Bolt
Represents the on assemble event.invoked after assembly logic executes
public event Action onAssemble;
Represents the on disassemble event. invoked after disassembly logic executes
public event Action onDisassemble;
Represents the on pre assemble event. invoked before assembly logic executes
public event Action onPreAssemble;
Represents the on pre disassemble event. invoked before disassembly logic executes
public event Action onPreDisassemble;
Represents the on pre init part event. invoked after fields are assigned but before init part logic has run.
public event Action onPreInitPart;
Represents the on post init part event. invoked after init part logic has run.
public event Action onPostInitPart;
Represents the on part bolted. invoked when the part has been completely bolted..
public event Action onPartBolted;
Represents the on part unbolted. invoked when the part has been completely unbolted.
public event Action onPartUnBolted;
Represents the on bolt screwed. occurs when any of the bolts have been screwed (up or down).
public event Action onBoltScrew;
Represents the on part picked up event. occurs when this part has been picked up.
public event Action onPartPickUp;
Represents the on part thrown event. occurs when this part has been thrown.
public event Action onPartThrow;
Represents the on part dropped event. occurs when this part has been dropped.
public event Action onPartDrop;
Represents the on joint break event. occurs when this parts Joint breaks. invoked after disassembly logic executes.
public event Action<float> onJointBreak;