Skip to content

ModClient

Tommo J. Phillips edited this page Oct 22, 2023 · 2 revisions

ModClient

Namespace: TommoJProductions.ModApi

Caches references for interacting with My Summer Car and PlayMaker. via Lazy Initialization. Many helpful functions to help mod developers make mods, GUI functions, extended Mathf functions, raycast functions, sound functions. ModAPI Cache gets reset on GAME load.

public class ModClient

Inheritance ObjectModClient

Fields

VERSION

Represents the complied runtime version of the api.

public static string VERSION;

Properties

instance

Gets the current ModClient instance.

public static ModClient instance { get; }

Property Value

ModClient

assembleAudio

Cache. Represents the assemble assemble audio source.

public static AudioSource assembleAudio { get; }

Property Value

AudioSource

disassembleAudio

Cache. Represents the disassemble audio source.

public static AudioSource disassembleAudio { get; }

Property Value

AudioSource

screwAudio

Cache. Represents the bolt screw audio source.

public static AudioSource screwAudio { get; }

Property Value

AudioSource

guiDisassemble

Cache. Represents whether the gui disassemble icon is shown or not. (Circle with line through it.)

public static FsmBool guiDisassemble { get; }

Property Value

FsmBool

guiDisassembleBool

Represents whether the gui disassemble icon is shown or not. (Circle with line through it.)

public static bool guiDisassembleBool { get; set; }

Property Value

Boolean

guiAssemble

Represents whether the gui assemble icon is shown or not. (Tick Symbol)

public static FsmBool guiAssemble { get; }

Property Value

FsmBool

guiAssembleBool

Represents whether the gui assemble icon is shown or not. (Tick Symbol)

public static bool guiAssembleBool { get; set; }

Property Value

Boolean

guiUse

Represents whether or not the gui use icon is shown. (Hand Symbol)

public static FsmBool guiUse { get; }

Property Value

FsmBool

guiUseBool

Represents whether or not the gui use icon is shown. (Hand Symbol)

public static bool guiUseBool { get; set; }

Property Value

Boolean

guiInteraction

Represents whether or not to display gui interaction text.

public static FsmString guiInteraction { get; }

Property Value

FsmString

guiInteractionBool

Represents whether or not to display gui interaction text.

public static string guiInteractionBool { get; set; }

Property Value

String

guiDrive

Represents whether or not to display gui drive icon.

public static FsmBool guiDrive { get; }

Property Value

FsmBool

guiDriveBool

Represents whether or not to display gui drive icon.

public static bool guiDriveBool { get; set; }

Property Value

Boolean

playerInMenu

Represents whether or not the player is in the menu in GAME. (controls the cursor)

public static FsmBool playerInMenu { get; }

Property Value

FsmBool

playerInMenuBool

Represents whether or not the player is in the menu in GAME. (controls the cursor)

public static bool playerInMenuBool { get; set; }

Property Value

Boolean

playerCurrentVehicle

Represents the player current vehicle state.

public static FsmString playerCurrentVehicle { get; }

Property Value

FsmString

getMode

Gets the current player mode,

public static PlayerMode getMode { get; }

Property Value

PlayerMode

loadedParts

Represents all parts in the current instance of my summer car. (msc mods that use MODAPI.Attachable.Part will be listed here)

public static List<Part> loadedParts { get; }

Property Value

List<Part>

loadedBolts

Represents all bolts in the current instance of my summer car. (Parts that use bolts will be listed here)

public static List<Bolt> loadedBolts { get; }

Property Value

List<Bolt>

getHandPickUpFsm

Cache. Gets the pickup playmakerfsm from the hand gameobject.

public static PlayMakerFSM getHandPickUpFsm { get; }

Property Value

PlayMakerFSM

getPickedUpGameObject

Cache. Gets the gameobject that the player is holding.

public static FsmGameObject getPickedUpGameObject { get; }

Property Value

FsmGameObject

getRaycastHitGameObject

Cache. Gets the gameobject that the player is looking at.

public static FsmGameObject getRaycastHitGameObject { get; }

Property Value

FsmGameObject

isInHandMode

