GearLib
Loading...
Searching...
No Matches
GearLib.API.Part Class Reference

Base class to use when creating a new Part.

These can be created using:
Part new_part = new Part(args);

or by inheriting like so:
class NewPart : Part
{
public NewPart() : base(args)
{
// Your code here
}
}
More...

Public Member Functions

 Part (ulong part_uid, string display_name, string category, float mass=1f, string bundle_path=null, string asset_name=null, string asset_path=null, string asset=null, bool is_paintable=false, bool is_swappable_material=false, bool mesh_collider=false)
 Creates a new Part within the game. No attachment points will be available unless specified.
 
AddBehaviour< T > ()
 Adds a Behaviour to your Part. Behaviours are logic that runs on your part. A part can have multiple Behaviours.
 
void AddLinkPoint (string name, string link_type, Vector3 position, bool can_send=true, bool can_receive=true)
 Adds a Link Point to your Part. This allows players to connect Parts together for logic.
 
void AddAttachmentPoint (string attachment_name, AttachmentTypeFlags attachment_flags, AlignmentFlags alignment_flags, Vector3 position, Vector3 orientation, Vector3Int size, bool pivot=false)
 Adds an Attachment Point to your Part. This allows players to attach it to things or things to it.
 
void SetAttachmentSize (string attachment_name, Vector3Int size)
 Allows you to alter the unit size of your attachments on the Part.
 
void AddCalculatedPointGrid (AttachmentTypeFlags attachment_flags)
 

Public Attributes

GameObject game_object
 
PartDescriptor descriptor
 

Static Public Attributes

static GameObject loading_object = LoaderUtil.LoadObject("GearLib/gearlib", "Cube")
 

Detailed Description

Base class to use when creating a new Part.

These can be created using:
Part new_part = new Part(args);

or by inheriting like so:
class NewPart : Part
{
public NewPart() : base(args)
{
// Your code here
}
}

Constructor & Destructor Documentation

◆ Part()

GearLib.API.Part.Part ( ulong part_uid,
string display_name,
string category,
float mass = 1f,
string bundle_path = null,
string asset_name = null,
string asset_path = null,
string asset = null,
bool is_paintable = false,
bool is_swappable_material = false,
bool mesh_collider = false )

Creates a new Part within the game. No attachment points will be available unless specified.

Parameters
bundle_pathPath to the bundle within your mod folder. For example "CombustionMotors/assets/my_asset_bundle"
asset_nameThe name of your asset within the bundle.
part_uidUnique ID for your part. This must be unique even across other mods, so randomize a big number!
display_nameThe name that will be used when players interact with it in game.
categoryString ID representation of the category you want it listed in. Default categories in game are: (Area, Blocks, Bodies, Brakes & Clutches, Checkpoints, Connectors, Control Wheels, Electronics, Gears, Lights, Linear Actuators, Motors, Power, Props, Pulleys, Seats, Suspension, Wheels)
massWeight of your part
is_paintableDetermines if the part is paintable. Default is false
is_swappable_materialDetermines if the part material can be changed. Default is false
Returns
Returns your new Part object. Further methods can be called for adding attachments, links, etc.

Member Function Documentation

◆ AddAttachmentPoint()

void GearLib.API.Part.AddAttachmentPoint ( string attachment_name,
AttachmentTypeFlags attachment_flags,
AlignmentFlags alignment_flags,
Vector3 position,
Vector3 orientation,
Vector3Int size,
bool pivot = false )

Adds an Attachment Point to your Part. This allows players to attach it to things or things to it.

Parameters
attachment_nameThe name of your Attachment Point. This is just a unique name for you to utilize in your Behaviours.
attachment_flagsClass from the base game. This determines what style attachment you'll have, for example, knuckle joints, spherical, fixed, etc.
alignment_flagsClass from the base game. This determines the alignment required for your attachment, for example, bi-directional, only 90 degrees, only 180, etc.
positionUnit position on your part this attachment will be added.
orientationThe unit direction your attachment will face, so to speak.
sizeThe size in units your attachment will be.
pivotDetermines if other parts can attach to your part, or only your part can attach to them. Default is false

◆ AddBehaviour< T >()

T GearLib.API.Part.AddBehaviour< T > ( )

Adds a Behaviour to your Part. Behaviours are logic that runs on your part. A part can have multiple Behaviours.

Parameters
TT Represents your Behaviour class with all it's logic.
Returns
Returns your instanced Behaviour object on the Part.
Type Constraints
T :Behaviour 

◆ AddLinkPoint()

void GearLib.API.Part.AddLinkPoint ( string name,
string link_type,
Vector3 position,
bool can_send = true,
bool can_receive = true )

Adds a Link Point to your Part. This allows players to connect Parts together for logic.

Parameters
nameThe name of your Link Point. This is just a unique name for you to utilize in your Behaviours.
link_typeUnique string ID of the link type you'll be using.
positionThe position in 3D space to place your link point.
can_sendDetermines if you can send data from this link. Default is true
can_receiveDetermines if you can receive data from this link. Default is true

◆ SetAttachmentSize()

void GearLib.API.Part.SetAttachmentSize ( string attachment_name,
Vector3Int size )

Allows you to alter the unit size of your attachments on the Part.

Parameters
attachment_nameThe name of your Attachment Point.
sizeThe size in units your attachment will be.

The documentation for this class was generated from the following file: