Part Class

From KitHack Model Club Wiki
Jump to navigation Jump to search

Back to SDK API Reference

Part Class

This class represents a part in the game, which can be a component of a vehicle, and handles various functionalities related to part interactions, physics, and connections within the game world.

Public Constant Fields

Public Fields

  • `public int constructID` - The construct ID of the part.
  • `public uint vehicleID` - The vehicle ID the part is associated with.
  • `public NetworkIdentity networkID` - The network identity of the part.
  • `public PartInfo partInfo` - Information about the part.
  • `public Vehicle vehicle` - The vehicle the part is attached to.
  • `public List<Part> Links` - List of linked parts.
  • `public List<Part> SymParts` - List of symmetrical parts.
  • `public int symmetryMode` - The symmetry mode of the part.
  • `public Vector3 attachPoint` - The attach point of the part.
  • `public int srfNodeIndex` - Index of the surface node.
  • `public float attachSrfOffset` - Offset for surface attachment.
  • `public Quaternion postAttachRot` - Rotation after attachment.
  • `public SymmetryPreference symmetryPreference` - Preference for symmetry.
  • `public AttachmentMethod primaryAttachMethod` - Method of primary attachment.
  • `public GrabAnchor initialGrabAnchor` - Initial grab anchor.
  • `public bool noSymmetryCenterlineMerge` - Indicates if there is no symmetry centerline merge.
  • `public bool canBeVehicleRoot` - Indicates if the part can be the vehicle root.
  • `public bool noMoveOffset` - Indicates if there is no move offset.
  • `public bool noRotateOffset` - Indicates if there is no rotate offset.
  • `public bool noSurfaceAttach` - Indicates if surface attachment is not allowed.
  • `public string craftContextHint` - Hint for the craft context.
  • `public PartInternalFootprint internalFootprint` - Internal footprint of the part.
  • `public PartInternalSpace internalSpace` - Internal space of the part.
  • `public List<PartAttachPlane> attachPlanes` - List of attach planes.
  • `public bool hasVolumeSrfForcesOverride` - Indicates if there is a volume surface forces override.
  • `public bool hasVolumeBuoyForcesOverride` - Indicates if there is a volume buoy forces override.
  • `public bool connected` - Indicates if the part is connected.
  • `public bool attached` - Indicates if the part is attached.
  • `public bool isIconInstance` - Indicates if the part is an icon instance.
  • `public List<PartModule> Modules` - List of part modules.
  • `protected PartModel _model` - Model of the part.
  • `protected PartPhysics _physics` - Physics of the part.
  • `protected PartInternalPhysics internalPhysics` - Internal physics of the part.
  • `protected PartBuoyancy buoyancy` - Buoyancy of the part.
  • `protected PartVolumetrics volumetrics` - Volumetrics of the part.
  • `protected PartBreakage breakage` - Breakage of the part.
  • `protected PartFX _fx` - FX of the part.
  • `protected PartContextMenu _ctxMenu` - Context menu of the part.
  • `protected PartUISounds uiSounds` - UI sounds of the part.
  • `protected PartWind wind` - Wind effects on the part.
  • `public List<ResourcePort> ResourcePorts` - List of resource ports.
  • `protected PartHighlighter hilighter` - Highlighter for the part.
  • `protected PtrSelectableObject ptrSelectable` - Selectable pointer object for the part.
  • `protected List<Collider> partColliders` - List of colliders for the part.
  • `private Part parent` - Parent part.
  • `public int lastRecurseId` - Last recurse ID.
  • `private int lastRecurseId_RecurseChildren` - Last recurse ID for recurse children.
  • `private int lastRecurseId_RecurseParentwise` - Last recurse ID for recurse parentwise.

Public Delegates

Public Events

  • `public event Action<Part, Transform> OnTransformParentChanged` - Event triggered when the transform parent changes.

Public Enums

Public Interfaces

  • `IPartWeaponDamageHandler` - Interface for handling weapon damage.
  • `IWeaponDamageHandler` - Interface for handling weapon damage.
  • `IGameObject` - Interface for game objects.
  • `IPart` - Interface for parts.

