C#:
// Requires: TapeLibrary
using Network;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Game.Rust;
using Oxide.Game.Rust.Cui;
using ProtoBuf;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using WebSocketSharp;
using static Construction;
namespace Oxide.Plugins {
[Info("AmusementRides", "Nikedemos", VERSION)]
[Description("I want to go on something more thrilling than MR BONES WILD RIDE")]
public class AmusementRides : RustPlugin {
[PluginReference]
private Plugin SignArtist, TapeLibrary;
public class AmusementBehaviour : MonoBehaviour {
//TODO: Common updateRate / currentTime based updates
}
public class AmusementRidesPlugin : RustPlugin {
public const string PREFAB_TC = "assets/prefabs/deployable/tool cupboard/cupboard.tool.deployed.prefab";
public const string PREFAB_SMALL_BOX = "assets/prefabs/deployable/woodenbox/woodbox_deployed.prefab";
public const string PREFAB_LARGE_BOX = "assets/prefabs/deployable/large wood storage/box.wooden.large.prefab";
public const string PREFAB_LOCK_KEY = "assets/prefabs/locks/keylock/lock.key.prefab";
public const string PREFAB_LOCK_CODE = "assets/prefabs/locks/keypad/lock.code.prefab";
public const string PREFAB_VENDING_MACHINE = "assets/prefabs/deployable/vendingmachine/vendingmachine.deployed.prefab";
public const string PREFAB_BOOMBOX = "assets/prefabs/voiceaudio/boombox/boombox.deployed.prefab";
public const string PREFAB_SPEAKER = "assets/prefabs/voiceaudio/hornspeaker/connectedspeaker.deployed.static.prefab";
public const string PREFAB_GENERATOR = "assets/prefabs/deployable/playerioents/generators/generator.small.prefab";
public const string PREFAB_SPLITTER = "assets/prefabs/io/electric/switches/splitter.prefab";
public const string PREFAB_BUTTON_CABLE = "assets/prefabs/io/electric/switches/pressbutton/pressbutton.prefab";
public const string PREFAB_BUTTON = "assets/prefabs/deployable/playerioents/button/button.prefab";
public const string PREFAB_LADDER = "assets/prefabs/building/ladder.wall.wood/ladder.wooden.wall.prefab";
public const string PREFAB_MAILBOX = "assets/prefabs/deployable/mailbox/mailbox.deployed.prefab";
public const string PREFAB_RUG = "assets/prefabs/deployable/rug/rug.deployed.prefab";
public const string PREFAB_FLOOR = "assets/prefabs/building core/floor/floor.prefab";
public const string PREFAB_FLOOR_FRAME = "assets/prefabs/building core/floor.frame/floor.frame.prefab";
public const string PREFAB_FLOOR_TRIANGLE = "assets/prefabs/building core/floor.triangle/floor.triangle.prefab";
public const string PREFAB_WALL_FRAME = "assets/prefabs/building core/wall.frame/wall.frame.prefab";
public const string PREFAB_WALL_WINDOW = "assets/prefabs/building core/wall.window/wall.window.prefab";
public const string PREFAB_ROOF_TRIANGLE = "assets/prefabs/building core/roof.triangle/roof.triangle.prefab";
public const string PREFAB_ROOF = "assets/prefabs/building core/roof/roof.prefab";
public const string PREFAB_DOORWAY = "assets/prefabs/building core/wall.doorway/wall.doorway.prefab";
public const string PREFAB_STEPS = "assets/prefabs/building core/foundation.steps/foundation.steps.prefab";
public const string PREFAB_FOUNDATION = "assets/prefabs/building core/foundation/foundation.prefab";
public const string PREFAB_FOUNDATION_TRIANGLE = "assets/prefabs/building core/foundation.triangle/foundation.triangle.prefab";
public const string PREFAB_WALL_LOW = "assets/prefabs/building core/wall.low/wall.low.prefab";
public const string PREFAB_RAMP = "assets/prefabs/building core/ramp/ramp.prefab";
public const string PREFAB_WALL = "assets/prefabs/building core/wall/wall.prefab";
public const string PREFAB_SHOP_FRONT = "assets/prefabs/building/wall.frame.shopfront/wall.frame.shopfront.prefab";
public const string PREFAB_GRILL_FLOOR = "assets/prefabs/building/floor.grill/floor.grill.prefab";
public const string PREFAB_DOOR_WOODEN_SINGLE = "assets/prefabs/building/door.hinged/door.hinged.wood.prefab";
public const string PREFAB_DOOR_METAL_DOUBLE = "assets/prefabs/building/door.double.hinged/door.double.hinged.metal.prefab";
public const string PREFAB_DOOR_METAL_SINGLE = "assets/prefabs/building/door.hinged/door.hinged.metal.prefab";
public const string PREFAB_WINDOW_SHUTTERS = "assets/prefabs/building/wall.window.shutter/shutter.wood.a.prefab";
public const string PREFAB_XMAS_LIGHTS = "assets/prefabs/misc/xmas/christmas_lights/xmas.lightstring.deployed.prefab";
public const string PREFAB_REFINERY = "assets/prefabs/deployable/oil refinery/refinery_small_deployed.prefab";
public const string PREFAB_SIRENLIGHT = "assets/prefabs/deployable/playerioents/lights/sirenlight/electric.sirenlight.deployed.prefab";
public const string PREFAB_FIREWORK = "assets/prefabs/deployable/fireworks/volcanofirework.prefab";
public const string PREFAB_CHAIR = "assets/prefabs/deployable/chair/chair.deployed.prefab";
public const string PREFAB_DIESEL_BARREL = "assets/prefabs/resource/diesel barrel/diesel_barrel_world.prefab";
public const string PREFAB_OIL_BARREL = "assets/bundled/prefabs/radtown/oil_barrel.prefab";
public const string PREFAB_METAL_BARRICADE = "assets/prefabs/deployable/barricades/barricade.metal.prefab";
public const string PREFAB_PICTUREFRAME_XXL = "assets/prefabs/deployable/signs/sign.pictureframe.xxl.prefab";
public const string PREFAB_PICTUREFRAME_XL = "assets/prefabs/deployable/signs/sign.pictureframe.xl.prefab";
public const string PREFAB_SIGN_TALL = "assets/prefabs/deployable/signs/sign.pictureframe.tall.prefab";
public const string PREFAB_SIGN_WOODEN_MEDIUM = "assets/prefabs/deployable/signs/sign.medium.wood.prefab";
public const string PREFAB_SIGN_WOODEN_LARGE = "assets/prefabs/deployable/signs/sign.large.wood.prefab";
public const string PREFAB_SIGN_WOODEN_HUGE = "assets/prefabs/deployable/signs/sign.huge.wood.prefab";
public const string PREFAB_SIGN_WOODEN_SMALL= "assets/prefabs/deployable/signs/sign.small.wood.prefab";
public const string PREFAB_FOG_MACHINE = "assets/content/props/fog machine/fogmachine.prefab";
public const string PREFAB_SHOTGUN_TRAP = "assets/prefabs/deployable/single shot trap/guntrap.deployed.prefab";
public const string PREFAB_MINICOPTER = "assets/content/vehicles/minicopter/minicopter.entity.prefab";
public const string PREFAB_PLAYER = "assets/prefabs/player/player.prefab";
public const string PREFAB_HORSE = "assets/rust.ai/nextai/testridablehorse.prefab";
public const string PREFAB_HORSE_CORPSE = "assets/rust.ai/agents/horse/horse.corpse.prefab";
public const string PREFAB_WORKBENCH_LEVEL1_DEPLOYED = "assets/prefabs/deployable/tier 1 workbench/workbench1.deployed.prefab";
public const string PREFAB_WORKBENCH_LEVEL2_DEPLOYED = "assets/prefabs/deployable/tier 2 workbench/workbench2.deployed.prefab";
public const string PREFAB_WORKBENCH_LEVEL3_DEPLOYED = "assets/prefabs/deployable/tier 3 workbench/workbench3.deployed.prefab";
public const string PREFAB_WORKBENCH_LEVEL1_STATIC = "assets/bundled/prefabs/static/workbench1.static.prefab";
public const string PREFAB_WORKBENCH_LEVEL2_STATIC = "assets/bundled/prefabs/static/workbench2.static.prefab";
public const string PREFAB_WORKBENCH_LEVEL3_STATIC = "assets/bundled/prefabs/static/workbench3.static.prefab";
public const string PREFAB_SCRAPHELI_GIBS = "assets/content/vehicles/scrap heli carrier/servergibs_scraptransport.prefab";
public const string PREFAB_SCRAPHELI_GIBS_PART_38 = "ScrapHeliGibs_Part038";
public const int ITEM_LOCK_KEY = -850982208;
public const int ITEM_REFINERY = -1293296287;
public const int ITEM_TC = -97956382;
public const int ITEM_LARGE_BOX = 833533164;
public const int ITEM_SMALL_BOX = -180129657;
public const int ITEM_PITCHFORK = 1090916276;
public const int ITEM_SPRING = -1021495308;
public const int ITEM_SALVAGED_HAMMER = -1506397857;
public const int ITEM_METAL_PIPE = 95950017;
public const int ITEM_WOOD = -151838493;
public const int ITEM_FRAGS = 69511070;
public const int ITEM_STONES = 2099697608;
public const int ITEM_CLOTH = 858312878;
public const int ITEM_SCRAP = -932201673;
public const int ITEM_LOWGRADE = -946369541;
public const int ITEM_SEWING_KIT = 1234880403;
public const int ITEM_SICKLE = -1368584029;
public const int ITEM_SNOWBALL = -363689972;
public const ulong SKIN_CHAIR_RED = 2243574331;
public const ulong SKIN_CHAIR_YELLOW = 2243575528;
public const ulong SKIN_CHAIR_GREEN = 2243575827;
public const ulong SKIN_CHAIR_CYAN = 2243576358;
public const ulong SKIN_CHAIR_BLUE = 2243576743;
public const ulong SKIN_CHAIR_MAGENTA = 2243577262;
public Dictionary<string, RideDefinition> rideDefinitions = new Dictionary<string, RideDefinition>();
public Dictionary<string, RideHandler> rideHandlers = new Dictionary<string, RideHandler>();
public static AmusementRides AmusementInstance;
public const string MERRY_RADIO_URL = "http://80.2.179.204:1337/stream";
public static readonly string[] BUNDLED_OGG_URLS = new string[] {
"https://cdn.discordapp.com/attachments/771376962643034143/1080119417238736917/babys1stsynthwave.ogg", "https://cdn.discordapp.com/attachments/771376962643034143/1080119417637187604/bluegras.ogg", "https://cdn.discordapp.com/attachments/771376962643034143/1080119417930780702/brokeback.ogg", "https://cdn.discordapp.com/attachments/771376962643034143/1080119418325061724/denseintenseloop16.ogg", "https://cdn.discordapp.com/attachments/771376962643034143/1080119418744483891/ferriswheel.ogg", "https://cdn.discordapp.com/attachments/771376962643034143/1080119419084214272/greengras.ogg", "https://cdn.discordapp.com/attachments/771376962643034143/1080119419411386498/mutkanto.ogg", "https://cdn.discordapp.com/attachments/771376962643034143/1080119419704979507/psyloop.ogg", "https://cdn.discordapp.com/attachments/771376962643034143/1080119420069875793/slowspyk.ogg",
}
;
[PluginReference]
private AmusementRides AmusementRides;
//has to be private
public string AddRideDefinition(RideDefinition definition) {
rideDefinitions.Add(definition.rideName, definition);
return definition.rideName;
}
public string AddRideHandler(RideHandler handler) {
rideHandlers.Add(handler.name, handler);
return handler.name;
}
void Init() {
InitStuff();
}
void Unload() {
UnloadStuff();
}
void OnServerInitialized() {
InitializedStuff();
}
public virtual void InitializedStuff() {
AddRideHandlers();
RegisterHandlers();
AddRideMusics();
AddRideDefinitions();
RegisterDefinitions();
}
public virtual void InitStuff() {
AmusementInstance = Instance;
}
public virtual void UnloadStuff() {
foreach (var definition in rideDefinitions) {
Instance.DefinitionUnregister(this, definition.Key);
}
foreach (var handler in rideHandlers) {
Instance.HandlerUnregister(this, handler.Key);
}
}
public virtual void AddRideHandlers() {
}
public virtual void AddRideDefinitions() {
}
public virtual void AddRideMusics() {
}
public void RegisterDefinitions() {
foreach (var definition in rideDefinitions) {
AmusementInstance.DefinitionRegister(this, definition.Value);
}
}
public void RegisterHandlers() {
foreach (var handler in rideHandlers) {
AmusementInstance.HandlerRegister(this, handler.Value);
}
}
}
public static readonly ulong SteamIconID = 0;
public static AmusementRides Instance;
public static LayerMask CollisionLayer = LayerMask.GetMask("Tree", "Debris", "Clutter", "Default", "Construction", "Deployed");
public static readonly string PERMISSION_ADMIN = "amusementrides.admin";
public static readonly string PERMISSION_VIP = "amusementrides.vip";
public static readonly string PERMISSION_RIDE = "amusementrides.ride";
public static readonly string PERMISSION_OPERATE = "amusementrides.operate";
public static readonly string PERMISSION_CRAFT_DEPLOY_PICKUP = "amusementrides.craft.deploy.pickup";
public static readonly int FLAG_INTERNAL = 0x200000;
public static int layerMaskPlayer = LayerMask.GetMask("Player (Server)");
/*
public static readonly Dictionary<string, string> ThirdPersonToFirst = new Dictionary<string, string>
{
["was"] = "were",
["has"] = "have",
["is"] = "are",
["does"] = "do",
["wasn't"] = "weren't",
["hasn't"] = "haven't",
["isn't"] = "aren't",
["doesn't"] = "don't",
};*/
public static Dictionary<string, string> Fx = new Dictionary<string, string> {
["pumpUp"]
= "assets/bundled/prefabs/fx/oiljack/pump_up.prefab", ["pumpDown"] = "assets/bundled/prefabs/fx/oiljack/pump_down.prefab", ["pumpUp2"] = "assets/bundled/prefabs/fx/well/pump_up.prefab", ["pumpDown2"] = "assets/bundled/prefabs/fx/well/pump_down.prefab", ["purchase"] = "assets/prefabs/deployable/vendingmachine/effects/vending-machine-purchase-human.prefab", ["vomit"] = "assets/bundled/prefabs/fx/gestures/drink_vomit.prefab", ["flesh"] = "assets/bundled/prefabs/fx/impacts/blunt/flesh/fleshbloodimpact.prefab", ["fall"] = "assets/bundled/prefabs/fx/player/fall-damage.prefab", ["ground"] = "assets/bundled/prefabs/fx/player/groundfall.prefab", ["gutshot"] = "assets/bundled/prefabs/fx/player/gutshot_scream.prefab", ["scream"] = "assets/bundled/prefabs/fx/player/beartrap_scream.prefab"
}
;
public static readonly List<string> deployTargetNames = new List<string> {
"box.wooden", "box.wooden.large", "cupboard.tool", "door.double.hinged.metal", "door.double.hinged.toptier", "door.double.hinged.wood", "door.hinged.metal", "door.hinged.toptier", "door.hinged.wood", "floor.ladder.hatch", "fridge", "gates.external.high.stone", "gates.external.high.wood", "locker", "wall.frame.garagedoor", "wall.frame.cell.gate", "wall.frame.fence.gate", "wall.frame.shopfront",
}
;
public const string VERSION = "0.9.8";
#region CONFIG
public ConfigData configData;
protected override void LoadDefaultConfig() {
PrintWarning("Generating default config...");
configData = new ConfigData();
SaveConfigData();
}
private void ProcessConfigData() {
if (configData.version != VERSION) {
Tuple<int, int, int> tuplePrevious;
Tuple<int, int, int> tupleCurrent;
var versionFromConfig = configData.version;
//is the version older than 0.9.3?
if (CompareVersions(versionFromConfig, "0.9.8", out tuplePrevious, out tupleCurrent) == VersionComparisonResult.PreviousIsOlder) {
Instance.PrintError($"\n\nMusical Update: Backed up your previous config as /oxide/config/AmusementRides.json.OLD and generated default config.\n\n");
SaveConfigData($"{Config.Filename}.OLD");
storedData = new StoredData();
configData.version = VERSION;
Instance.PrintWarning($"\n\nYou have succesfully updated from {versionFromConfig} to {VERSION}\n");
SaveConfigData();
}
}
}
private void LoadConfigData() {
PrintWarning("Loading configuration file...");
try {
configData = Config.ReadObject<ConfigData>();
}
catch {
configData = new ConfigData();
}
//SaveConfigData();
}
private void SaveConfigData(string customFilename = null) {
Config.WriteObject(configData, true, customFilename);
}
public class DefinitionOverride {
public Dictionary<int, Dictionary<int, ulong>> specialGroupSkins;
public Dictionary<int, Dictionary<int, string>> specialSignData;
public float minWaitTime = 0F;
public string rideDescription;
public string rideImage;
public Dictionary<int, int> rideCost;
public int worbenchLevel;
public List<string> assignedMusic;
}
public class ConfigData {
public string version = VERSION;
public float minimumRideSpacing = 20F;
public bool allowMusic = true;
public bool enableCrafting = true;
public bool removeRidesOnMapWipe = true;
public bool addMerryGoRadioToBoomboxes = true;
public Dictionary<string, DefinitionOverride> definitionCustomizations = new Dictionary<string, DefinitionOverride>();
}
#endregion
#region LANG
//pre 0.9.3 messages
public const string MSG_LANDING_SURVIVED_5 = "LandingMessageSurvived5";
public const string MSG_LANDING_SURVIVED_10 = "LandingMessageSurvived10";
public const string MSG_LANDING_SURVIVED_25 = "LandingMessageSurvived25";
public const string MSG_LANDING_SURVIVED_50 = "LandingMessageSurvived50";
public const string MSG_LANDING_SURVIVED_90 = "LandingMessageSurvived90";
public const string MSG_LANDING_SURVIVED_100 = "LandingMessageSurvived100";
public const string MSG_LANDING_SURVIVED_MAX = "LandingMessageSurvivedMax";
public const string MSG_LANDING_DIED_5 = "LandingMessageDied5";
public const string MSG_LANDING_DIED_10 = "LandingMessageDied10";
public const string MSG_LANDING_DIED_25 = "LandingMessageDied25";
public const string MSG_LANDING_DIED_50 = "LandingMessageDied50";
public const string MSG_LANDING_DIED_90 = "LandingMessageDied90";
public const string MSG_LANDING_DIED_100 = "LandingMessageDied100";
public const string MSG_LANDING_DIED_150 = "LandingMessageDied150";
public const string MSG_LANDING_DIED_250 = "LandingMessageDied250";
public const string MSG_LANDING_DIED_MAX = "LandingMessageDiedMax";
//post 0.9.3 messages
public const string MSG_LANDING_FULL_STATS = nameof(MSG_LANDING_FULL_STATS);
public const string MSG_MESSAGE_FORMAT = nameof(MSG_MESSAGE_FORMAT);
public const string MSG_CANT_CONNECT_DISCONNECT_WIRES = nameof(MSG_CANT_CONNECT_DISCONNECT_WIRES);
public const string MSG_CAN_ONLY_PLACE_ON_SINGLE_FOUNDATION = nameof(MSG_CAN_ONLY_PLACE_ON_SINGLE_FOUNDATION);
public const string MSG_TOO_CLOSE_TO_ANOTHER_RIDE = nameof(MSG_TOO_CLOSE_TO_ANOTHER_RIDE);
public const string MSG_CANT_DEMOLISH_RIDE_ENTITY = nameof(MSG_CANT_DEMOLISH_RIDE_ENTITY);
public const string MSG_CANT_ROTATE_RIDE_ENTITY = nameof(MSG_CANT_ROTATE_RIDE_ENTITY);
public const string MSG_CANT_DEPLOY_RIDES_IN_THE_WAY = nameof(MSG_CANT_DEPLOY_RIDES_IN_THE_WAY);
public const string MSG_CANT_DEPLOY_THINGS_ON_RIDE = nameof(MSG_CANT_DEPLOY_THINGS_ON_RIDE);
public const string MSG_CANT_BUILD_OR_DEPLOY_ON_RIDE = nameof(MSG_CANT_BUILD_OR_DEPLOY_ON_RIDE);
public const string MSG_CANT_UPGRADE_RIDE_STRUCTURES = nameof(MSG_CANT_UPGRADE_RIDE_STRUCTURES);
public const string MSG_ONLY_AUTHORISED_CAN_USE_RIDE = nameof(MSG_ONLY_AUTHORISED_CAN_USE_RIDE);
public const string MSG_ONLY_AUTHORISED_CAN_CONTROL = nameof(MSG_ONLY_AUTHORISED_CAN_CONTROL);
public const string MSG_CANT_PICKUP_ADMIN_RIDE = nameof(MSG_CANT_PICKUP_ADMIN_RIDE);
public const string MSG_PICKUP_CONTAINER_NEEDS_TO_BE_EMPTY = nameof(MSG_PICKUP_CONTAINER_NEEDS_TO_BE_EMPTY);
public const string MSG_PICKUP_LOCK_NEEDS_TO_BE_REMOVED = nameof(MSG_PICKUP_LOCK_NEEDS_TO_BE_REMOVED);
public const string MSG_PICKUP_CONTAINER_NEEDS_REPAIR = nameof(MSG_PICKUP_CONTAINER_NEEDS_REPAIR);
public const string MSG_CANT_GET_ON_RIDE_NOT_OVER = nameof(MSG_CANT_GET_ON_RIDE_NOT_OVER);
public const string MSG_ADMISSION_FEE_FREE_OF_CHARGE_FORMATTED = nameof(MSG_ADMISSION_FEE_FREE_OF_CHARGE_FORMATTED);
public const string MSG_ADMISSION_FEE_CURRENCY_FORMATTED = nameof(MSG_ADMISSION_FEE_CURRENCY_FORMATTED);
public const string MSG_ADMISSION_FEE_FREE_OF_CHARGE_UNFORMATTED = nameof(MSG_ADMISSION_FEE_FREE_OF_CHARGE_UNFORMATTED);
public const string MSG_ADMISSION_FEE_CURRENCY_UNFORMATTED = nameof(MSG_ADMISSION_FEE_CURRENCY_UNFORMATTED);
public const string MSG_CANT_GET_ON_NEED_CURRENCY = nameof(MSG_CANT_GET_ON_NEED_CURRENCY);
public const string MSG_BROADCAST_PLAYER_BACK_ON_RIDE = nameof(MSG_BROADCAST_PLAYER_BACK_ON_RIDE);
public const string MSG_BROADCAST_RIDE_NOT_STARTING = nameof(MSG_BROADCAST_RIDE_NOT_STARTING);
public const string MSG_BROADCAST_RIDE_HAS_STARTED = nameof(MSG_BROADCAST_RIDE_HAS_STARTED);
public const string MSG_BROADCAST_RIDE_IS_OVER = nameof(MSG_BROADCAST_RIDE_IS_OVER);
public const string MSG_BROADCAST_RIDE_STARTING_SOON = nameof(MSG_BROADCAST_RIDE_STARTING_SOON);
public const string MSG_BROADCAST_PLAYER_HOPPED_IN_TIME_CANT_JOIN_LATE = nameof(MSG_BROADCAST_PLAYER_HOPPED_IN_TIME_CANT_JOIN_LATE);
public const string MSG_BROADCAST_PLAYER_HOPPED_IN_TIME_AND_CAN_JOIN_LATE = nameof(MSG_BROADCAST_PLAYER_HOPPED_IN_TIME_AND_CAN_JOIN_LATE);
public const string MSG_BROADCAST_NOBODY_LEFT_STOPPING_NOW = nameof(MSG_BROADCAST_NOBODY_LEFT_STOPPING_NOW);
public const string MSG_BROADCAST_NOBODY_LEFT_STOPPING_SOON = nameof(MSG_BROADCAST_NOBODY_LEFT_STOPPING_SOON);
public const string MSG_BROADCAST_PLAYER_GOT_OFF_DISMOUNTED = nameof(MSG_BROADCAST_PLAYER_GOT_OFF_DISMOUNTED);
public const string MSG_BROADCAST_PLAYER_GOT_OFF_DIED = nameof(MSG_BROADCAST_PLAYER_GOT_OFF_DIED);
public const string MSG_BROADCAST_PLAYER_GOT_OFF_DISCONNECTED = nameof(MSG_BROADCAST_PLAYER_GOT_OFF_DISCONNECTED);
public const string MSG_BROADCAST_PLAYER_GOT_OFF_COLD_FEET = nameof(MSG_BROADCAST_PLAYER_GOT_OFF_COLD_FEET);
public const string MSG_BROADCAST_PLAYER_GOT_OFF_DIED_BEFORE_RIDE_BEGAN = nameof(MSG_BROADCAST_PLAYER_GOT_OFF_DIED_BEFORE_RIDE_BEGAN);
public const string MSG_BROADCAST_PLAYER_GOT_OFF_DISCONNECTED_BEFORE_RIDE_BEGAN = nameof(MSG_BROADCAST_PLAYER_GOT_OFF_DISCONNECTED_BEFORE_RIDE_BEGAN);
public const string MSG_BROADCAST_RIDE_REMOVED_BY_ADMIN = nameof(MSG_BROADCAST_RIDE_REMOVED_BY_ADMIN);
public const string MSG_BROADCAST_RIDE_REMOVED_BY_RAIDING = nameof(MSG_BROADCAST_RIDE_REMOVED_BY_RAIDING);
public const string MSG_BROADCAST_RIDE_LOCK_DESTROYED = nameof(MSG_BROADCAST_RIDE_LOCK_DESTROYED);
public const string MSG_ADMISSION_RIDE_FREE_OF_CHARGE_PLAYER_AUTHORISED = nameof(MSG_ADMISSION_RIDE_FREE_OF_CHARGE_PLAYER_AUTHORISED);
public const string MSG_ADMISSION_RIDE_FREE_OF_CHARGE_NO_FEE = nameof(MSG_ADMISSION_RIDE_FREE_OF_CHARGE_NO_FEE);
public const string MSG_ADMISSION_PLAYER_PAID_CURRENCY = nameof(MSG_ADMISSION_PLAYER_PAID_CURRENCY);
public const string MSG_COMMAND_GIVE_AND_SPAWN_PROVIDE_VALID_RIDE_NAME = nameof(MSG_COMMAND_GIVE_AND_SPAWN_PROVIDE_VALID_RIDE_NAME);
public const string MSG_COMMAND_GIVE_GAVE_RIDE_TO_YOURSELF = nameof(MSG_COMMAND_GIVE_GAVE_RIDE_TO_YOURSELF);
public const string MSG_COMMAND_GAVE_RIDE_TO_PLAYER = nameof(MSG_COMMAND_GAVE_RIDE_TO_PLAYER);
public const string MSG_COMMAND_GIVE_GAVE_RIDE_RECEIVED_FROM_ADMIN = nameof(MSG_COMMAND_GIVE_GAVE_RIDE_RECEIVED_FROM_ADMIN);
public const string MSG_COMMAND_SPAWN_NEW_RIDE_CREATED = nameof(MSG_COMMAND_SPAWN_NEW_RIDE_CREATED);
public const string MSG_ONLY_ADMINS_CAN_MANAGE_THIS_RIDE = nameof(MSG_ONLY_ADMINS_CAN_MANAGE_THIS_RIDE);
public const string MSG_ONLY_ADMINS_CAN_CHANGE_THIS_SETTING = nameof(MSG_ONLY_ADMINS_CAN_CHANGE_THIS_SETTING);
public const string MSG_UI_RIDE_NAME = nameof(MSG_UI_RIDE_NAME);
public const string MSG_UI_ONLY_AUTHORISED_CAN_RIDE = nameof(MSG_UI_ONLY_AUTHORISED_CAN_RIDE);
public const string MSG_UI_EVERYONE_CAN_RIDE = nameof(MSG_UI_EVERYONE_CAN_RIDE);
public const string MSG_UI_ONLY_AUTHORISED_CAN_CONTROL = nameof(MSG_UI_ONLY_AUTHORISED_CAN_CONTROL);
public const string MSG_UI_EVERYONE_CAN_CONTROL = nameof(MSG_UI_EVERYONE_CAN_CONTROL);
public const string MSG_UI_AUTHORISED_FREE = nameof(MSG_UI_AUTHORISED_FREE);
public const string MSG_UI_AUTHORISED_CHARGE = nameof(MSG_UI_AUTHORISED_CHARGE);
public const string MSG_UI_BROADCAST_POSITION = nameof(MSG_UI_BROADCAST_POSITION);
public const string MSG_UI_DONT_BROADCAST_POSITION = nameof(MSG_UI_DONT_BROADCAST_POSITION);
public const string MSG_UI_ADMIN_RIDE = nameof(MSG_UI_ADMIN_RIDE);
public const string MSG_UI_NORMAL_RIDE = nameof(MSG_UI_NORMAL_RIDE);
public const string MSG_UI_ADMISSION_ITEM = nameof(MSG_UI_ADMISSION_ITEM);
public const string MSG_UI_ADMISSION_AMOUNT = nameof(MSG_UI_ADMISSION_AMOUNT);
public const string MSG_UI_MUSIC_AUTO = nameof(MSG_UI_MUSIC_AUTO);
public const string MSG_UI_MUSIC_MANUAL = nameof(MSG_UI_MUSIC_MANUAL);
public const string MSG_UI_BROADCAST_CHAT_MESSAGES = nameof(MSG_UI_BROADCAST_CHAT_MESSAGES);
public const string MSG_UI_DONT_BROADCAST_CHAT_MESSAGES = nameof(MSG_UI_DONT_BROADCAST_CHAT_MESSAGES);
public const string MSG_UI_WB_PLAYS_MUSIC = nameof(MSG_UI_WB_PLAYS_MUSIC);
public const string MSG_UI_WB_HAS_TC = nameof(MSG_UI_WB_HAS_TC);
public const string MSG_UI_WB_LEVEL_REQUIRED = nameof(MSG_UI_WB_LEVEL_REQUIRED);
public const string MSG_UI_WB_CANT_AFFORD_TO_CRAFT = nameof(MSG_UI_WB_CANT_AFFORD_TO_CRAFT);
public const string MSG_UI_WB_READY_TO_CRAFT = nameof(MSG_UI_WB_READY_TO_CRAFT);
public const string MSG_PLACEHOLDER_74 = nameof(MSG_PLACEHOLDER_74);
public const string MSG_PLACEHOLDER_75 = nameof(MSG_PLACEHOLDER_75);
public const string MSG_PLACEHOLDER_76 = nameof(MSG_PLACEHOLDER_76);
public const string MSG_PLACEHOLDER_77 = nameof(MSG_PLACEHOLDER_77);
public const string MSG_PLACEHOLDER_78 = nameof(MSG_PLACEHOLDER_78);
public const string MSG_PLACEHOLDER_79 = nameof(MSG_PLACEHOLDER_79);
public const string MSG_PLACEHOLDER_80 = nameof(MSG_PLACEHOLDER_80);
private static Dictionary<string, string> LangMessages = new Dictionary<string, string> {
[MSG_LANDING_SURVIVED_5]
= "{0} came out virtually unscathed!", [MSG_LANDING_SURVIVED_10] = "{0} ended up with a few bruises.", [MSG_LANDING_SURVIVED_25] = "{0} suffered some minor injuries.", [MSG_LANDING_SURVIVED_50] = "{0} suffered severe injuries.", [MSG_LANDING_SURVIVED_90] = "{0} suffered fatal injuries.", [MSG_LANDING_SURVIVED_100] = "{0} nearly died from the injuries.", [MSG_LANDING_SURVIVED_MAX] = "{0} survived a literally IMPOSSIBLE amount of damage.", [MSG_LANDING_DIED_5] = "{0} died from stupidity!", [MSG_LANDING_DIED_10] = "{0} died from a boobo or and/or an ouchie.", [MSG_LANDING_DIED_25] = "{0} died from some minor injuries.", [MSG_LANDING_DIED_50] = "{0} died from severe injuries.", [MSG_LANDING_DIED_90] = "{0} died from predictably fatal injuries.", [MSG_LANDING_DIED_100] = "{0} died from practically unsurvivable injuries.", [MSG_LANDING_DIED_150] = "{0} died from humorously over-the-top injuries.", [MSG_LANDING_DIED_250] = "{0} died from absolutely hilarious injuries.", [MSG_LANDING_DIED_MAX] = "{0} died from shockingly grotesque injuries.", [MSG_LANDING_FULL_STATS] = "Launch velocity: {0} m/s ({1} MPH)\nLaunch height: {2} m\nFirst impact velocity: {3} m/s ({4} MPH)\nAir time: {5} s\nAir distance: {6} m\nDamage taken: {7} HP (= {8} J)\nTotal travel time: {9} s\nTotal travel distance: {10} m", [MSG_MESSAGE_FORMAT] = "<color=yellow>[{0}]</color> {1}", [MSG_CANT_CONNECT_DISCONNECT_WIRES] = "You can't connect/disconnect wires on entities belonging to Rides", [MSG_CAN_ONLY_PLACE_ON_SINGLE_FOUNDATION] = "You can only place {0} on a single foundation with nothing else around it.", [MSG_TOO_CLOSE_TO_ANOTHER_RIDE] = "You are too close to another ride, <color=yellow>{0}</color> ({1} m. away).\nTry at least {2} meters away.", [MSG_CANT_DEMOLISH_RIDE_ENTITY] = "You cannot demolish structures that belong to the ride.", [MSG_CANT_ROTATE_RIDE_ENTITY] = "You cannot rotate structures that belong to the ride.", [MSG_CANT_DEPLOY_RIDES_IN_THE_WAY] = "You cannot deploy the ride here, there's some entities in the way: ", [MSG_CANT_DEPLOY_THINGS_ON_RIDE] = "You cannot build or deploy things on this ride.", [MSG_CANT_BUILD_OR_DEPLOY_ON_RIDE] = "You cannot build or deploy things on this ride.", [MSG_CANT_UPGRADE_RIDE_STRUCTURES] = "You cannot upgrade structures that belong to the ride.", [MSG_ONLY_AUTHORISED_CAN_USE_RIDE] = "Only authorized players can use this ride.", [MSG_ONLY_AUTHORISED_CAN_CONTROL] = "Only authorized players can control this ride.", [MSG_CANT_PICKUP_ADMIN_RIDE] = "This is an admin ride, you cannot pick it up.", [MSG_PICKUP_CONTAINER_NEEDS_TO_BE_EMPTY] = "You have to take everything out of the ride's Container before picking the ride up.", [MSG_PICKUP_LOCK_NEEDS_TO_BE_REMOVED] = "You have to take off the lock on the ride's Container before picking the ride up.", [MSG_PICKUP_CONTAINER_NEEDS_REPAIR] = "You have to repair the ride's Container to full health before picking the ride up.", [MSG_CANT_GET_ON_RIDE_NOT_OVER] = "Please wait till the ride's over.", [MSG_ADMISSION_FEE_FREE_OF_CHARGE_FORMATTED] = "<color=green>FREE OF CHARGE</color>", [MSG_ADMISSION_FEE_CURRENCY_FORMATTED] = "<color=white>{0}</color> <color=orange>{1}</color>", [MSG_ADMISSION_FEE_FREE_OF_CHARGE_UNFORMATTED] = "FREE OF CHARGE", [MSG_ADMISSION_FEE_CURRENCY_UNFORMATTED] = "{0} {1}", [MSG_CANT_GET_ON_NEED_CURRENCY] = "Sorry, you need {0} to get on!", [MSG_BROADCAST_PLAYER_BACK_ON_RIDE] = "{0} is back on the ride? Gotta make your mind up!", [MSG_BROADCAST_RIDE_NOT_STARTING] = "The ride is not starting, everyone got off before the countdown.", [MSG_BROADCAST_RIDE_HAS_STARTED] = "The ride has started!", [MSG_BROADCAST_RIDE_IS_OVER] = "The ride is over!", [MSG_BROADCAST_RIDE_STARTING_SOON] = "{0} hopped on. Ride starting in {1} seconds!", [MSG_BROADCAST_PLAYER_HOPPED_IN_TIME_CANT_JOIN_LATE] = "{0} managed to hop on in time, there's {1} seats left.", [MSG_BROADCAST_PLAYER_HOPPED_IN_TIME_AND_CAN_JOIN_LATE] = "{0} got on the ride! Come and join them!", [MSG_BROADCAST_NOBODY_LEFT_STOPPING_NOW] = "Nobody left on the ride, coming to a stop now.", [MSG_BROADCAST_NOBODY_LEFT_STOPPING_SOON] = "Nobody left on the ride, coming to a stop soon.", [MSG_BROADCAST_PLAYER_GOT_OFF_DISMOUNTED] = "{0} couldn't take it any more and got off!", [MSG_BROADCAST_PLAYER_GOT_OFF_DIED] = "{0} couldn't take it anymore and died on the ride!", [MSG_BROADCAST_PLAYER_GOT_OFF_DISCONNECTED] = "{0} couldn't take it anymore and disconnected!", [MSG_BROADCAST_PLAYER_GOT_OFF_COLD_FEET] = "{0} had cold feet and got off!", [MSG_BROADCAST_PLAYER_GOT_OFF_DIED_BEFORE_RIDE_BEGAN] = "{0} died before the ride even began!", [MSG_BROADCAST_PLAYER_GOT_OFF_DISCONNECTED_BEFORE_RIDE_BEGAN] = "{0} had cold feet and disconnected before the ride even began!", [MSG_BROADCAST_RIDE_REMOVED_BY_ADMIN] = "{0} has been removed by an admin.", [MSG_BROADCAST_RIDE_REMOVED_BY_RAIDING] = "Oh no. {0} has been removed (most likely because it was raided)", [MSG_BROADCAST_RIDE_LOCK_DESTROYED] = "The lock on the ride's container has been destroyed!", [MSG_ADMISSION_RIDE_FREE_OF_CHARGE_PLAYER_AUTHORISED] = "You're authorized, so for you, the ride is free of charge!", [MSG_ADMISSION_RIDE_FREE_OF_CHARGE_NO_FEE] = "The ride is free of charge!", [MSG_ADMISSION_PLAYER_PAID_CURRENCY] = "You paid {0} to ride.", [MSG_COMMAND_GIVE_AND_SPAWN_PROVIDE_VALID_RIDE_NAME] = "Please provide a valid name of the ride. Try {0}.\nIf you don't see the ride listed, reload the missing ride plugins in the console.", [MSG_COMMAND_GIVE_GAVE_RIDE_TO_YOURSELF] = "You have given yourself a <color=yellow>{0}</color> item.", [MSG_COMMAND_GAVE_RIDE_TO_PLAYER] = "You have given {0} a <color=yellow>{1}</color> item.", [MSG_COMMAND_GIVE_GAVE_RIDE_RECEIVED_FROM_ADMIN] = "You have received a <color=yellow>{0}</color> item from an admin.", [MSG_COMMAND_SPAWN_NEW_RIDE_CREATED] = "New ride {0} created successfully!", [MSG_ONLY_ADMINS_CAN_MANAGE_THIS_RIDE] = "Only admins can manage this ride.", [MSG_ONLY_ADMINS_CAN_CHANGE_THIS_SETTING] = "Only admins can change this setting.", [MSG_UI_RIDE_NAME] = "Ride name (or DEFAULT to restore):", [MSG_UI_ONLY_AUTHORISED_CAN_RIDE] = "Only authorized can use this ride", [MSG_UI_EVERYONE_CAN_RIDE] = "Everyone can use this ride", [MSG_UI_ONLY_AUTHORISED_CAN_CONTROL] = "Only authorized can control this ride", [MSG_UI_EVERYONE_CAN_CONTROL] = "Everyone can control this ride", [MSG_UI_AUTHORISED_FREE] = "Authorized ride for free", [MSG_UI_AUTHORISED_CHARGE] = "Charge authorized too", [MSG_UI_BROADCAST_POSITION] = "Broadcast ride position", [MSG_UI_DONT_BROADCAST_POSITION] = "Don't broadcast position", [MSG_UI_ADMIN_RIDE] = "Admin ride (no damage, no decay, only admins can pick up/manage)", [MSG_UI_NORMAL_RIDE] = "Normal ride (takes damage, decays, authorized can pick up/manage)", [MSG_UI_ADMISSION_ITEM] = "Admission item, enter ID/name: ", [MSG_UI_ADMISSION_AMOUNT] = "Admission amount, 0 = free: ", [MSG_UI_MUSIC_AUTO] = "Music: auto start/stop from ride playlist", [MSG_UI_MUSIC_MANUAL] = "Music: manual start/stop with custom tapes/stations", [MSG_UI_BROADCAST_CHAT_MESSAGES] = "Broadcast global chat messages", [MSG_UI_DONT_BROADCAST_CHAT_MESSAGES] = "Don't broadcast global chat messages", [MSG_UI_WB_PLAYS_MUSIC] = "• plays {0} music tracks", [MSG_UI_WB_HAS_TC] = "• comes with a TC", [MSG_UI_WB_LEVEL_REQUIRED] = "WORKBENCH LV {0} REQUIRED", [MSG_UI_WB_CANT_AFFORD_TO_CRAFT] = "CAN'T AFFORD TO CRAFT", [MSG_UI_WB_READY_TO_CRAFT] = "READY TO CRAFT! CLICK HERE", [MSG_PLACEHOLDER_74] = "", [MSG_PLACEHOLDER_75] = "", [MSG_PLACEHOLDER_76] = "", [MSG_PLACEHOLDER_77] = "", [MSG_PLACEHOLDER_78] = "", [MSG_PLACEHOLDER_79] = "", [MSG_PLACEHOLDER_80] = "",
}
;
private static string MSG(string msg, string userID = null, params object[] args) {
if (args == null) {
return Instance.lang.GetMessage(msg, Instance, userID);
}
else {
return string.Format(Instance.lang.GetMessage(msg, Instance, userID), args);
}
}
#endregion
protected override void LoadDefaultMessages() {
lang.RegisterMessages(LangMessages, this);
}
public static List<string> FxHurt = new List<string> {
"flesh", "fall", "ground", "gutshot", "scream"
}
;
public const float AVERAGE_HUMAN_BODY_WEIGHT = 62F;
public const float METERS_PER_SECOND_TO_MPH_MULTIPLIER = 2.23694F;
//if the server is US-based, you should change it to your country's average, 80.7F (in kilograms) ;)
//source: https://bmcpublichealth.biomedcentral.com/articles/10.1186/1471-2458-12-439
public const float DEATH_AT_VELOCITY = 56.7961835F;
//at body weight 62 KG and kinetic energy 50000 JOULES, it means death
public const float MAX_KINETIC_ENERGY_AT_100_DAMAGE = 50000F;
//50 kilojoules means 100HP damage on impact
public static string RandomHurtFx() {
return FxHurt[UnityEngine.Random.Range(0, FxHurt.Count - 1)];
}
public Dictionary<ulong, Ride> entityToRide = new Dictionary<ulong, Ride>();
public Dictionary<string, Ride> rides = new Dictionary<string, Ride>();
public Dictionary<string, RideDefinition> rideDefinitions = new Dictionary<string, RideDefinition>();
public Dictionary<int, byte[]> textureDictionary = null;
public Dictionary<ulong, string> skinToDefinition = new Dictionary<ulong, string>();
public Dictionary<string, RideHandler> rideHandlers = new Dictionary<string, RideHandler>();
public Dictionary<ulong, Ride> playerIDtoRide = new Dictionary<ulong, Ride>();
public Dictionary<ulong, RideSegmentCollider> playerIDtoSegmentCollider = new Dictionary<ulong, RideSegmentCollider>();
public Dictionary<ulong, List<Ride>> playerIDtoRidesNearby = new Dictionary<ulong, List<Ride>>();
public bool DefinitionRegister(RustPlugin registrant, RideDefinition definition) {
if (rideDefinitions.ContainsKey(definition.rideName)) {
Instance.PrintError($"[{registrant.Name}] [DEFINITION] ERROR: {definition.rideName} has already been registered! Skipping.");
return false;
}
else {
//not contains? create some defaults based on the definition.
if (!Instance.configData.definitionCustomizations.ContainsKey(definition.rideName)) {
Instance.configData.definitionCustomizations.Add(definition.rideName, new DefinitionOverride {
rideCost = definition.rideCost, rideDescription = definition.rideDescription, rideImage = definition.rideImage, minWaitTime = definition.minWaitTime, worbenchLevel = definition.workbenchLevel, specialSignData = definition.specialSignData, specialGroupSkins = definition.specialGroupSkins, assignedMusic = definition.assignedMusic
}
);
Instance.PrintWarning($"[{registrant.Name}] [DEFINITION] {definition.rideName} {definition.rideVersion} by {definition.rideAuthor} has succesfully registered its default definition customization entry in the config. Any changes made to that file will take effect next time the plugin reloads.");
Instance.SaveConfigData();
}
else //contains? well then, use those!
{
//1 by 1...
var definitionCopy = definition.ShallowCopy();
try {
var useThisDefinition = Instance.configData.definitionCustomizations[definition.rideName];
definition.rideDescription = useThisDefinition.rideDescription;
definition.rideCost = useThisDefinition.rideCost.ToDictionary(e => e.Key, e => e.Value);
definition.rideImage = useThisDefinition.rideImage;
definition.minWaitTime = useThisDefinition.minWaitTime;
definition.workbenchLevel = useThisDefinition.worbenchLevel;
definition.specialSignData = useThisDefinition.specialSignData;
definition.specialGroupSkins = useThisDefinition.specialGroupSkins;
definition.assignedMusic = useThisDefinition.assignedMusic;
}
catch {
Instance.PrintError($"[{registrant.Name}] [DEFINITION] {definition.rideName} {definition.rideVersion} by {definition.rideAuthor} failed to apply definition customization settings. Please check your config file - are those null/invalid or are they missing quotes? Sticking with default definition settings for now.");
definition = definitionCopy;
}
finally {
Instance.PrintWarning($"[{registrant.Name}] [DEFINITION] {definition.rideName} {definition.rideVersion} by {definition.rideAuthor} has succesfully applied definition customization from the config file.");
}
//check if the ride item skin is not 0!
if (definition.rideItemSkinID == 0) {
Instance.PrintError($"[{registrant.Name}] [DEFINITION] ERROR: {definition.rideName} cannot have a Ride Item Skin ID set to 0! Please change it to ANYTHING else. Skipping.");
return false;
}
//check if another ride has already registered the same pickup skin
if (rideDefinitions.Where(d => d.Value.rideItemSkinID == definition.rideItemSkinID).Any()) {
Instance.PrintError($"[{registrant.Name}] [DEFINITION] ERROR: {definition.rideName} is trying to register the same Ride Item Skin ID ({definition.rideItemSkinID}) as another, already registered definition. Please change it to ANYTHING else. Skipping.");
return false;
}
definition.ApplyPickupDefinition();
skinToDefinition.Add(definition.rideItemSkinID, definition.rideName);
rideDefinitions.Add(definition.rideName, definition);
Instance.PrintWarning($"[{registrant.Name}] [DEFINITION] {definition.rideName} {definition.rideVersion} by {definition.rideAuthor} registered successfully.");
//create an override entry in the config if it doesn't exist
if (Instance.configData.definitionCustomizations == null) {
Instance.configData.definitionCustomizations = new Dictionary<string, DefinitionOverride>();
}
}
return true;
}
}
public bool DefinitionUnregister(RustPlugin registrant, string name) {
if (rideDefinitions.ContainsKey(name)) {
Instance.PrintWarning($"[{registrant.Name}] [DEFINITION] {rideDefinitions[name].rideName} unregistered successfully.");
skinToDefinition.Remove(rideDefinitions[name].rideItemSkinID);
rideDefinitions.Remove(name);
return true;
}
else {
return false;
}
}
public bool HandlerRegister(RustPlugin registrant, RideHandler handler) {
if (rideHandlers.ContainsKey(handler.name)) {
return false;
}
else {
rideHandlers.Add(handler.name, handler);
Instance.PrintWarning($"[{registrant.Name}] [HANDLER] {handler.name} {handler.version} by {handler.author} registered successfully.");
return true;
}
}
public bool HandlerUnregister(RustPlugin registrant, string name) {
if (rideHandlers.ContainsKey(name)) {
Instance.PrintWarning($"[{registrant.Name}] [HANDLER] {rideHandlers[name].name} unregistered successfully.");
rideHandlers.Remove(name);
return true;
}
else {
return false;
}
}
public bool HandlerExists(string name) {
return rideHandlers.ContainsKey(name);
}
public bool isUnloading;
public bool isEmergencyCleanup;
void Init() {
LoadData();
isUnloading = false;
Instance = this;
isEmergencyCleanup = false;
}
void Unload() {
/*
var check = true;
if (rides == null)
{
check = false;
}
else
{
if (storedData == null)
{
check = false;
}
else
{
if (storedData.rides == null)
{
check = false;
}
}
}*/
isUnloading = true;
var iter = rides.Keys.ToList();
foreach (var entry in iter) {
RideRemove(entry);
}
foreach (var ejector in UnityEngine.Object.FindObjectsOfType<PlayerEjector>()) {
ejector.Eject(true);
}
ItemManager.DoRemoves();
SaveData();
if (BundledDownloadTimeoutTimer != null) {
BundledDownloadTimeoutTimer.Destroy();
BundledDownloadTimeoutTimer = null;
}
Instance = null;
//storedData = null;
isUnloading = false;
}
//
void OnNewSave(string strFilename) {
var tempConfig = Config.ReadObject<ConfigData>();
if (tempConfig.removeRidesOnMapWipe) {
Instance.PrintWarning("INFO: The map has been wiped! Removing all ride data. If you don't want this to happen, make an appropriate setting in the config.");
storedData = new StoredData();
SaveData();
}
}
void OnServerSave() {
timer.Once(UnityEngine.Random.Range(30F, 60F), () => {
SaveData();
}
);
}
void OnServerInitialized(bool serverInitialized) {
Instance = this;
lang.RegisterMessages(LangMessages, this);
isEmergencyCleanup = true;
BaseEntity entityAsBaseEntity;
var found = 0;
foreach (var mono in UnityEngine.Object.FindObjectsOfType<AmusementBehaviour>()) {
UnityEngine.Object.Destroy(mono.gameObject);
found++;
}
if (found > 0) {
Instance.PrintError($"EMERGENCY CLEANUP: Found and destroyed {found} leftover MonoBehaviour gameobjects");
}
found = 0;
foreach (var entity in BaseNetworkable.serverEntities) {
entityAsBaseEntity = entity as BaseEntity;
if (entityAsBaseEntity != null) {
if ( /*entityAsBaseEntity.OwnerID == 1337420*/
IsInternal(entityAsBaseEntity)) {
if (!entityAsBaseEntity
// ... [Code preview truncated due to length. Full source in attached file] ...