C#:
using Network;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace Oxide.Plugins {
/*ПЛАГИН БЫЛ ПОФИКШЕН С ПОМОЩЬЮ ПРОГРАММЫ СКАЧАНОЙ С https://discord.gg/dNGbxafuJn */
[Info("SquidGameRLGL", "https://discord.gg/dNGbxafuJn", "1.0.1")]
class SquidGameRLGL : RustPlugin {
#region Config
private PluginConfig _config;
protected override void LoadDefaultConfig() {
Puts("Creating a default config...");
_config = PluginConfig.DefaultConfig();
_config.PluginVersion = Version;
SaveConfig();
Puts("Creation of the default config completed!");
}
protected override void LoadConfig() {
base.LoadConfig();
_config = Config.ReadObject<PluginConfig>();
if (_config.PluginVersion < Version) UpdateConfigValues();
}
private void UpdateConfigValues() {
Puts("Config update detected! Updating config values...");
_config.PluginVersion = Version;
Puts("Config update completed!");
SaveConfig();
}
protected override void SaveConfig() => Config.WriteObject(_config);
public class ItemConfig {
[JsonProperty("ShortName")]
public string ShortName;
[JsonProperty("Минимальное кол-во")]
public int MinAmount;
[JsonProperty("Максимальное кол-во")]
public int MaxAmount;
[JsonProperty("Шанс выпадения предмета [0.0-100.0]")]
public float Chance;
[JsonProperty("Это чертеж? [true/false]")]
public bool IsBluePrint;
[JsonProperty("SkinID (0 - default)")]
public ulong SkinID;
[JsonProperty("Название (empty - default)")]
public string Name;
}
public class LootTableConfig {
[JsonProperty("Минимальное кол-во элементов")]
public int Min;
[JsonProperty("Максимальное кол-во элементов")]
public int Max;
[JsonProperty("Список предметов")]
public List<ItemConfig> Items;
}
private class PluginConfig {
[JsonProperty("Префикс сообщений в чате")]
public string Prefix;
[JsonProperty("Погрешность изменения положения игрока при красном индикаторе [м.]")]
public float ePos;
[JsonProperty("Погрешность изменения положения камеры игрока при красном индикаторе [degrees]")]
public float eRot;
[JsonProperty("Минимальное время между ивентами [sec.]")]
public float MinStartTime;
[JsonProperty("Максимальное время между ивентами [sec.]")]
public float MaxStartTime;
[JsonProperty("Время ожидания в начале ивента [sec.]")]
public float TimeToStart;
[JsonProperty("Время проведения ивента [sec.]")]
public float Time;
[JsonProperty("Время ожидания в конце ивента [sec.]")]
public float TimeToFinish;
[JsonProperty("Минимальное начальное время проведения стадии (не менее 2) [sec.]")]
public float TimeMinStage;
[JsonProperty("Максимальное начальное время проведения стадии (не менее 4) [sec.]")]
public float TimeMaxStage;
[JsonProperty("Язык озвучки [ru/en]")]
public string Language;
[JsonProperty("Список команд, которые запрещены в зоне ивента")]
public List<string> Commands;
[JsonProperty("Таблица предметов при победе в игре")]
public LootTableConfig Loot;
[JsonProperty("Версия конфигурации")]
public VersionNumber PluginVersion;
public static PluginConfig DefaultConfig() {
return new PluginConfig() {
Prefix = "[SquidGame]", ePos = 0.1f, eRot = 10f, MinStartTime = 3600f, MaxStartTime = 3600f, TimeToStart = 180f, Time = 300f, TimeToFinish = 60f, TimeMinStage = 3f, TimeMaxStage = 6f, Language = "en", Commands = new List<string> {
"/kit", "kit", "/store", "store.opencart", "/shop", "/backpack", "/bp", "backpack.open", "/trade", "trade", "/kits", "tp.menu", "/craft", "/discord"
}
, Loot = new LootTableConfig {
Min = 6, Max = 12, Items = new List<ItemConfig> {
new ItemConfig {
ShortName = "rifle.lr300", MinAmount = 1, MaxAmount = 1, Chance = 2.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "ammo.rifle.hv", MinAmount = 10, MaxAmount = 30, Chance = 6.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "ammo.rifle.explosive", MinAmount = 8, MaxAmount = 24, Chance = 7.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "metalpipe", MinAmount = 5, MaxAmount = 5, Chance = 8.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "techparts", MinAmount = 4, MaxAmount = 4, Chance = 8.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "sheetmetal", MinAmount = 5, MaxAmount = 5, Chance = 8.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "gears", MinAmount = 5, MaxAmount = 5, Chance = 8.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "smg.mp5", MinAmount = 1, MaxAmount = 1, Chance = 12.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "shotgun.spas12", MinAmount = 1, MaxAmount = 1, Chance = 12.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "pistol.m92", MinAmount = 1, MaxAmount = 1, Chance = 12.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "rifle.m39", MinAmount = 1, MaxAmount = 1, Chance = 12.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "ammo.rifle.incendiary", MinAmount = 8, MaxAmount = 24, Chance = 13.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "explosive.timed", MinAmount = 1, MaxAmount = 1, Chance = 14.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "chainsaw", MinAmount = 1, MaxAmount = 1, Chance = 14.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "jackhammer", MinAmount = 1, MaxAmount = 1, Chance = 14.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "ammo.pistol.hv", MinAmount = 10, MaxAmount = 30, Chance = 14.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "hoodie", MinAmount = 1, MaxAmount = 1, Chance = 20.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "bucket.helmet", MinAmount = 1, MaxAmount = 1, Chance = 20.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "riot.helmet", MinAmount = 1, MaxAmount = 1, Chance = 20.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "pants", MinAmount = 1, MaxAmount = 1, Chance = 20.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "coffeecan.helmet", MinAmount = 1, MaxAmount = 1, Chance = 20.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "roadsign.kilt", MinAmount = 1, MaxAmount = 1, Chance = 21.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "roadsign.jacket", MinAmount = 1, MaxAmount = 1, Chance = 21.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "roadsign.gloves", MinAmount = 1, MaxAmount = 1, Chance = 21.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "rifle.semiauto", MinAmount = 1, MaxAmount = 1, Chance = 22.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "smg.2", MinAmount = 1, MaxAmount = 1, Chance = 22.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "shotgun.pump", MinAmount = 1, MaxAmount = 1, Chance = 22.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "smg.thompson", MinAmount = 1, MaxAmount = 1, Chance = 22.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "jacket.snow", MinAmount = 1, MaxAmount = 1, Chance = 25.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "ammo.pistol.fire", MinAmount = 10, MaxAmount = 30, Chance = 27.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "grenade.f1", MinAmount = 1, MaxAmount = 5, Chance = 29.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "explosive.satchel", MinAmount = 2, MaxAmount = 2, Chance = 29.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "ammo.shotgun.slug", MinAmount = 4, MaxAmount = 12, Chance = 29.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "ammo.shotgun.fire", MinAmount = 4, MaxAmount = 19, Chance = 29.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "metal.refined", MinAmount = 32, MaxAmount = 39, Chance = 33.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "scrap", MinAmount = 140, MaxAmount = 159, Chance = 34.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "ammo.rifle", MinAmount = 12, MaxAmount = 119, Chance = 55.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "ammo.shotgun", MinAmount = 6, MaxAmount = 38, Chance = 64.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
, new ItemConfig {
ShortName = "ammo.pistol", MinAmount = 15, MaxAmount = 85, Chance = 84.0f, IsBluePrint = false, SkinID = 0, Name = ""
}
}
}
, PluginVersion = new VersionNumber()
}
;
}
}
#endregion Config
#region Lang
protected override void LoadDefaultMessages() {
lang.RegisterMessages(new Dictionary<string, string> {
["Wait"]
= "{0} Game <color=#55aaff>Red Light, Green Light</color> <color=#738d43>will start</color> in <color=#55aaff>{1} sec.</color> If you want to play the game you have to write the command in the chat <color=#55aaff>/rlglenter</color>.Then you will move to the game area", ["Enter"] = "{0} You are a <color=#738d43>player</color> <color=#55aaff>Red Light, Green Light</color> game.Wait for the starting of the game...", ["Exit"] = "{0} You <color=#ce3f27>have left</color> the game <color=#55aaff>Red Light, Green Light</color>", ["Start"] = "{0} Сбор игроков окончен.В игре участвуют {1} игроков\nИгра Red Light, Green Light началась!\nКогда на экране игрока красный индиктор, то движение запрещено.Если движение будет замечено, то вы выбываете из игры.Пока индикатор зеленый, у вас есть возможность двигаться.Побеждают все игроки, которые пересекут финишную линию до истечения таймера", ["RedLight"] = "{0} <color=#ce3f27>Red</color> Light! You <color=#ce3f27>can’t move</color>", ["GreenLight"] = "{0} <color=#738d43>Green</color> Light! You <color=#738d43>can move</color>", ["NoActiveEvent"] = "{0} Game <color=#55aaff>Red Light, Green Light</color> is <color=#ce3f27>not active</color> at this moment", ["NoWaitStageEvent"] = "{0} The meeting of players in the game <color=#55aaff>Red Light, Green Light</color> is <color=#ce3f27>finished</color>", ["DetectMove"] = "{0} your <color=#ce3f27>movement has been detected</color>!", ["ToSpectate"] = "{0} You have been <color=#55aaff>spectate</color> status in the game <color=#55aaff>Red Light, Green Light</color>", ["ToWinner"] = "{0} <color=#738d43>Congratulations</color>! You are the <color=#738d43>winner</color> of the game <color=#55aaff>Red Light, Green Light</color>", ["Winner"] = "{0} <color=#55aaff>{1}</color> is the <color=#738d43>winner</color> of the game <color=#55aaff>Red Light, Green Light</color>", ["Loser"] = "{0} <color=#55aaff>{1}</color> is the <color=#ce3f27>loser</color> of the game <color=#55aaff>Red Light, Green Light</color>", ["Finish"] = "{0} Game <color=#55aaff>Red Light, Green Light</color> is over\nWinners: <color=#55aaff>{1}</color>", ["WaitGUI"] = "The game starts in {0} sec.", ["GameGUI"] = "The game finishes in {0} sec.", ["FinishGUI"] = "There are {0} sec.before leaving the game", ["EventActive"] = "{0} This event is active now.To finish this event (<color=#55aaff>/rlglstop</color>), then to start the next one!", ["NTeleportation"] = "{0} You <color=#ce3f27>can’t</color> teleport in the event area!", ["NoEscape"] = "{0} You <color=#ce3f27>can’t</color> enter the game when you are in the raid block!", ["NoAccesCommand"] = "{0} You <color=#ce3f27>can’t</color> use this command in the event area!", ["NoSuicide"] = "{0} You <color=#ce3f27>can’t</color> kill yourself in the event area!"
}
, this);
lang.RegisterMessages(new Dictionary<string, string> {
["Wait"]
= "{0} Через <color=#55aaff>{1} сек.</color> <color=#738d43>начнется</color> игра <color=#55aaff>Red Light, Green Light</color>.Чтобы сыграть в игру необходимо написать команду в чате <color=#55aaff>/rlglenter</color> и вы переместитесь на арену игры", ["Enter"] = "{0} Вы <color=#738d43>участник</color> игры <color=#55aaff>Red Light, Green Light</color>.Ожидайте начало игры...", ["Exit"] = "{0} Вы <color=#ce3f27>покинули</color> игру <color=#55aaff>Red Light, Green Light</color>", ["Start"] = "{0} Сбор игроков <color=#ce3f27>окончен</color>.В игре участвуют <color=#55aaff>{1}</color> игроков\nИгра <color=#55aaff>Red Light, Green Light</color> <color=#738d43>началась</color>!\nКогда на экране игрока красный индиктор, то движение запрещено.Если движение будет замечено, то вы выбываете из игры.Пока индикатор зеленый, у вас есть возможность двигаться.Побеждают все игроки, которые пересекут финишную линию до истечения таймера", ["RedLight"] = "{0} <color=#ce3f27>Красный</color> свет! Движение <color=#ce3f27>запрещено</color>", ["GreenLight"] = "{0} <color=#738d43>Зеленый</color> свет! Движение <color=#738d43>разрешено</color>", ["NoActiveEvent"] = "{0} Игра <color=#55aaff>Red Light, Green Light</color> в данный момент <color=#ce3f27>не активна</color>", ["NoWaitStageEvent"] = "{0} Сбор игроков в игре <color=#55aaff>Red Light, Green Light</color> уже <color=#ce3f27>окончен</color>", ["DetectMove"] = "{0} Ваше <color=#ce3f27>движение замечено</color>!", ["ToSpectate"] = "{0} Вы получили статус <color=#55aaff>наблюдателя</color> в игре <color=#55aaff>Red Light, Green Light</color>", ["ToWinner"] = "{0} <color=#738d43>Поздравляем</color>! Вы стали <color=#738d43>победителем</color> в игре <color=#55aaff>Red Light, Green Light</color>", ["Winner"] = "{0} <color=#55aaff>{1}</color> стал <color=#738d43>победителем</color> в игре <color=#55aaff>Red Light, Green Light</color>", ["Loser"] = "{0} <color=#55aaff>{1}</color> стал <color=#ce3f27>проигравшим</color> в игре <color=#55aaff>Red Light, Green Light</color>", ["Finish"] = "{0} Игра <color=#55aaff>Red Light, Green Light</color> окончена\nПобедители: <color=#55aaff>{1}</color>", ["WaitGUI"] = "До начала игры осталось {0} сек.", ["GameGUI"] = "До окончания игры осталось {0} сек.", ["FinishGUI"] = "До выхода из игры осталось {0} сек.", ["EventActive"] = "{0} Ивент в данный момент активен, сначала завершите текущий ивент (<color=#55aaff>/rlglstop</color>), чтобы начать следующий!", ["NTeleportation"] = "{0} Вы <color=#ce3f27>не можете</color> телепортироваться в зоне ивента!", ["NoEscape"] = "{0} Вы <color=#ce3f27>не можете</color> войти в игру, пока находитесь в рейд-блоке!", ["NoAccesCommand"] = "{0} Вы <color=#ce3f27>не можете</color> использовать данную команду в зоне ивента!", ["NoSuicide"] = "{0} Вы <color=#ce3f27>не можете</color> убить себя в зоне ивента!"
}
, this, "ru");
}
string GetMessage(string langKey, ulong UID) => ins.lang.GetMessage(langKey, ins, UID.ToString());
string GetMessage(string langKey, ulong UID, params object[] args) => (args.Length == 0) ? GetMessage(langKey, UID) : string.Format(GetMessage(langKey, UID), args);
#endregion Lang
#region Oxide Hooks
[PluginReference]
Plugin NoEscape;
private static SquidGameRLGL ins;
void Init() {
ins = this;
Unsubscribes();
}
void OnServerInitialized() {
foreach (ElectricalBranch branch in UnityEngine.Object.FindObjectsOfType<ElectricalBranch>()) {
if (branch.branchAmount == 8923) {
main = branch;
break;
}
}
if (main == null) {
if (attempts < 10) {
attempts++;
timer.In(9f, () => OnServerInitialized());
}
else {
PrintError("The prefab location is missing on the map.The plugin cannot be loaded!");
Server.Command($"o.unload {Name}");
}
return;
}
LoadDefaultMessages();
FindMonuments();
timer.In(UnityEngine.Random.Range(_config.MinStartTime, _config.MaxStartTime), () => {
if (controller == null) Start();
else Puts("This event is active now.To finish this event (rlglstop), then to start the next one");
}
);
}
void Unload() {
if (controller != null) Finish();
ins = null;
}
object OnPlayerDeath(BasePlayer player, HitInfo info) {
MemberSquidGame member = controller.members.Where(x => x.player == player).FirstOrDefault();
if (member != null) {
if (controller.StageGame == 2) {
controller.ToSpectateMember(member);
foreach (MemberSquidGame m in controller.members) PrintToChat(m.player, GetMessage("Loser", m.player.userID, _config.Prefix, player.displayName));
}
else if (controller.StageGame == 3) {
controller.RemoveMember(member);
controller.members.Remove(member);
}
return true;
}
return null;
}
object OnServerCommand(ConsoleSystem.Arg arg) {
BasePlayer player = arg.Player();
if (player == null || string.IsNullOrEmpty(arg.cmd?.FullName)) return null;
MemberSquidGame member = controller.members.Where(x => x.player == player).FirstOrDefault();
if (member == null) return null;
if (arg.cmd.Name == "kill") {
PrintToChat(player, GetMessage("NoSuicide", player.userID, _config.Prefix));
return false;
}
if (_config.Commands.Contains(arg.cmd.Name.ToLower()) || _config.Commands.Contains(arg.cmd.FullName.ToLower())) {
PrintToChat(player, GetMessage("NoAccesCommand", player.userID, _config.Prefix));
return false;
}
return null;
}
object OnPlayerCommand(BasePlayer player, string command, string[] args) {
if (player == null) return null;
MemberSquidGame member = controller.members.Where(x => x.player == player).FirstOrDefault();
if (member == null) return null;
command = command.Insert(0, "/");
if (_config.Commands.Contains(command.ToLower())) {
PrintToChat(player, GetMessage("NoAccesCommand", player.userID, _config.Prefix));
return false;
}
return null;
}
#endregion Oxide Hooks
#region Controller
ElectricalBranch main;
ControllerSquidGame controller;
void Start() {
Subscribes();
controller = main.gameObject.AddComponent<ControllerSquidGame>();
foreach (BasePlayer target in BasePlayer.activePlayerList) PrintToChat(target, GetMessage("Wait", target.userID, _config.Prefix, (int)_config.TimeToStart));
}
void Finish() {
Unsubscribes();
foreach (BasePlayer target in BasePlayer.activePlayerList) PrintToChat(target, GetMessage("Finish", target.userID, _config.Prefix, string.IsNullOrEmpty(controller.winners) ? "-" : controller.winners));
if (controller != null) UnityEngine.Object.Destroy(controller);
NextTick(() => Server.Command($"o.reload {Name}"));
}
public class ControllerSquidGame : FacepunchBehaviour {
Transform Transform;
public int StageGame = 1;
bool IsGreen = false;
bool IsRed = false;
string currentKey;
public string winners = "";
float timeMinStage;
float timeMaxStage;
float timeStage;
float time;
List<Vector3> SpectatePositions = new List<Vector3> {
new Vector3(-19.58f, 19.35f, 6.218f), new Vector3(19.501f, 20.6f, -2.788f)
}
;
public HashSet<MemberSquidGame> members = new HashSet<MemberSquidGame>();
HashSet<SimpleBuildingBlock> walls = new HashSet<SimpleBuildingBlock>();
HashSet<BasePlayer> dummies = new HashSet<BasePlayer>();
DeployableBoomBox boomBox;
Cassette cassette;
Dictionary<string, uint> audioIDs = new Dictionary<string, uint>();
HashSet<ConnectedSpeaker> speakers = new HashSet<ConnectedSpeaker>();
HashSet<Location> SpeakerLocations = new HashSet<Location> {
new Location {
Position = new Vector3(14.85f, 7.4f, 39.25f), Rotation = new Vector3(0f, 180f, 0f)
}
, new Location {
Position = new Vector3(0f, 1f, 39.25f), Rotation = new Vector3(0f, 90f, 90f)
}
, new Location {
Position = new Vector3(-13.85f, 7.4f, 39.25f), Rotation = new Vector3(0f, 0f, 0f)
}
, new Location {
Position = new Vector3(18.85f, 7.4f, 24.25f), Rotation = new Vector3(0f, 180f, 0f)
}
, new Location {
Position = new Vector3(0f, 1f, 24.25f), Rotation = new Vector3(0f, 90f, 90f)
}
, new Location {
Position = new Vector3(-18.15f, 6.85f, 24.25f), Rotation = new Vector3(0f, 0f, 0f)
}
, new Location {
Position = new Vector3(15.85f, 7.4f, 9.25f), Rotation = new Vector3(0f, 180f, 0f)
}
, new Location {
Position = new Vector3(0f, 1f, 9.25f), Rotation = new Vector3(0f, 90f, 90f)
}
, new Location {
Position = new Vector3(-14.9f, 6.25f, 9.25f), Rotation = new Vector3(0f, 0f, 0f)
}
, new Location {
Position = new Vector3(14.85f, 7.4f, -5.75f), Rotation = new Vector3(0f, 180f, 0f)
}
, new Location {
Position = new Vector3(0f, 1f, -5.75f), Rotation = new Vector3(0f, 90f, 90f)
}
, new Location {
Position = new Vector3(-15.9f, 6.15f, -5.75f), Rotation = new Vector3(0f, 0f, 0f)
}
, new Location {
Position = new Vector3(18.4f, 7.4f, -20.75f), Rotation = new Vector3(0f, 180f, 0f)
}
, new Location {
Position = new Vector3(0f, 1f, -20.75f), Rotation = new Vector3(0f, 90f, 90f)
}
, new Location {
Position = new Vector3(-15.35f, 7.6f, -20.75f), Rotation = new Vector3(0f, 0f, 0f)
}
, new Location {
Position = new Vector3(14.85f, 7.4f, -35.75f), Rotation = new Vector3(0f, 180f, 0f)
}
, new Location {
Position = new Vector3(0f, 1f, -35.75f), Rotation = new Vector3(0f, 90f, 90f)
}
, new Location {
Position = new Vector3(-14.9f, 7.4f, -35.75f), Rotation = new Vector3(0f, 0f, 0f)
}
}
;
class Location {
public Vector3 Position;
public Vector3 Rotation;
}
HBHFSensor sensorRight;
HBHFSensor sensorLeft;
DropBox dropBoxUp;
DropBox dropBoxDown;
ElectricBattery battery;
ModularCarOven bbq;
Dictionary<BaseEntity, Animation> animations = new Dictionary<BaseEntity, Animation>();
HashSet<Move> AllMoveTurnHeadBack;
HashSet<Move> AllMoveTurnHeadForward;
class Move {
public float time;
public HashSet<EntityPos> entities;
}
class EntityPos {
public BaseEntity entity;
public Vector3 pos;
public Vector3 rot;
}
void AddMove() {
AllMoveTurnHeadBack = new HashSet<Move> {
new Move {
time = 0.25f, entities = new HashSet<EntityPos> {
new EntityPos {
entity = sensorRight, pos = new Vector3(-0.541f, 6.904f, 47.478f), rot = new Vector3(0f, 270f, 0f)
}
, new EntityPos {
entity = sensorLeft, pos = new Vector3(-0.541f, 6.904f, 46.871f), rot = new Vector3(0f, 270f, 0f)
}
, new EntityPos {
entity = dropBoxUp, pos = new Vector3(0f, 6.82f, 47.175f), rot = new Vector3(270f, 90f, 0f)
}
, new EntityPos {
entity = dropBoxDown, pos = new Vector3(0f, 6.515f, 47.175f), rot = new Vector3(270f, 90f, 0f)
}
, new EntityPos {
entity = battery, pos = new Vector3(0f, 5.902f, 47.174f), rot = new Vector3(0f, 90f, 0f)
}
, new EntityPos {
entity = bbq, pos = new Vector3(-0.413f, 6.282f, 47.18f), rot = new Vector3(0f, 180f, 270f)
}
}
}
, new Move {
time = 0.25f, entities = new HashSet<EntityPos> {
new EntityPos {
entity = sensorRight, pos = new Vector3(0.304f, 6.904f, 47.715f), rot = new Vector3(0f, 0f, 0f)
}
, new EntityPos {
entity = sensorLeft, pos = new Vector3(-0.304f, 6.904f, 47.715f), rot = new Vector3(0f, 0f, 0f)
}
, new EntityPos {
entity = dropBoxUp, pos = new Vector3(0f, 6.82f, 47.183f), rot = new Vector3(270f, 180f, 0f)
}
, new EntityPos {
entity = dropBoxDown, pos = new Vector3(0f, 6.515f, 47.183f), rot = new Vector3(270f, 180f, 0f)
}
, new EntityPos {
entity = battery, pos = new Vector3(0f, 5.902f, 47.174f), rot = new Vector3(0f, 180f, 0f)
}
, new EntityPos {
entity = bbq, pos = new Vector3(0f, 6.282f, 47.588f), rot = new Vector3(0f, 270f, 270f)
}
}
}
}
;
AllMoveTurnHeadForward = new HashSet<Move> {
new Move {
time = 0.25f, entities = new HashSet<EntityPos> {
new EntityPos {
entity = sensorRight, pos = new Vector3(-0.541f, 6.904f, 47.478f), rot = new Vector3(0f, 270f, 0f)
}
, new EntityPos {
entity = sensorLeft, pos = new Vector3(-0.541f, 6.904f, 46.871f), rot = new Vector3(0f, 270f, 0f)
}
, new EntityPos {
entity = dropBoxUp, pos = new Vector3(0f, 6.82f, 47.175f), rot = new Vector3(270f, 90f, 0f)
}
, new EntityPos {
entity = dropBoxDown, pos = new Vector3(0f, 6.515f, 47.175f), rot = new Vector3(270f, 90f, 0f)
}
, new EntityPos {
entity = battery, pos = new Vector3(0f, 5.902f, 47.174f), rot = new Vector3(0f, 90f, 0f)
}
, new EntityPos {
entity = bbq, pos = new Vector3(-0.413f, 6.282f, 47.18f), rot = new Vector3(0f, 180f, 270f)
}
}
}
, new Move {
time = 0.25f, entities = new HashSet<EntityPos> {
new EntityPos {
entity = sensorRight, pos = new Vector3(-0.304f, 6.904f, 46.652f), rot = new Vector3(0f, 180f, 0f)
}
, new EntityPos {
entity = sensorLeft, pos = new Vector3(0.304f, 6.904f, 46.652f), rot = new Vector3(0f, 180f, 0f)
}
, new EntityPos {
entity = dropBoxUp, pos = new Vector3(0f, 6.82f, 47.185f), rot = new Vector3(270f, 0f, 0f)
}
, new EntityPos {
entity = dropBoxDown, pos = new Vector3(0f, 6.515f, 47.185f), rot = new Vector3(270f, 0f, 0f)
}
, new EntityPos {
entity = battery, pos = new Vector3(0f, 5.902f, 47.194f), rot = new Vector3(0f, 0f, 0f)
}
, new EntityPos {
entity = bbq, pos = new Vector3(0f, 6.282f, 46.78f), rot = new Vector3(0f, 90f, 270f)
}
}
}
}
;
}
void Awake() {
Transform = GetComponent<Transform>();
SpawnHead();
AddMove();
SpawnWalls();
SpawnAudio();
SpawnDummy(GetGlobalPosition(Transform, new Vector3(-2.6f, 1.8f, 47f)), GetGlobalRotation(Transform, new Vector3(2.2f, 182.2f, 0f)));
SpawnDummy(GetGlobalPosition(Transform, new Vector3(2.6f, 1.8f, 47f)), GetGlobalRotation(Transform, new Vector3(4.5f, 181.5f, 0f)));
time = ins._config.TimeToStart;
timeMinStage = ins._config.TimeMinStage;
timeMaxStage = ins._config.TimeMaxStage;
timeStage = UnityEngine.Random.Range(timeMinStage, timeMaxStage);
InvokeRepeating(DecrementTime, 1f, 1f);
InvokeRepeating(UpdateGUI, 0f, 1f);
}
void OnDestroy() {
CancelInvoke(DecrementTime);
CancelInvoke(UpdateGUI);
ServerMgr.Instance.StopCoroutine(StageGreen());
ServerMgr.Instance.StopCoroutine(StageRed());
foreach (MemberSquidGame member in members) RemoveMember(member);
KillWalls();
foreach (BasePlayer dummy in dummies) if (IsAlive(dummy)) dummy.Kill();
CancelInvoke(PlaySound);
CancelInvoke(StopSound);
StopSound();
if (IsAlive(boomBox)) boomBox.Kill();
foreach (ConnectedSpeaker speaker in speakers) if (IsAlive(speaker)) speaker.Kill();
ServerMgr.Instance.StopCoroutine(TurnHeadBack());
ServerMgr.Instance.StopCoroutine(TurnHeadForward());
if (IsAlive(sensorRight)) sensorRight.Kill();
if (IsAlive(sensorLeft)) sensorLeft.Kill();
if (IsAlive(dropBoxUp)) dropBoxUp.Kill();
if (IsAlive(dropBoxDown)) dropBoxDown.Kill();
if (IsAlive(battery)) battery.Kill();
if (IsAlive(bbq)) bbq.Kill();
}
public void AddMember(BasePlayer player) {
MemberSquidGame member = new MemberSquidGame {
player = player, teleportPos = Vector3.zero, containerBelt = ins.SaveItems(player.inventory.containerBelt.itemList), containerWear = ins.SaveItems(player.inventory.containerWear.itemList), containerMain = ins.SaveItems(player.inventory.containerMain.itemList), lastPos = Vector3.zero, lastRot = Vector3.zero, IsSpectate = false, IsWinner = false
}
;
if (player.IsBuildingAuthed()) member.teleportPos = player.transform.position;
else if (ins.spawnMonuments.Count > 0) member.teleportPos = ins.spawnMonuments.GetRandom();
else member.teleportPos = ServerMgr.FindSpawnPoint(player).pos;
members.Add(member);
ClearInventory(player);
player.State.unHostileTimestamp = 0;
Teleport(player, GetSpawnPosition());
player.metabolism.Reset();
player.SetHealth(100f);
ItemManager.CreateByName("shoes.boots", 1, 2552314771).MoveToContainer(player.inventory.containerWear);
ItemManager.CreateByName("pants", 1, 834766778).MoveToContainer(player.inventory.containerWear);
ItemManager.CreateByName("hoodie", 1, 14072).MoveToContainer(player.inventory.containerWear);
ins.PrintToChat(player, ins.GetMessage("Enter", player.userID, ins._config.Prefix));
}
public void RemoveMember(MemberSquidGame member) {
CuiHelper.DestroyUi(member.player, "TextMain");
CuiHelper.DestroyUi(member.player, "IndicatorMain");
member.player.State.unHostileTimestamp = 0;
Teleport(member.player, member.teleportPos);
member.player.metabolism.Reset();
member.player.SetHealth(100f);
ClearInventory(member.player);
foreach (Item item in ins.RestoreItems(member.containerBelt)) item.MoveToContainer(member.player.inventory.containerBelt);
foreach (Item item in ins.RestoreItems(member.containerWear)) item.MoveToContainer(member.player.inventory.containerWear);
foreach (Item item in ins.RestoreItems(member.containerMain)) ins.MoveItem(member.player, item);
if (member.IsWinner) foreach (Item item in GetWinItems()) ins.MoveItem(member.player, item);
ins.PrintToChat(member.player, ins.GetMessage("Exit", member.player.userID, ins._config.Prefix));
}
public void ToSpectateMember(MemberSquidGame member) {
member.player.State.unHostileTimestamp = 0;
Vector3 localPos = SpectatePositions.GetRandom();
localPos.x = UnityEngine.Random.Range(localPos.x - 1f, localPos.x + 1f);
localPos.z = UnityEngine.Random.Range(localPos.z - 1f, localPos.z + 1f);
Teleport(member.player, GetGlobalPosition(Transform, localPos));
member.player.metabolism.Reset();
member.player.SetHealth(100f);
member.IsSpectate = true;
ins.PrintToChat(member.player, ins.GetMessage("ToSpectate", member.player.userID, ins._config.Prefix));
}
void SpawnWalls() {
for (int i = 0; i < 5; i++) {
SimpleBuildingBlock wall = GameManager.server.CreateEntity("assets/prefabs/building/wall.external.high.stone/wall.external.high.stone.prefab", GetGlobalPosition(Transform, new Vector3(11.83f - i * 6.11f, 1.639f, -43.221f)), Quaternion.Euler(GetGlobalRotation(Transform, new Vector3(0f, 0f, 0f)))) as SimpleBuildingBlock;
wall.enableSaving = false;
wall.Spawn();
wall.limitNetworking = true;
walls.Add(wall);
}
}
void KillWalls() {
foreach (SimpleBuildingBlock wall in walls) if (IsAlive(wall)) wall.Kill();
}
void SpawnDummy(Vector3 pos, Vector3 rot) {
BasePlayer dummy = GameManager.server.CreateEntity("assets/prefabs/player/player.prefab", pos) as BasePlayer;
dummy.viewAngles = rot;
dummy.enableSaving = false;
dummy.Spawn();
ClearInventory(dummy);
ItemManager.CreateByName("smg.mp5").MoveToContainer(dummy.inventory.containerBelt);
dummy.UpdateActiveItem(dummy.inventory.containerBelt.itemList[0].uid);
ItemManager.CreateByName("shoes.boots", 1, 2090776132).MoveToContainer(dummy.inventory.containerWear);
ItemManager.CreateByName("pants", 1, 2631440368).MoveToContainer(dummy.inventory.containerWear);
ItemManager.CreateByName("hoodie", 1, 2631350189).MoveToContainer(dummy.inventory.containerWear);
ItemManager.CreateByName("burlap.gloves", 1, 2090790324).MoveToContainer(dummy.inventory.containerWear);
ItemManager.CreateByName("mask.bandana", 1, 2412392358).MoveToContainer(dummy.inventory.containerWear);
ItemManager.CreateByName("riot.helmet", 1, 2631346403).MoveToContainer(dummy.inventory.containerWear);
dummies.Add(dummy);
}
void SpawnAudio() {
boomBox = GameManager.server.CreateEntity("assets/prefabs/voiceaudio/boombox/boombox.deployed.prefab", GetGlobalPosition(Transform, new Vector3(-0.023f, 4.223f, 49.170f)), Quaternion.Euler(GetGlobalRotation(Transform, new Vector3(0f, 180f, 0f)))) as DeployableBoomBox;
boomBox.enableSaving = false;
boomBox.Spawn();
boomBox.UpdateFromInput(35, 0);
IOEntity.IOSlot outSlot = boomBox.outputs[0];
IOEntity outEntity = boomBox;
foreach (Location location in SpeakerLocations) {
ConnectedSpeaker speaker = GameManager.server.CreateEntity("assets/prefabs/voiceaudio/hornspeaker/connectedspeaker.deployed.prefab", GetGlobalPosition(Transform, location.Position), Quaternion.Euler(GetGlobalRotation(Transform, location.Rotation))) as ConnectedSpeaker;
speaker.enableSaving = false;
speaker.Spawn();
speakers.Add(speaker);
outSlot.connectedTo.Set(speaker);
speaker.inputs[0].connectedTo.Set(outEntity);
outEntity.MarkDirtyForceUpdateOutputs();
speaker.MarkDirtyForceUpdateOutputs();
outSlot = speaker.outputs[0];
outEntity = speaker;
}
SpawnCassette();
LoadAudio();
SetSound("start");
Invoke(PlaySound, 1f);
}
void SpawnCassette() {
Item item = ItemManager.CreateByName("cassette");
cassette = ItemModAssociatedEntity<Cassette>.GetAssociatedEntity(item);
cassette.MaxCassetteLength = 30f;
item.MoveToContainer(boomBox.inventory);
item.MarkDirty();
boomBox.OnCassetteInserted(cassette);
}
void LoadAudio() {
foreach (var dic in ins.sounds[ins._config.Language]) audioIDs.Add(dic.Key, FileStorage.server.Store(dic.Value, FileStorage.Type.ogg, cassette.net.ID));
}
void SetSound(string key) {
cassette.SetAudioId(audioIDs[key], 76561198328868364);
currentKey = key;
}
void PlaySound() {
boomBox.UpdateFromInput(1, 1);
Invoke(StopSound, ins.timeSounds[ins._config.Language][currentKey]);
}
void StopSound() {
boomBox.UpdateFromInput(0, 1);
if (currentKey == "start") {
if (time > ins.timeSounds[ins._config.Language]["start"] + 1f) Invoke(PlaySound, 1f);
else SetSound("green");
}
else if (currentKey == "red") SetSound("green");
else if (currentKey == "green") SetSound("red");
}
void StartGame() {
StageGame = 2;
time = ins._config.Time;
KillWalls();
foreach (BasePlayer target in BasePlayer.activePlayerList) ins.PrintToChat(target, ins.GetMessage("Start", target.userID, ins._config.Prefix, members.Count));
IsGreen = true;
UpdateGUI();
foreach (MemberSquidGame member in members) ins.PrintToChat(member.player, ins.GetMessage("GreenLight", member.player.userID, ins._config.Prefix));
PlaySound();
ServerMgr.Instance.StartCoroutine(StageGreen());
}
void FinishGame() {
StageGame = 3;
IsGreen = false;
IsRed = false;
time = ins._config.TimeToFinish;
UpdateGUI();
foreach (MemberSquidGame member in members.Where(x => !x.IsSpectate && !x.player.IsHostile())) HostilePlayer(member.player);
InvokeRepeating(DecrementTime, 1f, 1f);
}
void DecrementTime() {
time -= 1f;
if (time < 1f) {
if (StageGame == 1) StartGame();
else if (StageGame == 2) FinishGame();
else if (StageGame == 3) ins.Finish();
CancelInvoke(DecrementTime);
}
}
IEnumerator StageGreen() {
float elapsedTime = 0f;
while (elapsedTime < timeStage) {
foreach (MemberSquidGame member in members.Where(x => !x.IsSpectate)) {
if (IsWinner(member.player)) {
winners += $" {member.player.displayName},";
member.IsWinner = true;
ToSpectateMember(member);
ins.PrintToChat(member.player, ins.GetMessage("ToWinner", member.player.userID, ins._config.Prefix));
foreach (MemberSquidGame m in members) ins.PrintToChat(m.player, ins.GetMessage("Winner", m.player.userID, ins._config.Prefix, member.player.displayName));
}
}
elapsedTime += 0.1f;
yield return CoroutineEx.w
// ... [Code preview truncated due to length. Full source in attached file] ...