Public Properties

  • `public bool InternalSelectable { get; }` - Indicates if the part is internally selectable.
  • `public bool IsVehicleRoot { get; }` - Indicates if the part is the root of the vehicle.
  • `public bool Connected { get; }` - Indicates if the part is connected.
  • `public Vector3 p0 { get; protected set; }` - Initial position of the part.
  • `public Quaternion r0 { get; protected set; }` - Initial rotation of the part.
  • `public PartModel model { get; }` - Gets the part model.
  • `public PartPhysics physics { get; }` - Gets the part physics.
  • `public PartInternalPhysics InternalPhysics { get; }` - Gets the internal physics of the part.
  • `public PartBuoyancy Buoyancy { get; }` - Gets the buoyancy of the part.
  • `public PartVolumetrics Volumetrics { get; }` - Gets the volumetrics of the part.
  • `public PartBreakage Breakage { get; }` - Gets the breakage of the part.
  • `public PartFX Fx { get; }` - Gets the FX of the part.
  • `public PartContextMenu CtxMenu { get; }` - Gets the context menu of the part.
  • `public PartUISounds UiSounds { get; }` - Gets the UI sounds of the part.
  • `public PartWind Wind { get; }` - Gets the wind effects on the part.
  • `public bool spawned { get; protected set; }` - Indicates if the part is spawned.
  • `public PartHighlighter Hilighter { get; }` - Gets the highlighter for the part.
  • `public PtrSelectableObject PtrSelectable { get; }` - Gets the selectable pointer object for the part.
  • `public VehiclePhysics RootPhysics { get; }` - Gets the root physics of the part.
  • `public string IdName { get; }` - Gets the ID name of the part.
  • `public string FullName { get; }` - Gets the full name of the part.
  • `public Part Parent { get; set; }` - Gets or sets the parent part.
  • `public bool HasChildren { get; }` - Indicates if the part has children.
  • `public IEnumerable<Part> Children { get; }` - Gets the children of the part.
  • `public IEnumerable<Part> Descendants { get; }` - Gets the descendants of the part.
  • `public IEnumerable<Part> Ancestors { get; }` - Gets the ancestors of the part.