Cache. Returns true if in hand mode. determines state by ModClient.getHandPickUpFsm.Active.

public static bool isInHandMode { get; }

Property Value

Boolean

isHandEmpty

Cache. Returns true if player is not holding anything

public static bool isHandEmpty { get; }

Property Value

Boolean

getModsFolderFi

Cache. Gets modloaer mods folder field info.

public static FieldInfo getModsFolderFi { get; }

Property Value

FieldInfo

getModsFolder

Cache. Gets the currently used mods folder path.

public static string getModsFolder { get; }

Property Value

String

getToolWrenchSize_boltSize

Cache. gets the currently used wrench size casted to a BoltSize

public static BoltSize getToolWrenchSize_boltSize { get; }

Property Value

BoltSize

getToolWrenchSize_float

Cache. gets the currently used wrench size

public static float getToolWrenchSize_float { get; }

Property Value

Single

getSpannerBoltingSpeed

Gets the spanner bolting speed wait time.

public static float getSpannerBoltingSpeed { get; }

Property Value

Single

getRachetBoltingSpeed

Gets the rachet bolting speed wait time.

public static float getRachetBoltingSpeed { get; }

Property Value

Single

getActiveBoltMaterial

Cache. Gets the active bolt material. (green bolt texture)

public static Material getActiveBoltMaterial { get; }

Property Value

Material

getMasterAudioGameObject

Cache. gets the master audio gameobject and caches a reference.

public static GameObject getMasterAudioGameObject { get; }

Property Value

GameObject

getPOV

Cache. gets and stores a reference to the player camera gameobject (parent of player camera). PATH: "PLAYER/Pivot/AnimPivot/Camera/FPSCamera/FPSCamera"

public static GameObject getPOV { get; }

Property Value

GameObject

getPlayer

Cache. gets and stores a reference to the player gameobject. PATH: "PLAYER"

public static GameObject getPlayer { get; }

Property Value

GameObject

getFPS

Cache. gets and stores a reference to the player fps gameobject. PATH: "PLAYER/Pivot/AnimPivot/Camera/FPSCamera"

public static GameObject getFPS { get; }

Property Value

GameObject

getPlayerCamera

cache. gets and stores a reference to the player camera.

public static Camera getPlayerCamera { get; }

Property Value

Camera

getGameFolder

Cache. Gets the full game directory path on the user system.

public static string getGameFolder { get; }

Property Value

String

getPlayerHasRatchet

Cache. Represents if the player is using the ratchet.

public static FsmBool getPlayerHasRatchet { get; }

Property Value

FsmBool

getRatchetSwitch

Cache. Represents if the ratchet is switched. (direction)

public static FsmBool getRatchetSwitch { get; }

Property Value

FsmBool

devModeBehaviour

Represents the dev mode behaviour instance. null if is .

public static DevMode devModeBehaviour { get; internal set; }

Property Value

DevMode

levelManager

Represents modapi behaviour

public static LevelManager levelManager { get; internal set; }

Property Value

LevelManager

getBoltManager

Cache. Gets The Bolt Manager.

public static BoltManager getBoltManager { get; }

Property Value

BoltManager

getInteractionManager

Cache. Gets The Interaction Manager.

public static InteractionManager getInteractionManager { get; }

Property Value

InteractionManager

getPartManager

Cache. Gets The Part Manager.

public static PartManager getPartManager { get; }

Property Value

PartManager

modapiGo

Represents the gameobject that holds the dev mode behaviour. gameobject is used to detect if game has been re-loaded/changed. used to inject mod api related stuff.

public static GameObject modapiGo { get; }

Property Value

GameObject

loaded

Represents if ModAPI is Loaded or not.

public static bool loaded { get; }

Property Value

Boolean

Constructors

ModClient()

public ModClient()

Methods

drawPropertyEdit(String, Double, Int32)

[GUI] draws a double property that can be edited

public static double drawPropertyEdit(string propertyName, double property, int maxLength)

Parameters

propertyName String
The property double name

property Double
the reference double to draw/edit

maxLength Int32
max length of textfield

Returns

Double

drawPropertyBool(String, Boolean&)

