Scripting API
CCDS is a static class in BoneCrackerGames.CCDS (Assets/CCDS/Scripts/Base/CCDS.cs). It is the supported entry point for money, ownership, game state, settings, missions and layers.
Prefer it over reaching into managers directly. It handles save initialisation, persistence and event raising, which hand-written manager access does not.
using BoneCrackerGames.CCDS;
Player data
| Method | Returns | Notes |
|---|---|---|
GetMoney() |
int |
Current balance |
ChangeMoney(int amount) |
void |
Adds amount. Pass a negative value to charge. Saves and raises OnMoneyChanged. |
GetPlayerName() |
string |
|
SetPlayerName(string name) |
void |
Minimum 3 characters. Shorter input logs a warning and does nothing. Also updates the Photon nickname when PUN is included and connected, CCDS_NetworkManager.playerName and the spawned player. |
ChangeMoney does not clamp. Nothing prevents a negative balance — check GetMoney() before charging.
Vehicle ownership
| Method | Returns | Notes |
|---|---|---|
GetVehicle() |
int |
Selected vehicle index |
SetVehicle(int index) |
void |
Select a vehicle |
IsOwnedVehicle(int index) |
bool |
|
UnlockVehicle(int index) |
void |
|
LockVehicle(int index) |
void |
|
UnlockAllVehicles() |
void |
Useful while testing |
LockAllVehicles() |
void |
The index is the position in CCDS_PlayerVehicles.playerVehicles, and it is persisted. Reordering that array reassigns vehicles for existing players.
Purchases
| Method | Returns | Notes |
|---|---|---|
IsItemPurchased(string saveKey) |
bool |
|
PurchaseItem(string saveKey) |
void |
Marks owned and saves |
IsUpgradePurchased(string saveKey) |
bool |
|
PurchaseUpgrade(string saveKey) |
void |
Marks purchased and saves |
Neither purchase method charges the player. Deduct with ChangeMoney yourself.
if (!CCDS.IsItemPurchased("paint_red") && CCDS.GetMoney() >= 500) {
CCDS.ChangeMoney(-500);
CCDS.PurchaseItem("paint_red");
}
Game state
| Method | Returns | Notes |
|---|---|---|
IsMultiplayer() |
bool |
True only when connected and ready in a room; delegates to CCDS_NetworkAvailability.IsInRoom |
PauseGame() |
void |
Raises OnPaused |
ResumeGame() |
void |
Raises OnResumed |
RestartGame() |
void |
|
MainMenu() |
void |
Returns to the main menu, raises OnMainMenu |
SetScene(int index) |
void |
Selects the gameplay scene |
GetScene() |
int |
|
StartGameplayScene() |
void |
Loads it; uses PhotonNetwork.LoadLevel when connected and in a room |
IsFirstGameplay() |
bool |
|
SetFirstGameplay() |
void |
|
ResetGame() |
void |
Deletes the save data and reloads. No confirmation. |
Network availability
CCDS_NetworkAvailability is a static class in BoneCrackerGames.CCDS. Its checks are safe with or without PUN, and reading them never starts a connection.
| Member | Type | Meaning |
|---|---|---|
IsInstalled |
bool property |
This build includes the optional PUN integration |
IsConfigured |
bool property |
PUN is included and its Realtime App ID parses as a nonempty GUID; this is not an authentication test |
IsInRoom |
bool property |
Photon is connected and ready, and has joined a room |
ShouldStartOnline(bool savedPreference) |
Returns bool |
True only when PUN is installed, configured, and the supplied preference is true |
CCDS.GetPreferMultiplayer() reads the player's saved choice. It does not report capability, a connection, or room membership. Resolve the intended startup mode without changing that choice:
bool startOnline =
CCDS_NetworkAvailability.ShouldStartOnline(CCDS.GetPreferMultiplayer());
This expression makes no connection attempt. CCDS gameplay uses the same check to fall back to local play when the SDK or valid configuration is unavailable, preserving the saved preference. Call CCDS.SetPreferMultiplayer(bool) when the player changes their choice; it persists the value without connecting.
Settings
These are the runtime, player-facing counterparts to the default* fields in CCDS_Settings. Settings setters persist their values; most also raise the matching event. SetPreferMultiplayer only saves the startup preference.
| Getter | Setter | Type | Range |
|---|---|---|---|
GetShadows() |
SetShadows(bool) |
bool |
— |
GetSoftShadows() |
SetSoftShadows(bool) |
bool |
— |
GetShadowResolution() |
SetShadowResolution(int) |
int |
0–3 |
GetImageEffects() |
SetImageEffects(bool) |
bool |
— |
GetDrawDistance() |
SetDrawDistance(float) |
float |
500–5000 |
GetMaxRealtimeLights() |
SetMaxRealtimeLights(int) |
int |
0–16 |
GetAntialiasingMode() |
SetAntialiasingMode(int) |
int |
0 None, 1 FXAA, 2 SMAA |
GetAudioVolume() |
SetAudioVolume(float) |
float |
0–1 |
GetMusicVolume() |
SetMusicVolume(float) |
float |
0–1 |
GetAutoHandbrake() |
SetAutoHandbrake(bool) |
bool |
— |
GetTrafficDensity() |
SetTrafficDensity(float) |
float |
0–2 |
GetPreferMultiplayer() |
SetPreferMultiplayer(bool) |
bool |
— |
Traffic
| Method | Notes |
|---|---|
DisableTrafficForAWhile() |
Temporary suppression, e.g. during a race |
ToggleTrafficPermanently(bool state) |
Until changed back |
Both route through RTC_SceneManager.
Vehicle checks
Each has an ACCDS_Vehicle / RCCP_CarController overload and a GameObject overload.
| Method | Returns |
|---|---|
IsLocalPlayerVehicle(...) |
bool |
IsCopCar(...) |
bool |
IsClientCar(...) |
bool |
IsAICar(...) |
bool |
RepairVehicle(CCDS_Player player) |
void |
void OnCollisionEnter(Collision col) {
if (CCDS.IsCopCar(col.gameObject))
CCDS.DebugLog("Hit a police car");
}
Creation helpers
| Method | Returns | Requires |
|---|---|---|
CreateMission(string name, MissionType type) |
GameObject |
CCDS_MissionObjectiveManager in the scene |
CreateCop(GameObject prefab, Vector3 pos, Quaternion rot) |
GameObject |
Prefab with CCDS_AI_Cop |
CreateCop(Vector3 pos) |
GameObject |
CCDS_Settings.copVehicle |
CreateMissionPosition(string name = null) |
CCDS_MissionObjectivePosition |
CCDS_MissionObjectivePositionsManager |
CreateMissionPosition(Vector3 pos, Quaternion rot, string name = null) |
CCDS_MissionObjectivePosition |
Same |
All return null and log an error when the required manager is absent.
GameObject mission = CCDS.CreateMission("Harbour Run", CCDS.MissionType.Checkpoint);
if (mission == null) return; // manager missing
CCDS.CreateMissionPosition(new Vector3(10f, 0f, 0f), Quaternion.identity, "CP_01");
Chat
| Method | Notes |
|---|---|
ShowChat() |
|
HideChat() |
|
ToggleChatVisibility() |
|
SetChatVisibilityMode(ChatVisibilityMode mode) |
AlwaysVisible, ShowOnNewMessages, Hidden |
Layers
| Method | Returns | Notes |
|---|---|---|
GetLayerIndex(string name) |
int |
|
LayerExists(string name) |
bool |
|
GetLayerMask(string name) |
LayerMask |
|
IsOnLayer(GameObject obj, string name) |
bool |
|
SetLayerRecursively(GameObject obj, string name, bool recursive = true) |
void |
|
EnsureLayer(GameObject obj, string name, bool recursive = true) |
bool |
Respects CCDS_Settings.enableAutoLayerManagement |
Persistence
| Method | Notes |
|---|---|
Save() |
Write save data |
Load() |
Read it back |
ChangeMoney, SetPlayerName, PurchaseItem, PurchaseUpgrade and the settings setters already save. Call Save() only after writing saveData fields directly.
Logging
| Method | Emits when |
|---|---|
DebugLog(string message) |
CCDS_Settings.enableDebugMessages is true |
DebugLogWarning(string message) |
Always |
DebugLogWarning(string message, Object context) |
Always |
DebugLogError(string message) |
Always |
DebugLogError(string message, Object context) |
Always |
Use these instead of Debug.* in CCDS code. All routes also raise CCDS_Events.OnDebugLog, which is how the in-game debug console receives them.
Enums
CCDS.MissionType // Checkpoint, Pursuit, Race, Trailblazer
ChatVisibilityMode // AlwaysVisible, ShowOnNewMessages, Hidden
CCDS_GameStates.GameState // Stopped, Countdown, Paused, Started
CCDS_GameModes.Mode // Race, Trailblazer, Pursuit, Checkpoint
Save data access
Reading saveData directly is supported, but initialise first:
CCDS_SaveGameManager.EnsureInitialized();
float distance = CCDS_SaveGameManager.saveData.totalDistanceDriven;
CCDS_SaveGameManager.saveData.totalDistanceDriven += delta;
CCDS.Save();
Skipping EnsureInitialized() risks reading a null or stale object. CCDS.cs calls it in over twenty places for this reason.
Culture
CCDS_FixCultureEditor and FixCultureRuntime pin Thread.CurrentCulture to InvariantCulture in both the editor and play mode.
Do not write code that depends on locale-aware parsing or formatting — it will behave differently from the rest of the project. Numbers parse and format invariantly everywhere in CCDS.