Public Methods

  • `public void AssimilateLoadedAsset(GameObject partGo)` - Assimilates a loaded asset.
  • `public void OnPrefabLoad(ConfigNode node)` - Loads the prefab configuration.
  • `public void Save(ConfigNode node, CfgContext context)` - Saves the part configuration.
  • `public void Load(ConfigNode node, CfgContext context)` - Loads the part configuration.
  • `public virtual void OnSave(ConfigNode node, CfgContext context)` - Called when saving the part.
  • `public virtual void OnLoad(ConfigNode node, CfgContext context)` - Called when loading the part.
  • `protected void Awake()` - Called when the part is instantiated.
  • `protected void OnEnable()` - Called when the part is enabled.
  • `protected void OnDisable()` - Called when the part is disabled.
  • `public void Start()` - Called when the part starts.
  • `private void onInputLocksModified(FromToAction<ControlTypes> arg0)` - Handles input lock modifications.
  • `public void SetInitialPosRot(Vector3 position, Quaternion rotation)` - Sets the initial position and rotation.
  • `public void OnSpawn(bool spawnedAsClone)` - Called when the part is spawned.
  • `internal void OnAddedToVehicle(bool jip)` - Called when the part is added to a vehicle.
  • `public IEnumerable<T> GetModules<T>()` - Gets modules of a specific type.
  • `public IEnumerable<PartModule> GetModulesWithIDs(params string[] tgtModuleIDs)` - Gets modules with specific IDs.
  • `public PartModule GetModuleWithID(string id)` - Gets a module with a specific ID.
  • `public T GetModuleWithID<T>(string id) where T : PartModule` - Gets a module with a specific ID and type.
  • `public Ti GetModuleWithIDImplementing<Ti>(string id)` - Gets a module implementing a specific interface with a specific ID.
  • `public float GetModuleCostOffsets(float partBaseCost)` - Gets the cost offsets of modules.
  • `public Transform Transform { get; }` - Gets the transform of the part.
  • `public GameObject GameObject { get; }` - Gets the game object of the part.
  • `internal void OnEditorStart()` - Called when the editor starts.
  • `internal void OnEditorEnd()` - Called when the editor ends.
  • `public int GenerateConstructID(List<Part> parts)` - Generates a construct ID.
  • `public void SetTransformParent(Transform parent, bool recursive = false)` - Sets the transform parent.
  • `public void SetTransformParent(Transform parent, bool worldPositionStays, bool recursive = false)` - Sets the transform parent with world position stay option.
  • `public void SetLayerRecursive(int layer, int skipLayersMask = 0)` - Sets the layer recursively.
  • `public void ResetHighlighters()` - Resets the highlighters.
  • `public void LinkTo(Part part, PartAttachNode partAttachNode, PartAttachPlane partAttachPlane = null)` - Links the part to another part.
  • `public void UnlinkFrom(Part toDelete)` - Unlinks the part from another part.
  • `public AttachBlob FindBlobForLink(Part linksTo)` - Finds the blob for a link.
  • `public AttachBlob FindBlobByID(string id)` - Finds a blob by ID.
  • `public PartAttachNode FindNodeForLink(Part linksTo)` - Finds a node for a link.
  • `public PartAttachPlane FindPlaneForLink(Part p1)` - Finds a plane for a link.
  • `public IEnumerable<Part> FindLinksViaBlob(AttachBlob blob)` - Finds links via a blob.
  • `public List<PartAttachNode> GetAllAttachNodes()` - Gets all attach nodes.
  • `public ResourcePort FindResourcePort(string portID)` - Finds a resource port by ID.
  • `public ResourcePort FindResourcePortForNode(ResourcePortNode portNode)` - Finds a resource port for a node.
  • `public PartAttachNode FindAttachNodeById(string id)` - Finds an attach node by ID.
  • `public PartAttachNode FindPartAttachNodeForNode(AttachNode node)` - Finds a part attach node for a node.
  • `public Part FindPartThroughNode(AttachNode node)` - Finds a part through a node.
  • `public Part FindPartThroughNode(PartAttachNode node)` - Finds a part through a part attach node.
  • `public Part GetRoot()` - Gets the root part.
  • `public bool CanBeSetRoot()` - Indicates if the part can be set as root.
  • `public void MakeSetRoot()` - Makes the part the root.
  • `protected void SetRoot(Part newRoot, int recurseID)` - Sets the root part.
  • `public void SetConnected(bool connected)` - Sets the connected state of the part.
  • `public void SetPosRotRecursive(Vector3 wPos, Quaternion wRot)` - Sets the position and rotation recursively.
  • `public void SetPosRotRecursive(PosRot wPosRot)` - Sets the position and rotation recursively using a PosRot object.
  • `public bool IsAttachedDescendant(Part ofPart, bool includeSelf = true)` - Checks if the part is an attached descendant.
  • `public bool IsAttachedAncestor(Part ofPart, bool includeSelf = true)` - Checks if the part is an attached ancestor.
  • `public bool IsHierarchyDescendant(Part ofPart, bool includeSelf = true)` - Checks if the part is a hierarchy descendant.
  • `public bool IsHierarchyAncestor(Part ofPart, bool includeSelf = true)` - Checks if the part is a hierarchy ancestor.
  • `public List<Part> GetHierarchySet()` - Gets the hierarchy set of parts.
  • `public void GetHierarchySet(ref List<Part> parts)` - Gets the hierarchy set of parts recursively.
  • `protected void GetHierarchySet(ref List<Part> parts, Part part)` - Helper method to get the hierarchy set of parts recursively.
  • `public int? GetDFSIndexFromPart(Part fromPart)` - Gets the DFS index from a part.
  • `public IEnumerable<Part> RecurseChildren(bool includeSelf = true, int? rID = null)` - Recurses through children parts.
  • `public IEnumerable<Part> RecurseParentwise(Part part, bool includeSelf = true, int? rID = null)` - Recurses through parentwise parts.
  • `public bool IsServer { get; }` - Indicates if the part is on the server.
  • `public bool IsClient { get; }` - Indicates if the part is on the client.
  • `public bool IsVehicleRoot { get; }` - Indicates if the part is the vehicle root.
  • `public void OnWeaponDamage(Vector3 force, Vector3 point, Ballistics.ShotSimData ssd, Ballistics.AmmoData ammoData)` - Handles weapon damage on the part.
  • `public void Cmd_SetBroken(bool broken)` - Sets the broken state of the part.
  • `protected void Rpc_OnWeaponDamage(Vector3 force, Vector3 point)` - RPC method for handling weapon damage.
  • `private void MirrorProcessed()` - Called when Mirror processes the part.
  • `public int NetworkconstructID { get; set; }` - Gets or sets the network construct ID.
  • `public uint NetworkvehicleID { get; set; }` - Gets or sets the network vehicle ID.
  • `protected void UserCode_Rpc_OnWeaponDamage__Vector3__Vector3(Vector3 force, Vector3 point)` - User code for handling weapon damage.
  • `protected static void InvokeUserCode_Rpc_OnWeaponDamage__Vector3__Vector3(NetworkBehaviour obj, NetworkReader reader, NetworkConnectionToClient senderConnection)` - Invokes user code for handling weapon damage.
  • `public override void SerializeSyncVars(NetworkWriter writer, bool forceAll)` - Serializes the sync variables.
  • `public override void DeserializeSyncVars(NetworkReader reader, bool initialState)` - Deserializes the sync variables.

Public Structs

Public Classes

See Also

  • Vehicle Class
  • NetworkIdentity Class
  • PartInfo Class
  • PartModule Class
  • VehiclePhysics Class
  • AttachNode Class
  • AttachBlob Class
  • ResourcePort Class
  • PartAttachNode Class
  • PartAttachPlane Class
  • GameObject Class
  • Transform Class
  • ConfigNode Class
  • PosRot Struct