-
Notifications
You must be signed in to change notification settings - Fork 17
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 Object → ModClient
Represents the complied runtime version of the api.
public static string VERSION;
Gets the current ModClient instance.
public static ModClient instance { get; }
Cache. Represents the assemble assemble audio source.
public static AudioSource assembleAudio { get; }
AudioSource
Cache. Represents the disassemble audio source.
public static AudioSource disassembleAudio { get; }
AudioSource
Cache. Represents the bolt screw audio source.
public static AudioSource screwAudio { get; }
AudioSource
Cache. Represents whether the gui disassemble icon is shown or not. (Circle with line through it.)
public static FsmBool guiDisassemble { get; }
FsmBool
Represents whether the gui disassemble icon is shown or not. (Circle with line through it.)
public static bool guiDisassembleBool { get; set; }
Represents whether the gui assemble icon is shown or not. (Tick Symbol)
public static FsmBool guiAssemble { get; }
FsmBool
Represents whether the gui assemble icon is shown or not. (Tick Symbol)
public static bool guiAssembleBool { get; set; }
Represents whether or not the gui use icon is shown. (Hand Symbol)
public static FsmBool guiUse { get; }
FsmBool
Represents whether or not the gui use icon is shown. (Hand Symbol)
public static bool guiUseBool { get; set; }
Represents whether or not to display gui interaction text.
public static FsmString guiInteraction { get; }
FsmString
Represents whether or not to display gui interaction text.
public static string guiInteractionBool { get; set; }
Represents whether or not to display gui drive icon.
public static FsmBool guiDrive { get; }
FsmBool
Represents whether or not to display gui drive icon.
public static bool guiDriveBool { get; set; }
Represents whether or not the player is in the menu in GAME. (controls the cursor)
public static FsmBool playerInMenu { get; }
FsmBool
Represents whether or not the player is in the menu in GAME. (controls the cursor)
public static bool playerInMenuBool { get; set; }
Represents the player current vehicle state.
public static FsmString playerCurrentVehicle { get; }
FsmString
Gets the current player mode,
public static PlayerMode getMode { get; }
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; }
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; }
Cache. Gets the pickup playmakerfsm from the hand gameobject.
public static PlayMakerFSM getHandPickUpFsm { get; }
PlayMakerFSM
Cache. Gets the gameobject that the player is holding.
public static FsmGameObject getPickedUpGameObject { get; }
FsmGameObject
Cache. Gets the gameobject that the player is looking at.
public static FsmGameObject getRaycastHitGameObject { get; }
FsmGameObject
Cache. Returns true if in hand mode. determines state by ModClient.getHandPickUpFsm.Active.
public static bool isInHandMode { get; }
Cache. Returns true if player is not holding anything
public static bool isHandEmpty { get; }
Cache. Gets modloaer mods folder field info.
public static FieldInfo getModsFolderFi { get; }
Cache. Gets the currently used mods folder path.
public static string getModsFolder { get; }
Cache. gets the currently used wrench size casted to a BoltSize
public static BoltSize getToolWrenchSize_boltSize { get; }
Cache. gets the currently used wrench size
public static float getToolWrenchSize_float { get; }
Gets the spanner bolting speed wait time.
public static float getSpannerBoltingSpeed { get; }
Gets the rachet bolting speed wait time.
public static float getRachetBoltingSpeed { get; }
Cache. Gets the active bolt material. (green bolt texture)
public static Material getActiveBoltMaterial { get; }
Material
Cache. gets the master audio gameobject and caches a reference.
public static GameObject getMasterAudioGameObject { get; }
GameObject
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; }
GameObject
Cache. gets and stores a reference to the player gameobject. PATH: "PLAYER"
public static GameObject getPlayer { get; }
GameObject
Cache. gets and stores a reference to the player fps gameobject. PATH: "PLAYER/Pivot/AnimPivot/Camera/FPSCamera"
public static GameObject getFPS { get; }
GameObject
cache. gets and stores a reference to the player camera.
public static Camera getPlayerCamera { get; }
Camera
Cache. Gets the full game directory path on the user system.
public static string getGameFolder { get; }
Cache. Represents if the player is using the ratchet.
public static FsmBool getPlayerHasRatchet { get; }
FsmBool
Cache. Represents if the ratchet is switched. (direction)
public static FsmBool getRatchetSwitch { get; }
FsmBool
Represents the dev mode behaviour instance. null if is .
public static DevMode devModeBehaviour { get; internal set; }
Represents modapi behaviour
public static LevelManager levelManager { get; internal set; }
Cache. Gets The Bolt Manager.
public static BoltManager getBoltManager { get; }
Cache. Gets The Interaction Manager.
public static InteractionManager getInteractionManager { get; }
Cache. Gets The Part Manager.
public static PartManager getPartManager { get; }
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; }
GameObject
Represents if ModAPI is Loaded or not.
public static bool loaded { get; }
public ModClient()
[GUI] draws a double property that can be edited
public static double drawPropertyEdit(string propertyName, double property, int maxLength)
propertyName
String
The property double name
property
Double
the reference double to draw/edit
maxLength
Int32
max length of textfield
[GUI] draws a bool that can be edited
public static bool drawPropertyBool(string propertyName, Boolean& property)
propertyName
String
the property bool name
property
Boolean&
the reference bool to draw/edit
Boolean
if has changed.
[GUI] draws a bool that can be edited
public static bool drawPropertyBool(string propertyName, bool property)
propertyName
String
the property bool name
property
Boolean
the reference bool to draw/edit
[GUI] draws a property.
public static void drawProperty(object property)
property
Object
the reference of the property to draw.
[GUI] draws a property.
public static void drawProperty(string property)
property
String
the reference of the property to draw.
[GUI] draws a property.
public static void drawProperty(object propertyName, object property)
propertyName
Object
The property object name
property
Object
the reference of the property to draw.
Displays Interaction text and an optional symbol. Use ModClient.guiInteractReset() to reset the gui.
public static void guiInteract(string text, GuiInteractSymbol guiInteractSymbol)
text
String
The text to display.
guiInteractSymbol
GuiInteractSymbol
Whether or not to display a symbol.
Resets the interaction text and symbol. Turns off the interaction.
public static void guiInteractReset()
Reps modapi print-to-console function
public static void print(string format, Object[] args)
format
String
args
Object[]
Gets the layermask. Used to make raycast masks. if no masks are passed. returns all layers (everything) '~0'
public static int getMask(LayerMasks[] masks)
masks
LayerMasks[]
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)
T
the type of behaviour to raycast for.
layers
LayerMasks[]
the layers to raycast on. Note: if nothing is passed, raycasts on all layers.
T
the instance of if found. if not returns null.
Raycasts for a type of behaviour with a max distance of '1' from the camera.
public static T raycastForBehaviour<T>(bool centerOfScreen, LayerMasks[] layers)
T
the type of behaviour to raycast for.
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.
T
the instance of if found. if not returns null.
Raycasts for a type of behaviour from the camera at the cursor position.
public static T raycastForBehaviour<T>(float maxDistance, LayerMasks[] layers)
T
the type of behaviour to raycast for.
maxDistance
Single
the max distance of the ray.
layers
LayerMasks[]
the layers to raycast on. Note: if nothing is passed, raycasts on all layers.
T
the instance of if found. if not returns null.
Raycasts for a type of behaviour
public static T raycastForBehaviour<T>(bool centerOfScreen, float maxDistance, LayerMasks[] layers)
T
the type of behaviour to raycast for.
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.
T
the instance of if found. if not returns null.
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)
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.
Boolean
if the raycast hit anything.
Assigns ES2 types to a type.
public static void addES2Type<T, _ES2Type>()
T
The type to link to a ES2 type
_ES2Type
The ES2 Type to link to ()
internal static void setModApiGo(GameObject gameObject)
gameObject
GameObject
sets to null. thus next call to ModClient.instance will create a new instance.
internal static void refreshCache()
finds child object of name and gets playmaker called, "Data".
internal static PlayMakerFSM getData(GameObject go, string childName)
go
GameObject
childName
String
PlayMakerFSM
"Data" playmakerFsm on child of .
Gets a random index, 0 - .
public static int getRandomIndex(int length)
length
Int32
the max value the random index can be.
Creates a Parent on .
public static GameObject createParentGameObject(string parentName, Transform parent)
parentName
String
parent
Transform
GameObject
The Parent .
creates a texure with the color provided.
public static Texture2D createTextureFromColor(int width, int height, Color col)
width
Int32
width of texture
height
Int32
height of texture
col
Color
the color of the texture
Texture2D
a new texture instance of color param:
Plays a sound at world position. if sound is already playing, does nothing.
public static void playSoundAt(Transform transform, string soundType, string variantName)
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
Plays a sound at world position. if sound is already playing, stops and restarts.
public static void playSoundAtInterupt(Transform transform, string soundType, string variantName)
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
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)
soundType
String
The sound type group. eg => CarBuilding
variantName
String
The sound variant in the soundType group. eg => assemble
AudioSource
Same logic as , but is not clamped. to 0 - 1.
public static float unclampedLerp(float from, float to, float t)
from
Single
to
Single
t
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)
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 .
Same logic as but with threshold parameter.
public static bool approximately(float a, float b, float threshold)
a
Single
the a param to compare
b
Single
the b param to compare.
threshold
Single
draws a gui of info about a game part. (use within an ).
public static void drawGamePartInfo(GamePart gp)
gp
GamePart
[GUI] draws a vector3 that can be edited.
public static void drawPropertyVector3(string propertyName, Vector3& vector3)
propertyName
String
The property vector3 name
vector3
Vector3&
the reference vector3 to draw/edit
[GUI] draws a vector3 that can be edited.
public static Vector3 drawPropertyVector3(string propertyName, Vector3 vector3)
propertyName
String
The property vector3 name
vector3
Vector3
the reference vector3 to draw/edit
Vector3
[GUI] draws an enum that can be edited as a list of toggles.
public static void drawPropertyEnum<T>(T& e)
T
The type of enum
e
T&
Reference enum (selected)
[GUI] draws an enum that can be edited as a list of toggles.
public static void drawPropertyEnumVertical<T>(T& e)
T
The type of enum
e
T&
Reference enum (selected)
[GUI] draws an enum that can be edited as a list of toggles.
public static void drawPropertyEnum<T>(T& e, string name)
T
The type of enum
e
T&
Reference enum (selected)
name
String
The name of the member enum.
[GUI] draws an enum that can be edited as a list of toggles.
public static T drawPropertyEnum<T>(T e)
T
The type of enum
e
T
Reference enum (selected)
T
[GUI] draws an enum that can be edited as a list of toggles.
public static T drawPropertyEnum<T>(T e, string name)
T
The type of enum
e
T
Reference enum (selected)
name
String
The name of the member enum.
T
[GUI] draws a property of type String that can be edited
public static bool drawPropertyEdit(string propertyName, String& property, int maxLength)
propertyName
String
The property name
property
String&
the reference string to draw/edit
maxLength
Int32
max length of textfield (number of letters.)
Boolean
if has changed.
[GUI] draws a property of type String that can be edited
public static string drawPropertyEdit(string propertyName, string property, int maxLength)
propertyName
String
The property name
property
String
the reference string to draw/edit
maxLength
Int32
max length of textfield (number of letters.)
String
returns the property
[GUI] draws a property of type Int32 that can be edited
public static bool drawPropertyEdit(string propertyName, Int32& property, int maxLength)
propertyName
String
The property int name
property
Int32&
the reference int to draw/edit
maxLength
Int32
max length of textfield (number of letters.)
Boolean
if has changed.
[GUI] draws a int property that can be edited
public static float drawPropertyEdit(string propertyName, int property, int maxLength)
propertyName
String
The property int name
property
Int32
the reference int to draw/edit
maxLength
Int32
max length of textfield
[GUI] draws a property of type Single that can be edited
public static bool drawPropertyEdit(string propertyName, Single& property, int maxLength)
propertyName
String
The property float name
property
Single&
the reference float to draw/edit
maxLength
Int32
max length of textfield (number of letters.)
Boolean
if has changed.
[GUI] draws a float property that can be edited
public static float drawPropertyEdit(string propertyName, float property, int maxLength)
propertyName
String
The property float name
property
Single
the reference float to draw/edit
maxLength
Int32
max length of textfield
[GUI] draws a property of type Double that can be edited
public static bool drawPropertyEdit(string propertyName, Double& property, int maxLength)
propertyName
String
The property double name
property
Double&
the reference double to draw/edit
maxLength
Int32
max length of textfield (number of letters.)
Boolean
if has changed.