[GUI] draws a bool that can be edited

public static bool drawPropertyBool(string propertyName, Boolean& property)

Parameters

propertyName String
the property bool name

property Boolean&
the reference bool to draw/edit

Returns

Boolean
if has changed.

drawPropertyBool(String, Boolean)

[GUI] draws a bool that can be edited

public static bool drawPropertyBool(string propertyName, bool property)

Parameters

propertyName String
the property bool name

property Boolean
the reference bool to draw/edit

Returns

Boolean

drawProperty(Object)

[GUI] draws a property.

public static void drawProperty(object property)

Parameters

property Object
the reference of the property to draw.

drawProperty(String)

[GUI] draws a property.

public static void drawProperty(string property)

Parameters

property String
the reference of the property to draw.

drawProperty(Object, Object)

[GUI] draws a property.

public static void drawProperty(object propertyName, object property)

Parameters

propertyName Object
The property object name

property Object
the reference of the property to draw.

guiInteract(String, GuiInteractSymbol)

Displays Interaction text and an optional symbol. Use ModClient.guiInteractReset() to reset the gui.

public static void guiInteract(string text, GuiInteractSymbol guiInteractSymbol)

Parameters

text String
The text to display.

guiInteractSymbol GuiInteractSymbol
Whether or not to display a symbol.

guiInteractReset()

Resets the interaction text and symbol. Turns off the interaction.

public static void guiInteractReset()

print(String, Object[])

Reps modapi print-to-console function

public static void print(string format, Object[] args)

Parameters

format String

args Object[]

getMask(LayerMasks[])

Gets the layermask. Used to make raycast masks. if no masks are passed. returns all layers (everything) '~0'

public static int getMask(LayerMasks[] masks)

Parameters

masks LayerMasks[]
layermasks

Returns

Int32

raycastForBehaviour<T>(LayerMasks[])

Raycasts for a type of behaviour with a max distance of '1' from the camera at the cursor position.

public static T raycastForBehaviour<T>(LayerMasks[] layers)

Type Parameters

T
the type of behaviour to raycast for.

Parameters

layers LayerMasks[]
the layers to raycast on. Note: if nothing is passed, raycasts on all layers.

Returns

T
the instance of if found. if not returns null.

raycastForBehaviour<T>(Boolean, LayerMasks[])

Raycasts for a type of behaviour with a max distance of '1' from the camera.

public static T raycastForBehaviour<T>(bool centerOfScreen, LayerMasks[] layers)

Type Parameters

T
the type of behaviour to raycast for.

Parameters

centerOfScreen Boolean
if true. uses the center of the screen regardless where the mouse is.

layers LayerMasks[]
the layers to raycast on. Note: if nothing is passed, raycasts on all layers.

Returns

T
the instance of if found. if not returns null.

raycastForBehaviour<T>(Single, LayerMasks[])

Raycasts for a type of behaviour from the camera at the cursor position.

public static T raycastForBehaviour<T>(float maxDistance, LayerMasks[] layers)

Type Parameters

T
the type of behaviour to raycast for.

Parameters

maxDistance Single
the max distance of the ray.

layers LayerMasks[]
the layers to raycast on. Note: if nothing is passed, raycasts on all layers.

Returns

T
the instance of if found. if not returns null.

raycastForBehaviour<T>(Boolean, Single, LayerMasks[])

Raycasts for a type of behaviour

public static T raycastForBehaviour<T>(bool centerOfScreen, float maxDistance, LayerMasks[] layers)

Type Parameters

T
the type of behaviour to raycast for.

Parameters

centerOfScreen Boolean
if true. uses the center of the screen regardless where the mouse is.

maxDistance Single
the max distance of the ray.

layers LayerMasks[]
the layers to raycast on. Note: if nothing is passed, raycasts on all layers.

Returns

T
the instance of if found. if not returns null.

raycast(RaycastHit&, Single, Boolean, LayerMasks[])

raycasts. uses cached player camera (see: ModClient.getPlayerCamera) for improved performace. mod developers using ModAPI are recommended to use this instead of their own calls.

