C#:
using System;
using System.Linq;
using UnityEngine;
using Oxide.Core;
using Oxide.Core.Configuration;
using Rust;
using Network;
using System.Runtime.CompilerServices;
using System.Collections.Generic;
using System.Resources;
using Facepunch;
namespace Oxide.Plugins {
[Info("DeepWater", "Colon Blow", "1.0.24")]
class DeepWater : RustPlugin {
// fix for null errors for loot spawn
// changed base prefab back to visualization sphere
// fix for Helipad H half not showing
#region Load
private bool initialized;
void Loaded() {
LoadVariables();
lang.RegisterMessages(messages, this);
permission.RegisterPermission("deepwater.spawn", this);
}
private void OnServerInitialized() {
LoadDataFile();
initialized = true;
timer.In(5, RestoreSavedRigs);
if (SpawnRandomOnLoad) timer.In(30, SetAutoSpawnEnabled);
}
void LoadDefaultConfig() {
Puts("No configuration file found, generating...");
Config.Clear();
LoadVariables();
}
private void RestoreSavedRigs() {
if (storedData.saveRigData.Count > 0) {
BaseEntity[] objects = BaseEntity.saveList.Where(x => x is BaseEntity).ToArray();
if (objects != null) {
foreach (var obj in objects) {
if (storedData.saveRigData.ContainsKey(obj.net.ID)) {
var getent = obj.GetComponent<BaseEntity>();
if (getent) getent.Invoke("KillMessage", 0.1f);
var signownerid = storedData.saveRigData[obj.net.ID].ownerid;
var signpos = StringToVector3(storedData.saveRigData[obj.net.ID].pos);
var signrot = StringToQuaternion(storedData.saveRigData[obj.net.ID].rot);
var signangle = StringToVector3(storedData.saveRigData[obj.net.ID].eangles);
var rigcompound = storedData.saveRigData[obj.net.ID].iscompound;
timer.Once(2f, () => SpawnRig(signownerid, signpos, signrot, signangle, rigcompound));
storedData.saveRigData.Remove(obj.net.ID);
SaveData();
}
}
}
}
}
#endregion
#region Configuration
private string gridLocation;
static bool SpawnRandomOnLoad = false;
static bool EnableAutoZoneOnRandom = false;
static bool EnableAutoZoneOnLocal = false;
static bool EnableAutoZoneOnCompound = false;
static bool EnableAutoZoneOnRigEvent = true;
static bool useStaticRandomID = false;
static bool useStaticLocalID = false;
static bool useStaticComoundID = false;
static bool useStaticEventID = false;
static string randomRigZoneID = "123456";
static string localRigZoneID = "223344";
static string compoundRigZoneID = "555555";
static string eventRigZoneID = "999999";
static string randomzoneargs = @"radius,50,enter_message,You have entered a Random Rig Area";
static string localzoneargs = @"radius,50,enter_message,You have entered a Rig Area";
static string compoundzoneargs = @"radius,50,enter_message,You have entered a Compound Rig Area";
static string eventzoneargs = @"radius,50,enter_message,You have entered a Event Rig Area";
static int PumpStartingFuel = 100;
static uint HeliPadRugLogo1 = 1371746398;
static uint HeliPadRugLogo2 = 1371746398;
static bool UseSentryOnCompound = false;
bool CanDamageRig = false;
bool DestroyRandomOnReload = false;
bool DestroyLocalOnReload = false;
float RigSpawnHeight = 16f;
static bool UseDespawnOnRandom = true;
static bool UseDespawnOnLocal = false;
static bool AutoMoveLiftBucket = true;
static bool StandardRigHasLiftBucket = true;
static bool StandardRigHasBarrels = false;
static bool StandardRigHasLadders = true;
static bool StandardRigHasLootSpawn = true;
static float DespawnTime = 60000f;
static float LootRespawnTime = 1000f;
static int EventMinRestartTime = 10000;
static int EventMaxRestartTime = 30000;
static int MinPlayersForEventSpawn = 5;
static bool EventRigHasLiftBucket = true;
static bool EventRigHasBarrels = true;
static bool EventRigHasLadders = true;
static bool EventRigHasHackCrate = true;
static bool EventRigHasLootSpawn = true;
static bool AddFullDivingKit = true;
static int Stage1Duration = 6000;
static int Stage2Duration = 4000;
static float Stage2HackDuration = 200f;
static int Stage3Duration = 1000;
static int Stage3TimeBetweenBarrels = 100;
static float Stage3BarrelDamage = 50f;
static int Stage4Duration = 2000;
static float Stage4HackDefaultReset = 900f;
static int MaxLootCratesToSpawn = 2;
static string LootPrefab1 = "assets/bundled/prefabs/radtown/crate_basic.prefab";
static string LootPrefab2 = "assets/bundled/prefabs/radtown/crate_elite.prefab";
static string LootPrefab3 = "assets/bundled/prefabs/radtown/crate_mine.prefab";
static string LootPrefab4 = "assets/bundled/prefabs/radtown/crate_normal.prefab";
static string LootPrefab5 = "assets/bundled/prefabs/radtown/crate_normal_2.prefab";
static bool HasOilDeposit = true;
static bool HasHQMetalDeposit = true;
static bool HasSulfurDeposit = true;
static bool HasMetalDeposit = true;
static int OilDepositTickRate = 1;
static int HQMetalTickRate = 1;
static int SulfurOreTickRate = 1;
static int MetalOreTickRate = 1;
static bool BroadcastSpawn = true;
static bool BroadcastEventSpawn = true;
static bool BroadcastEventEnd = true;
static bool BroadCastEventStages = true;
int eventcounter = 0;
int eventrespawntime = EventMaxRestartTime;
bool Changed;
static bool DoRandomRespawn = false;
bool EventCountDown = false;
private void LoadVariables() {
LoadConfigVariables();
SaveConfig();
}
private void LoadConfigVariables() {
CheckCfg("Spawn - Starting Low Grade Fuel amount for engine when Deepwater spawns : ", ref PumpStartingFuel);
CheckCfg("Spawn - Broadcast to chat when Deepwater spawns and its coords ? ", ref BroadcastSpawn);
CheckCfg("ZoneManager - Automatic Zone Options - Local Zone Creation Arguments (except zone id, no space after commas) ", ref localzoneargs);
CheckCfg("ZoneManager - Automatic Zone Options - Random Zone Creation Arguments (except zone id, no space after commas) ", ref randomzoneargs);
CheckCfg("ZoneManager - Automatic Zone Options - Compound Zone Creation Arguments (except zone id, no space after commas) ", ref compoundzoneargs);
CheckCfg("ZoneManager - Automatic Zone Options - Event Rig Zone Creation Arguments (except zone id, no space after commas) ", ref eventzoneargs);
CheckCfg("ZoneManager - Automatic Zone - Autmatically spawn a zone when Random Rig Spawns ? ", ref EnableAutoZoneOnRandom);
CheckCfg("ZoneManager - Automatic Zone - Autmatically spawn a zone when Local Rig Spawns ? ", ref EnableAutoZoneOnLocal);
CheckCfg("ZoneManager - Automatic Zone - Autmatically spawn a zone when Compound Rig Spawns ? ", ref EnableAutoZoneOnCompound);
CheckCfg("ZoneManager - Automatic Zone - Autmatically spawn a zone when Event Rig Spawns ? ", ref EnableAutoZoneOnRigEvent);
CheckCfg("ZoneManager - Enable Predefined Zone ID - Turn this on for Event Rigs (otherwise, it autogenerates one from entity ID) ? ", ref useStaticEventID);
CheckCfg("ZoneManager - Enable Predefined Zone ID - Turn this on for Compound Rigs (otherwise, it autogenerates one from entity ID) ? ", ref useStaticComoundID);
CheckCfg("ZoneManager - Enable Predefined Zone ID - Turn this on for Random Rigs (otherwise, it autogenerates one from entity ID) ? ", ref useStaticRandomID);
CheckCfg("ZoneManager - Enable Predefined Zone ID - Turn this on for Local Rigs (otherwise, it autogenerates one from entity ID) ? ", ref useStaticLocalID);
CheckCfg("ZoneManager - Zone ID - Use This Predefined Event Rig Zone ID (if enabled) ", ref eventRigZoneID);
CheckCfg("ZoneManager - Zone ID - Use This Predefined Compound Rig Zone ID (if enabled) ", ref compoundRigZoneID);
CheckCfg("ZoneManager - Zone ID - Use This Predefined Random Rig Zone ID (if enabled) ", ref randomRigZoneID);
CheckCfg("ZoneManager - Zone ID - Use This Predefined Local Rig Zone ID (if enabled) ", ref localRigZoneID);
CheckCfg("Spawn - Helipad H logo Half 1 (H) rug skind ID ? ", ref HeliPadRugLogo1);
CheckCfg("Spawn - Helipad H logo Half 2 (H) rug skind ID ? ", ref HeliPadRugLogo2);
CheckCfg("Compound - Spawn the Sentry Guns if rig is a compound ? ", ref UseSentryOnCompound);
CheckCfg("_Event - AutoSpawn - Spawn Event at random Intervals between Min and Max Respawn time ? ", ref SpawnRandomOnLoad);
CheckCfg("_Event - Minimum Player Count needed to AutoSpawn Event Rig ? ", ref MinPlayersForEventSpawn);
CheckCfg("_Event - Spawn Bucket Lift for Event Rigs ? ", ref EventRigHasLiftBucket);
CheckCfg("_Event - Spawn Barrels (and explosions) for Event Rigs ? ", ref EventRigHasBarrels);
CheckCfg("_Event - Spawn Ladders for Event Rigs ? ", ref EventRigHasLadders);
CheckCfg("_Event - Spawn Hack Crate for Stage 2 ? ", ref EventRigHasHackCrate);
CheckCfg("_Event - Hack Crate will always have a full Diving Kit (wetsuit, tank, fins and mask) ? ", ref AddFullDivingKit);
CheckCfg("_Event - Spawn Loots crates for Event Rigs ? ", ref EventRigHasLootSpawn);
CheckCfg("_Event - Broadcast Event stages to all players ? ", ref BroadCastEventStages);
CheckCfg("_Event - Broadcast Event spawn to all players ? ", ref BroadcastEventSpawn);
CheckCfg("_Event - Broadcast Event ending to all players ? ", ref BroadcastEventEnd);
CheckCfg("_Event - AutoSpawn - Minimum Respawn Time for event (Every 1000 is approx 1 min) : ", ref EventMinRestartTime);
CheckCfg("_Event - AutoSpawn - Maximum Respawn Time for event (Every 1000 is approx 1 min) : ", ref EventMaxRestartTime);
CheckCfg("_Event - Duration - Rig Spawn to Stage 1 Wait Time : ", ref Stage1Duration);
CheckCfg("_Event - Duration - Stage 1 to Stage 2 Wait Time (MAX is 4500) : ", ref Stage2Duration);
CheckCfg("_Event - Duration - Stage 2 Duration to Stage 3 Wait Time : ", ref Stage3Duration);
CheckCfg("_Event - Duration - Stage 3 Time between Barrel Explosions : ", ref Stage3TimeBetweenBarrels);
CheckCfgFloat("_Event - Damage - Stage 3 Barrel Explosion Damage : ", ref Stage3BarrelDamage);
CheckCfg("_Event - Duration - Stage 4 Countdown Time (Every 1000 is approx 1 min) : ", ref Stage4Duration);
CheckCfgFloat("_Event - Hack time for Hack crate during event : ", ref Stage2HackDuration);
CheckCfgFloat("_Event - Reset global Hack Crate time back to (900 is default) after event : ", ref Stage4HackDefaultReset);
CheckCfgFloat("Spawn - Height of rig off water.13 to 19 works best : ", ref RigSpawnHeight);
CheckCfg("Spawn - Spawn Bucket Lift for Standard Rigs (non Event) ? ", ref StandardRigHasLiftBucket);
CheckCfg("Spawn - Spawn Barrels for Standard Rigs (non Event) ? ", ref StandardRigHasBarrels);
CheckCfg("Spawn - Spawn Ladders for Standard Rigs (non Event) ? ", ref StandardRigHasLadders);
CheckCfg("Spawn - Spawn Loots Crates for Standard Rigs (non Event) ? ", ref StandardRigHasLootSpawn);
CheckCfg("Allow Damage to Deepwater Rig ? ", ref CanDamageRig);
CheckCfg("Destroy all Random Spawned Deepwater Rigs when plugin reloads or server restarts ? ", ref DestroyRandomOnReload);
CheckCfg("Destroy all Manually Spawned Deepwater Rigs when plugin reloads or server restarts ? ", ref DestroyLocalOnReload);
CheckCfg("Automatically have lift bucket go up and down periodically ? ", ref AutoMoveLiftBucket);
CheckCfg("Despawn - Enable despawn timer on Randomly Spawned Deepwater Rigs ? ", ref UseDespawnOnRandom);
CheckCfg("Despawn - Enable despawn timer on Manually placed Deepwater Rigs ? ", ref UseDespawnOnLocal);
CheckCfgFloat("Despawn - Time before Deepwater Rig will despawn itself : ", ref DespawnTime);
CheckCfgFloat("Loot Spawn - amount of time to respawn loot spawns on rig : ", ref LootRespawnTime);
CheckCfg("Loot Spawn - maximum number of loot crates spawn locations (max 8) : ", ref MaxLootCratesToSpawn);
CheckCfg("Loot Spawn - Random Loot prefab 1 : ", ref LootPrefab1);
CheckCfg("Loot Spawn - Random Loot prefab 2 : ", ref LootPrefab2);
CheckCfg("Loot Spawn - Random Loot prefab 3 : ", ref LootPrefab3);
CheckCfg("Loot Spawn - Random Loot prefab 4 : ", ref LootPrefab4);
CheckCfg("Loot Spawn - Random Loot prefab 5 : ", ref LootPrefab5);
CheckCfg("Resource Deposit - Enable Crude Oil as a resource : ", ref HasOilDeposit);
CheckCfg("Resource Deposit - Enable High Quality Metal Ore as a resource : ", ref HasHQMetalDeposit);
CheckCfg("Resource Deposit - Enable Sulfur Ore as a resource : ", ref HasSulfurDeposit);
CheckCfg("Resource Deposit - Enable Metal Ore as a resource : ", ref HasMetalDeposit);
CheckCfg("Resource Deposit - Tick Rate - Get 1 Crude Oil every : (if enabled) : ", ref OilDepositTickRate);
CheckCfg("Resource Deposit - Tick Rate - Get 1 HQ Metal every (if enabled) : ", ref HQMetalTickRate);
CheckCfg("Resource Deposit - Tick Rate - Get 1 Sulfur Ore every (if enabled) : ", ref SulfurOreTickRate);
CheckCfg("Resource Deposit - Tick Rate - Get 1 Metal Ore every (if enabled) : ", ref MetalOreTickRate);
}
private void CheckCfg<T>(string Key, ref T var) {
if (Config[Key] is T) var = (T)Config[Key];
else Config[Key] = var;
}
private void CheckCfgFloat(string Key, ref float var) {
if (Config[Key] != null) var = System.Convert.ToSingle(Config[Key]);
else Config[Key] = var;
}
#endregion
#region Localization
string msg(string key, string playerId = null) => lang.GetMessage(key, this, playerId);
Dictionary<string, string> messages = new Dictionary<string, string>() {
["notauthorized"]
= "You are not authorized to use that command!", ["rigspawn"] = "[Буровая вышка] заспавнена в квадрате : ", ["rigdespawn"] = "[Буровая вышка] уничтожена"
}
;
#endregion
#region Commands
// Spawns a Random Deepwater Rig
[ChatCommand("spawnrandomrig")]
void cmdSpawnRandomRig(BasePlayer player, string command, string[] args) {
if (!IsAllowed(player, "deepwater.spawn")) return;
BuildRandomDeepWater(false);
}
[ConsoleCommand("spawnrandomrig")]
void cmdConsoleSpawnRandomRig(ConsoleSystem.Arg arg) {
var player = arg.Player();
if (player != null && !IsAllowed(player, "deepwater.spawn")) return;
BuildRandomDeepWater(false);
}
// Spawns Random Deepwater Rig with Event started
[ChatCommand("spawnrandomrigevent")]
void cmdSpawnRandomRigEvent(BasePlayer player, string command, string[] args) {
if (!IsAllowed(player, "deepwater.spawn")) return;
BuildRandomDeepWater(true);
}
[ConsoleCommand("spawnrandomrigevent")]
void cmdConsoleSpawnRandomRigEvent(ConsoleSystem.Arg arg) {
var player = arg.Player();
if (player != null && !IsAllowed(player, "deepwater.spawn")) return;
BuildRandomDeepWater(true);
}
// Spawns a Deepwater rig on players location
[ChatCommand("spawnrig")]
void cmdSpawnRig(BasePlayer player, string command, string[] args) {
if (!IsAllowed(player, "deepwater.spawn")) return;
BuildLocalDeepWater(player, false);
}
// Spawns a Deepwater rig with Event Started on players location
[ChatCommand("spawnrigevent")]
void cmdSpawnRigEvent(BasePlayer player, string command, string[] args) {
if (!IsAllowed(player, "deepwater.spawn")) return;
BuildLocalDeepWater(player, true);
}
[ChatCommand("destroyrig")]
void cmdDestroyRig(BasePlayer player, string command, string[] args) {
if (!IsAllowed(player, "deepwater.spawn")) return;
RaycastHit hit;
BaseEntity hitentity = new BaseEntity();
if (Physics.Raycast(player.eyes.HeadRay(), out hit, 50f)) hitentity = hit.GetTransform().gameObject.ToBaseEntity();
if (hitentity == null) return;
var isdeepwater = hitentity.GetComponentInParent<DeepWaterEntity>() ?? null;
if (isdeepwater) isdeepwater.OnDestroy();
}
[ChatCommand("clearrigdatabase")]
void cmdChatClearRigDataBase(BasePlayer player, string command, string[] args) {
if (player.net?.connection?.authLevel > 1) {
storedData.saveRigData.Clear();
SaveData();
}
return;
}
#endregion
#region RigAntihack check
static List<BasePlayer> rigantihack = new List<BasePlayer>();
object OnPlayerViolation(BasePlayer player, AntiHackType type, float amount) {
if (player == null) return null;
if (rigantihack.Contains(player)) return false;
return null;
}
#endregion
#region Data
static Dictionary<ulong, PlayerRigCount> loadplayer = new Dictionary<ulong, PlayerRigCount>();
public class PlayerRigCount {
public BasePlayer player;
public int rigcount;
}
static StoredData storedData = new StoredData();
DynamicConfigFile dataFile;
public class StoredData {
public Dictionary<uint, StoredRigData> saveRigData = new Dictionary<uint, StoredRigData>();
public StoredData() {
}
}
public class StoredRigData {
public ulong ownerid;
public string pos;
public string eangles;
public string rot;
public int iscompound;
}
void LoadDataFile() {
dataFile = Interface.Oxide.DataFileSystem.GetFile(Title);
try {
storedData = dataFile.ReadObject<StoredData>();
}
catch {
}
if (storedData == null) storedData = new StoredData();
}
void AddData(uint entnetid, ulong sownerid, string spos, string seangles, string srot, int compound = 0) {
if (storedData.saveRigData.ContainsKey(entnetid)) storedData.saveRigData.Remove(entnetid);
storedData.saveRigData.Add(entnetid, new StoredRigData {
ownerid = sownerid, pos = spos, eangles = seangles, rot = srot, iscompound = compound,
}
);
SaveData();
}
void RemoveData(uint entnetid) {
if (storedData.saveRigData.ContainsKey(entnetid)) storedData.saveRigData.Remove(entnetid);
}
void SaveData() {
if (dataFile != null && storedData != null) {
dataFile.WriteObject(storedData);
}
}
public static Vector3 StringToVector3(string sVector) {
if (sVector.StartsWith("(") && sVector.EndsWith(")")) {
sVector = sVector.Substring(1, sVector.Length - 2);
}
string[] sArray = sVector.Split(',');
Vector3 result = new Vector3(float.Parse(sArray[0]), float.Parse(sArray[1]), float.Parse(sArray[2]));
return result;
}
public static Quaternion StringToQuaternion(string sVector) {
if (sVector.StartsWith("(") && sVector.EndsWith(")")) {
sVector = sVector.Substring(1, sVector.Length - 2);
}
string[] sArray = sVector.Split(',');
Quaternion result = new Quaternion(float.Parse(sArray[0]), float.Parse(sArray[1]), float.Parse(sArray[2]), float.Parse(sArray[3]));
return result;
}
#endregion
#region Hooks
public void CreateZone(BaseEntity entity, string zoneidstr, string[] zoneargs) {
var spawnpos = entity.transform.position;
var ZoneManager = plugins.Find("ZoneManager");
if (!Convert.ToBoolean(ZoneManager?.Call("CreateOrUpdateZone", zoneidstr, zoneargs, spawnpos))) {
return;
}
}
public void EraseZone(string zoneid) {
var ZoneManager = plugins.Find("ZoneManager");
if (!Convert.ToBoolean(ZoneManager?.Call("EraseZone", zoneid))) {
return;
}
}
private int GetRandomTime() {
var respawnroll = EventMaxRestartTime;
var randomroll = UnityEngine.Random.Range(EventMinRestartTime, EventMaxRestartTime);
respawnroll = randomroll;
EventCountDown = true;
return respawnroll;
}
void OnTick() {
if (DoRandomRespawn) {
DoRandomRespawn = false;
eventrespawntime = GetRandomTime();
return;
}
if (!DoRandomRespawn && EventCountDown) {
if (eventcounter == eventrespawntime) {
SpawnRandom();
EventCountDown = false;
eventcounter = 0;
return;
}
eventcounter = eventcounter + 1;
return;
}
}
void SetAutoSpawnEnabled() {
DoRandomRespawn = true;
}
void SpawnRandom() {
var onlineplayers = BasePlayer.activePlayerList.Count;
if (onlineplayers < MinPlayersForEventSpawn) {
PrintWarning("[Буровая вышка] не хватает игроков для начала ивента");
DoRandomRespawn = true;
return;
}
BuildRandomDeepWater(true, true);
}
bool IsAllowed(BasePlayer player, string perm) {
if (permission.UserHasPermission(player.userID.ToString(), perm)) return true;
return false;
}
void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo) {
if (CanDamageRig) return;
if (entity == null || hitInfo == null) return;
var isdeepwater = entity.GetComponentInParent<DeepWaterEntity>();
if (isdeepwater) hitInfo.damageTypes.ScaleAll(0);
return;
}
void OnEntityDeath(BaseCombatEntity target, HitInfo info) {
if (target == null || target.net == null || info == null) return;
if (storedData.saveRigData.ContainsKey(target.net.ID)) {
storedData.saveRigData.Remove(target.net.ID);
SaveData();
}
}
private object OnEntityGroundMissing(BaseEntity entity) {
var onship = entity.GetComponentInParent<DeepWaterEntity>();
if (onship != null) return false;
return null;
}
private object CanBuild(Planner plan, Construction prefab, object obj) {
if (plan == null || prefab == null || obj == null) return null;
if (obj is Construction.Target) {
var target = (Construction.Target)obj;
var targetent = target.entity as BaseEntity;
var isdeepwater = targetent?.GetComponentInParent<DeepWaterEntity>();
if (isdeepwater) return false;
return null;
}
else return null;
}
private object CanPickupEntity(BasePlayer player, BaseCombatEntity entity) {
if (entity == null || player == null) return null;
if (entity.GetComponentInParent<DeepWaterEntity>()) return false;
return null;
}
Vector3 FindSpawnPoint() {
Vector3 spawnpoint = new Vector3();
float mapoffset = 75f;
float spawnline = ((ConVar.Server.worldsize) / 2) - 75f;
float sidepicked = UnityEngine.Random.Range(1, 5);
if (sidepicked == 1) spawnpoint = new Vector3(UnityEngine.Random.Range(-spawnline, spawnline), RigSpawnHeight, -spawnline);
else if (sidepicked == 2) spawnpoint = new Vector3(UnityEngine.Random.Range(-spawnline, spawnline), RigSpawnHeight, spawnline);
else if (sidepicked == 3) spawnpoint = new Vector3(spawnline, RigSpawnHeight, UnityEngine.Random.Range(-spawnline, spawnline));
else if (sidepicked == 4) spawnpoint = new Vector3(-spawnline, RigSpawnHeight, UnityEngine.Random.Range(-spawnline, spawnline));
return spawnpoint;
}
string GetGridLocation(Vector3 position) {
Vector2 offsetPos = new Vector2((World.Size / 2 - 6) + position.x, (World.Size / 2 - 56) - position.z);
string gridstring = $"{Convert.ToChar(65 + (int)offsetPos.x / 146)}{(int)(offsetPos.y / 146)}";
return gridstring;
}
public void BuildRandomDeepWater(bool eventstarted, bool autospawned = false) {
string prefabpumpjack = "assets/prefabs/visualization/sphere.prefab";
var spawnpos = FindSpawnPoint();
BaseEntity newrig = GameManager.server.CreateEntity(prefabpumpjack, new Vector3(spawnpos.x, spawnpos.y, spawnpos.z), Quaternion.identity, true);
newrig.OwnerID = 0;
newrig?.Spawn();
var addrigstructure = newrig.gameObject.AddComponent<DeepWaterEntity>();
newrig.transform.hasChanged = true;
newrig.SendNetworkUpdateImmediate();
newrig.UpdateNetworkGroup();
if (!eventstarted) AddData(newrig.net.ID, newrig.OwnerID, newrig.transform.position.ToString(), newrig.transform.eulerAngles.ToString(), newrig.transform.rotation.ToString());
addrigstructure.israndom = true;
if (eventstarted == true) {
addrigstructure.stage1 = true;
addrigstructure.isevent = true;
}
if (autospawned == true) {
addrigstructure.isautospawn = true;
}
string getgrid = GetGridLocation(newrig.transform.position);
if ((!eventstarted && BroadcastSpawn) || (eventstarted && BroadcastEventSpawn)) {
if (eventstarted) PrintWarning(TOD_Sky.Instance.Cycle.Hour + " : DeepWater Event Started at Grid : " + getgrid);
if (eventstarted) {
ConVar.Chat.Broadcast("ивент начался в координате : " + getgrid, "[Буровая вышка]", "#5e99f7");
return;
}
ConVar.Chat.Broadcast("ивент начался в координате : " + getgrid, "[Буровая вышка]", "#5e99f7");
}
}
public void BuildLocalDeepWater(BasePlayer player, bool eventstarted, int compound = 0) {
string prefabpumpjack = "assets/prefabs/visualization/sphere.prefab";
var spawnpos = new Vector3(player.transform.position.x, RigSpawnHeight, player.transform.position.z);
BaseEntity newrig = GameManager.server.CreateEntity(prefabpumpjack, spawnpos, new Quaternion(), true);
newrig.OwnerID = 0;
newrig?.Spawn();
var addrigstructure = newrig.gameObject.AddComponent<DeepWaterEntity>();
if (!eventstarted) AddData(newrig.net.ID, newrig.OwnerID, newrig.transform.position.ToString(), newrig.transform.eulerAngles.ToString(), newrig.transform.rotation.ToString(), compound);
addrigstructure.israndom = false;
if (compound == 1) addrigstructure.iscompound = true;
if (eventstarted == true) {
addrigstructure.stage1 = true;
addrigstructure.isevent = true;
}
string getgrid = GetGridLocation(newrig.transform.position);
if ((!eventstarted && BroadcastSpawn) || (eventstarted && BroadcastEventSpawn)) {
if (eventstarted) PrintWarning(TOD_Sky.Instance.Cycle.Hour + " : DeepWater Event Started at Grid : " + getgrid);
if (compound == 1) {
ConVar.Chat.Broadcast("Rig Compound has Spawned at Grid : " + getgrid, "[Буровая вышка]", "#5e99f7");
return;
}
if (eventstarted) {
ConVar.Chat.Broadcast("ивент начался в координате : " + getgrid, "[Буровая вышка]", "#5e99f7");
return;
}
ConVar.Chat.Broadcast("ивент начался в координате : " + getgrid, "[Буровая вышка]", "#5e99f7");
}
}
void SpawnRig(ulong ownerid, Vector3 pos, Quaternion rot, Vector3 angle, int compound = 0) {
string prefabpumpjack = "assets/prefabs/visualization/sphere.prefab";
BaseEntity newrig = GameManager.server.CreateEntity(prefabpumpjack, pos, rot, true);
newrig.OwnerID = ownerid;
newrig?.Spawn();
var addrigstructure = newrig.gameObject.AddComponent<DeepWaterEntity>();
if (compound == 1) addrigstructure.iscompound = true;
AddData(newrig.net.ID, ownerid, pos.ToString(), angle.ToString(), rot.ToString(), compound);
}
void DestroyAll() {
var objects = GameObject.FindObjectsOfType<DeepWaterEntity>();
if (objects != null) foreach (var gameObj in objects) {
if (gameObj.GetComponent<DeepWaterEntity>().isevent) GameObject.Destroy(gameObj);
if (DestroyRandomOnReload && gameObj.GetComponent<DeepWaterEntity>().israndom) GameObject.Destroy(gameObj);
if (DestroyLocalOnReload && !gameObj.GetComponent<DeepWaterEntity>().israndom) GameObject.Destroy(gameObj);
break;
}
}
void Unload() {
SaveData();
DestroyAll();
}
#endregion
#region DeepWater Entity
public class DeepWaterEntity : BaseEntity {
DeepWater deepwater;
public MiningQuarry pumpjackentity;
BaseEntity entity;
Vector3 entitypos;
Quaternion entityrot;
BaseEntity spawnEntity;
BaseEntity refinerysmall;
BaseEntity furnacelarge;
BaseEntity windmill;
BaseEntity lootspawn1;
BaseEntity lootspawn2;
BaseEntity lootspawn3;
BaseEntity lootspawn4;
BaseEntity lootspawn5;
BaseEntity lootspawn6;
BaseEntity lootspawn7;
BaseEntity lootspawn8;
BaseEntity leg1floorbase;
BaseEntity leg1floor5wall1;
BaseEntity leg1floor5wall2;
BaseEntity leg1floor5wall3;
BaseEntity leg1floor5wall4;
BaseEntity leg1floor4wall1;
BaseEntity leg1floor4wall2;
BaseEntity leg1floor4wall3;
BaseEntity leg1floor4wall4;
BaseEntity leg1floor1wall1;
BaseEntity leg1floor1wall2;
BaseEntity leg1floor1wall3;
BaseEntity leg1floor1wall4;
BaseEntity leg1floor2wall1;
BaseEntity leg1floor2wall2;
BaseEntity leg1floor2wall3;
BaseEntity leg1floor2wall4;
BaseEntity leg1floor3wall1;
BaseEntity leg1floor3wall2;
BaseEntity leg1floor3wall3;
BaseEntity leg1floor3wall4;
BaseEntity leg2floorbase;
BaseEntity leg2floor5wall1;
BaseEntity leg2floor5wall2;
BaseEntity leg2floor5wall3;
BaseEntity leg2floor5wall4;
BaseEntity leg2floor4wall1;
BaseEntity leg2floor4wall2;
BaseEntity leg2floor4wall3;
BaseEntity leg2floor4wall4;
BaseEntity leg2floor1wall1;
BaseEntity leg2floor1wall2;
BaseEntity leg2floor1wall3;
BaseEntity leg2floor1wall4;
BaseEntity leg2floor2wall1;
BaseEntity leg2floor2wall2;
BaseEntity leg2floor2wall3;
BaseEntity leg2floor2wall4;
BaseEntity leg2floor3wall1;
BaseEntity leg2floor3wall2;
BaseEntity leg2floor3wall3;
BaseEntity leg2floor3wall4;
BaseEntity leg3floorbase;
BaseEntity leg3floor5wall1;
BaseEntity leg3floor5wall2;
BaseEntity leg3floor5wall3;
BaseEntity leg3floor5wall4;
BaseEntity leg3floor4wall1;
BaseEntity leg3floor4wall2;
BaseEntity leg3floor4wall3;
BaseEntity leg3floor4wall4;
BaseEntity leg3floor1wall1;
BaseEntity leg3floor1wall2;
BaseEntity leg3floor1wall3;
BaseEntity leg3floor1wall4;
BaseEntity leg3floor2wall1;
BaseEntity leg3floor2wall2;
BaseEntity leg3floor2wall3;
BaseEntity leg3floor2wall4;
BaseEntity leg3floor3wall1;
BaseEntity leg3floor3wall2;
BaseEntity leg3floor3wall3;
BaseEntity leg3floor3wall4;
BaseEntity leg4floorbase;
BaseEntity leg4floor5wall1;
BaseEntity leg4floor5wall2;
BaseEntity leg4floor5wall3;
BaseEntity leg4floor5wall4;
BaseEntity leg4floor4wall1;
BaseEntity leg4floor4wall2;
BaseEntity leg4floor4wall3;
BaseEntity leg4floor4wall4;
BaseEntity leg4floor1wall1;
BaseEntity leg4floor1wall2;
BaseEntity leg4floor1wall3;
BaseEntity leg4floor1wall4;
BaseEntity leg4floor2wall1;
BaseEntity leg4floor2wall2;
BaseEntity leg4floor2wall3;
BaseEntity leg4floor2wall4;
BaseEntity leg4floor3wall1;
BaseEntity leg4floor3wall2;
BaseEntity leg4floor3wall3;
BaseEntity leg4floor3wall4;
BaseEntity deck1row1floor1;
BaseEntity deck1row1floor2;
BaseEntity deck1row1floor3;
BaseEntity deck1row1floor4;
BaseEntity deck1row1floor5;
BaseEntity deck1row1floor6;
BaseEntity deck1row1floor7;
BaseEntity deck1row2floor1;
BaseEntity deck1row2floor2;
BaseEntity deck1row2floor3;
BaseEntity deck1row2floor4;
BaseEntity deck1row2floor5;
BaseEntity deck1row2floor6;
BaseEntity deck1row2floor7;
BaseEntity deck1row3floor1;
BaseEntity deck1row3floor2;
BaseEntity deck1row3floor3;
BaseEntity deck1row3floor4;
BaseEntity deck1row3floor5;
BaseEntity deck1row4floor1;
BaseEntity deck1row4floor2;
BaseEntity deck1row4floor3;
BaseEntity deck1row4floor4;
BaseEntity deck1row4floor5;
BaseEntity helipadsupport1;
BaseEntity helipadsupport2;
BaseEntity helipadsupport3;
BaseEntity helipadsupport4;
BaseEntity helipadsupport5;
BaseEntity deck1row2lowwall1;
BaseEntity deck1row2lowwall2;
BaseEntity deck1row2lowwall3;
BaseEntity deck1row2lowwall4;
BaseEntity deck1row2lowwall5;
BaseEntity deck1row3lowwall1;
BaseEntity deck1row3lowwall2;
BaseEntity deck1row3lowwall3;
BaseEntity deck1row3lowwall4;
BaseEntity deck1row3lowwall5;
BaseEntity deck1row4lowwall1;
BaseEntity deck1row4lowwall2;
BaseEntity deck1row4lowwall3;
BaseEntity deck1row4lowwall4;
BaseEntity deck1row4lowwall5;
BaseEntity deck1row1wallframe1;
BaseEntity deck1row1wallframe2;
BaseEntity deck1row1wallframe3;
BaseEntity deck1row1wallframe4;
BaseEntity deck1row1wallframe5;
BaseEntity deck1row2wallframe1;
BaseEntity deck1row2wallframe2;
BaseEntity deck1row2wallframe3;
BaseEntity deck1row2wallframe4;
BaseEntity deck1row2wallframe5;
BaseEntity deck1row3wallframe1;
BaseEntity deck1row3wallframe2;
BaseEntity deck1row3wallframe3;
BaseEntity deck1row3wallframe4;
BaseEntity deck1row3wallframe5;
BaseEntity deck1row4wallframe1;
BaseEntity deck1row4wallframe2;
BaseEntity deck1row4wallframe3;
BaseEntity deck1row4wallframe4;
BaseEntity deck1row4wallframe5;
BaseEntity deck1row1floorframe1;
BaseEntity deck1row1floorframe2;
BaseEntity deck1row1floorframe3;
BaseEntity deck1row1floorframe4;
BaseEntity deck1row1floorframe5;
BaseEntity deck1row1floorgrill1;
BaseEntity deck1row1floorgrill2;
BaseEntity deck1row1floorgrill3;
BaseEntity deck1row1floorgrill4;
BaseEntity deck1row1floorgrill5;
BaseEntity deck1row2floorframe1;
BaseEntity deck1row2floorframe2;
BaseEntity deck1row2floorframe3;
BaseEntity deck1row2floorframe4;
BaseEntity deck1row2floorframe5;
BaseEntity deck1row2floorgrill1;
BaseEntity deck1row2floorgrill2;
BaseEntity BucketLift;
BaseEntity deck1row2floorgrill4;
BaseEntity deck1row2floorgrill5;
BaseEntity deck1row3floorframe1;
BaseEntity deck1row3floorframe2;
BaseEntity deck1row3floorframe3;
BaseEntity deck1row3floorgrill1;
BaseEntity deck1row3floorgrill2;
BaseEntity deck1row3floorgrill3;
BaseEntity deck1row4floorframe1;
BaseEntity deck1row4floorframe2;
BaseEntity deck1row4floorframe3;
BaseEntity deck1row4floorgrill1;
BaseEntity deck1row4floorgrill2;
BaseEntity deck1row4floorgrill3;
BaseEntity deck2frontrowfloor1;
BaseEntity deck2frontrowfloor2;
BaseEntity deck2frontrowfloor3;
BaseEntity deck2frontrowfloor4;
BaseEntity deck2frontrowfloor5;
BaseEntity deck2row1floor1;
BaseEntity deck2row1floor2;
BaseEntity deck2row1floor3;
BaseEntity deck2row1floor4;
BaseEntity deck2row1floor5;
BaseEntity deck2row2floor1;
BaseEntity deck2row2floor2;
BaseEntity deck2row2floor3;
BaseEntity deck2row2floor4;
BaseEntity deck2row2floor5;
BaseEntity deck2row3floor1;
BaseEntity deck2row3floor2;
BaseEntity deck2row3floor3;
BaseEntity deck2row4floor1;
BaseEntity deck2row4floor2;
BaseEntity deck2row4floor3;
BaseEntity deck2center1;
BaseEntity deck2center2;
BaseEntity deck2center3;
BaseEntity deck2center4;
BaseEntity deck2center5;
BaseEntity deck2center6;
BaseEntity deck2center7;
BaseEntity deck2center8;
BaseEntity deck2center9;
BaseEntity deck2backrowfloor1;
BaseEntity deck2backrowfloor2;
BaseEntity deck2backrowfloor3;
BaseEntity deck2backrowfloor4;
BaseEntity deck2backrowfloor5;
BaseEntity helipadsupportframe1;
BaseEntity helipadsupportframe2;
BaseEntity helipadsupportframe3;
BaseEntity helipadsupportframe4;
BaseEntity helipadsupportframe5;
BaseEntity deck2row2lowwall1;
BaseEntity deck2row2lowwall2;
BaseEntity deck2row2lowwall3;
BaseEntity deck2row2lowwall4;
BaseEntity deck2row2lowwall5;
BaseEntity deck2row3lowwall1;
BaseEntity deck2row3lowwall2;
BaseEntity deck2row3lowwall3;
BaseEntity deck2row3lowwall3U;
BaseEntity deck2row3lowwall4;
BaseEntity deck2row3lowwall5;
BaseEntity deck2row4lowwall1;
BaseEntity deck2row4lowwall2;
BaseEntity deck2row4lowwall3;
BaseEntity deck2row4lowwall3U;
BaseEntity deck2row4lowwall4;
BaseEntity deck2row4lowwall5;
BaseEntity ladder1leg1;
BaseEntity ladder2leg1;
BaseEntity ladder3leg1;
BaseEntity ladder4leg1;
BaseEntity ladder5leg1;
BaseEntity ladder6leg1;
BaseEntity ladder1leg2;
BaseEntity ladder2leg2;
BaseEntity ladder3leg2;
BaseEntity ladder4leg2;
BaseEntity ladder5leg2;
BaseEntity ladder6leg2;
BaseEntity ladder1leg3;
BaseEntity ladder2leg3;
BaseEntity ladder3leg3;
BaseEntity ladder4leg3;
BaseEntity ladder5leg3;
BaseEntity ladder6leg3;
BaseEntity ladder1leg4;
BaseEntity ladder2leg4;
BaseEntity ladder3leg4;
BaseEntity ladder4leg4;
BaseEntity ladder5leg4;
BaseEntity ladder6leg4;
BaseEntity lowerlight1;
BaseEntity lowerlight2;
BaseEntity lowerlight3;
BaseEntity lowerlight4;
BaseEntity lowerlight5;
BaseEntity lowerlight6;
BaseEntity lowerlight7;
BaseEntity lowerlight8;
BaseEntity upperlight1;
BaseEntity upperlight2;
BaseEntity upperlight3;
BaseEntity upperlight4;
BaseEntity upperlight5;
BaseEntity upperlight6;
BaseEntity upperlight7;
BaseEntity helipadfloor1;
BaseEntity helipadfloor2;
BaseEntity helipadfloor3;
BaseEntity helipadfloor4;
BaseEntity helipadfloor5;
BaseEntity helipadfloor6;
BaseEntity helipadfloor7;
BaseEntity helipadfloor8;
BaseEntity helipadfloor9;
BaseEntity helipadfloor10;
BaseEntity helipadfence1;
BaseEntity helipadfence2;
BaseEntity helipadfence3;
BaseEntity helipadfence4;
BaseEntity helipadfence5;
BaseEntity helilogo1;
BaseEntity helilogo2;
BaseEntity helicopter;
BaseEntity helicrate;
BaseEntity explosivecrate1;
BaseEntity explosivecrate2;
BaseEntity explosivecrate3;
BaseEntity explosivecrate4;
BaseEntity explosivecrate5;
BaseEntity explosivecrate6;
BaseEntity explosivecrate7;
BaseEntity explosivecrate8;
BaseEntity explosivecrate9;
BaseEntity explosivecrate10;
BaseEntity vendattire;
BaseEntity vendbuilding;
BaseEntity vendcomponents;
BaseEntity vendresources;
BaseEntity vendtools;
BaseEntity vendweapons;
BaseEntity peacekeeper1;
BaseEntity peacekeeper2;
BaseEntity peacekeeper3;
BaseEntity peacekeeper4;
BaseEntity peacekeeper5;
BaseEntity recycler1;
BaseEntity recycler2;
BaseEntity workbench;
BaseEntity researchtable;
BaseEntity waterwell;
BoxCollider boxcollider;
bool didspawnvariables;
bool setactive;
bool isrepairing;
public bool iscompound;
public bool israndom;
public bool isevent;
public bool isautospawn;
public bool stage1;
public int stage1time;
int stage1counter;
public bool stage2;
public int stage2time;
int stage2counter;
public bool stage3;
bool stage3startfire;
public int stage3time;
public int stage3barreltime;
int stage3barrelcounter;
int stage3counter;
public bool stage4;
public int stage4time;
int stage4counter;
float F1HeightOffset;
float F2HeightOffset;
float F3HeightOffset;
float F4HeightOffset;
float F5HeightOffset;
float ShiftOffset;
float UDHeightOffset;
float LDHeightOffSet;
int count;
int despawncount;
int liftcount;
int maxlootcrates;
public int currentlootcrates;
BaseEntity mapmarker;
uint entitynetid;
string zoneid;
bool dorigdestroy;
string prefabfoundation = "assets/prefabs/building core/foundation/foundation.prefab";
string prefabfoundationsteps = "assets/prefabs/building core/foundation.steps/foundation.steps.prefab";
string prefabfloor = "assets/prefabs/building core/floor/floor.prefab";
string prefabfloorframe = "assets/prefabs/building core/floor/floor.prefab";
//string prefabfloorframe = "assets/prefabs/building core/floor.frame/floor.frame.prefab";
string prefabfloorgrill = "assets/prefabs/building/floor.grill/floor.grill.prefab";
string prefabwall = "assets/prefabs/building core/wall/wall.prefab";
string prefabwallframe = "assets/prefabs/building core/wall.frame/wall.frame.prefab";
string prefabwallhalf = "assets/prefabs/building core/wall.half/wall.half.prefab";
string prefablowwall = "assets/prefabs/building core/wall.low/wall.low.prefab";
string prefabstairsl = "assets/prefabs/building core/stairs.l/block.stair.lshape.prefab";
string prefabdoorway = "assets/prefabs/building core/wall.doorway/wall.doorway.prefab";
string prefabpumpjack = "assets/prefabs/deployable/oil jack/mining.pumpjack.prefab";
// ... [Code preview truncated due to length. Full source in attached file] ...