public static bool raycast(RaycastHit& raycastHit, float maxDistance, bool centerOfScreen, LayerMasks[] layers)

Parameters

raycastHit RaycastHit&
the raycast hit info.

maxDistance Single
the max distance of the ray.

centerOfScreen Boolean
if true. uses the center of the screen regardless where the mouse is.

layers LayerMasks[]
the layers to raycast on. Note: if nothing is passed, raycasts on all layers.

Returns

Boolean
if the raycast hit anything.

addES2Type<T, _ES2Type>()

Assigns ES2 types to a type.

public static void addES2Type<T, _ES2Type>()

Type Parameters

T
The type to link to a ES2 type

_ES2Type
The ES2 Type to link to ()

setModApiGo(GameObject)

internal static void setModApiGo(GameObject gameObject)

Parameters

gameObject GameObject

refreshCache()

sets to null. thus next call to ModClient.instance will create a new instance.

internal static void refreshCache()

getData(GameObject, String)

finds child object of name and gets playmaker called, "Data".

internal static PlayMakerFSM getData(GameObject go, string childName)

Parameters

go GameObject

childName String

Returns

PlayMakerFSM
"Data" playmakerFsm on child of .

getRandomIndex(Int32)

Gets a random index, 0 - .

public static int getRandomIndex(int length)

Parameters

length Int32
the max value the random index can be.

Returns

Int32

createParentGameObject(String, Transform)

Creates a Parent on .

public static GameObject createParentGameObject(string parentName, Transform parent)

Parameters

parentName String

parent Transform

Returns

GameObject
The Parent .

createTextureFromColor(Int32, Int32, Color)

creates a texure with the color provided.

public static Texture2D createTextureFromColor(int width, int height, Color col)

Parameters

width Int32
width of texture

height Int32
height of texture

col Color
the color of the texture

Returns

Texture2D
a new texture instance of color param:

playSoundAt(Transform, String, String)

Plays a sound at world position. if sound is already playing, does nothing.

public static void playSoundAt(Transform transform, string soundType, string variantName)

Parameters

transform Transform
the world position to play sound at.

soundType String
The sound type group. eg => CarBuilding

variantName String
The sound variant in the soundType group. eg => Assemble

playSoundAtInterupt(Transform, String, String)

Plays a sound at world position. if sound is already playing, stops and restarts.

public static void playSoundAtInterupt(Transform transform, string soundType, string variantName)

Parameters

transform Transform
the world position to play sound at.

soundType String
The sound type group. eg => CarBuilding

variantName String
The sound variant in the soundType group. eg => Assemble

getMasterAudio(String, String)

Gets the audio source from the master audio gameobject (MasterAudio). path => / | eg => CarBuilding/assemble. adds it to a dictionary for for a less performat hit next time. asking for the same path.

public static AudioSource getMasterAudio(string soundType, string variantName)

Parameters

soundType String
The sound type group. eg => CarBuilding

variantName String
The sound variant in the soundType group. eg => assemble

Returns

AudioSource

unclampedLerp(Single, Single, Single)

Same logic as , but is not clamped. to 0 - 1.

public static float unclampedLerp(float from, float to, float t)

Parameters

from Single

to Single

t Single

Returns

Single

clampedLerp(Single, Single, Single, Single, Single)

Same logic as but defines min and max clamp params for .

public static float clampedLerp(float from, float to, float t, float min, float max)

Parameters

from Single
the start or from value.

to Single
the end or to value.

t Single
the time value.

min Single
The min value for .

max Single
The max value for .

Returns

Single

approximately(Single, Single, Single)

Same logic as but with threshold parameter.

public static bool approximately(float a, float b, float threshold)

Parameters

a Single
the a param to compare

b Single
the b param to compare.

threshold Single

Returns

Boolean

drawGamePartInfo(GamePart)

draws a gui of info about a game part. (use within an ).

public static void drawGamePartInfo(GamePart gp)

Parameters

gp GamePart

drawPropertyVector3(String, Vector3&)

[GUI] draws a vector3 that can be edited.

public static void drawPropertyVector3(string propertyName, Vector3& vector3)

Parameters

propertyName String
The property vector3 name

vector3 Vector3&
the reference vector3 to draw/edit

drawPropertyVector3(String, Vector3)

[GUI] draws a vector3 that can be edited.

public static Vector3 drawPropertyVector3(string propertyName, Vector3 vector3)

Parameters

propertyName String
The property vector3 name

vector3 Vector3
the reference vector3 to draw/edit

Returns

Vector3

drawPropertyEnum<T>(T&)

[GUI] draws an enum that can be edited as a list of toggles.

public static void drawPropertyEnum<T>(T& e)

Type Parameters

T
The type of enum

Parameters

e T&
Reference enum (selected)

drawPropertyEnumVertical<T>(T&)

[GUI] draws an enum that can be edited as a list of toggles.

public static void drawPropertyEnumVertical<T>(T& e)

Type Parameters

T
The type of enum

Parameters

e T&
Reference enum (selected)

drawPropertyEnum<T>(T&, String)

[GUI] draws an enum that can be edited as a list of toggles.

public static void drawPropertyEnum<T>(T& e, string name)

Type Parameters

T
The type of enum

Parameters

e T&
Reference enum (selected)

name String
The name of the member enum.

drawPropertyEnum<T>(T)

[GUI] draws an enum that can be edited as a list of toggles.

public static T drawPropertyEnum<T>(T e)

Type Parameters

T
The type of enum

Parameters

e T
Reference enum (selected)

Returns

T

drawPropertyEnum<T>(T, String)

[GUI] draws an enum that can be edited as a list of toggles.

public static T drawPropertyEnum<T>(T e, string name)

Type Parameters

T
The type of enum

Parameters

e T
Reference enum (selected)

name String
The name of the member enum.

Returns

T

drawPropertyEdit(String, String&, Int32)

[GUI] draws a property of type String that can be edited

public static bool drawPropertyEdit(string propertyName, String& property, int maxLength)

Parameters

propertyName String
The property name

property String&
the reference string to draw/edit

maxLength Int32
max length of textfield (number of letters.)

Returns

Boolean
if has changed.

drawPropertyEdit(String, String, Int32)

[GUI] draws a property of type String that can be edited

public static string drawPropertyEdit(string propertyName, string property, int maxLength)

Parameters

propertyName String
The property name

property String
the reference string to draw/edit

maxLength Int32
max length of textfield (number of letters.)

Returns

String
returns the property

drawPropertyEdit(String, Int32&, Int32)

[GUI] draws a property of type Int32 that can be edited

public static bool drawPropertyEdit(string propertyName, Int32& property, int maxLength)

Parameters

propertyName String
The property int name

property Int32&
the reference int to draw/edit

maxLength Int32
max length of textfield (number of letters.)

Returns

Boolean
if has changed.

drawPropertyEdit(String, Int32, Int32)

[GUI] draws a int property that can be edited

public static float drawPropertyEdit(string propertyName, int property, int maxLength)

Parameters

propertyName String
The property int name

property Int32
the reference int to draw/edit

maxLength Int32
max length of textfield

Returns

Single

drawPropertyEdit(String, Single&, Int32)

[GUI] draws a property of type Single that can be edited

public static bool drawPropertyEdit(string propertyName, Single& property, int maxLength)

Parameters

propertyName String
The property float name

property Single&
the reference float to draw/edit

maxLength Int32
max length of textfield (number of letters.)

Returns

Boolean
if has changed.

drawPropertyEdit(String, Single, Int32)

[GUI] draws a float property that can be edited

public static float drawPropertyEdit(string propertyName, float property, int maxLength)

Parameters

propertyName String
The property float name

property Single
the reference float to draw/edit

maxLength Int32
max length of textfield

Returns

Single

drawPropertyEdit(String, Double&, Int32)

[GUI] draws a property of type Double that can be edited

public static bool drawPropertyEdit(string propertyName, Double& property, int maxLength)

Parameters

propertyName String
The property double name

property Double&
the reference double to draw/edit

maxLength Int32
max length of textfield (number of letters.)

Returns

Boolean
if has changed.

Clone this wiki locally