From 63490b45cd3877c49e2abafed2454c7f7ccaa382 Mon Sep 17 00:00:00 2001 From: SpGerg Date: Mon, 22 Apr 2024 01:49:38 +0500 Subject: [PATCH] now is array --- .../API/Serializable/SerializableThing.cs | 2 +- UncomplicatedCustomItems/Config.cs | 25 +++++++++++-------- .../Events/Internal/Player.cs | 1 + .../Events/Internal/Server.cs | 23 +++++++++-------- 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/UncomplicatedCustomItems/API/Serializable/SerializableThing.cs b/UncomplicatedCustomItems/API/Serializable/SerializableThing.cs index e4c5c4c..728eb2e 100644 --- a/UncomplicatedCustomItems/API/Serializable/SerializableThing.cs +++ b/UncomplicatedCustomItems/API/Serializable/SerializableThing.cs @@ -24,7 +24,7 @@ public abstract class SerializableThing public Vector3 Scale { get; set; } [Description("Spawn properties")] - public ItemSpawnPoint SpawnPoint { get; set; } + public ItemSpawnPoint[] SpawnPoint { get; set; } public abstract CustomThing Create(Player player); } diff --git a/UncomplicatedCustomItems/Config.cs b/UncomplicatedCustomItems/Config.cs index 303addf..7d1c252 100644 --- a/UncomplicatedCustomItems/Config.cs +++ b/UncomplicatedCustomItems/Config.cs @@ -26,10 +26,13 @@ public class Config : IConfig Id = 0, Model = ItemType.KeycardFacilityManager, Scale = Vector3.one, - SpawnPoint = new ItemSpawnPoint() + SpawnPoint = new[] { - Position = Vector3.zero, - Location = Exiled.API.Enums.SpawnLocationType.InsideLczWc + new ItemSpawnPoint() + { + Position = Vector3.zero, + Location = Exiled.API.Enums.SpawnLocationType.InsideLczWc + }, }, Info = new KeycardInfo() { @@ -55,13 +58,15 @@ public class Config : IConfig BodyProtection = 99, HeadProtection = 99 }, - SpawnPoint = new ItemSpawnPoint() - { - Location = Exiled.API.Enums.SpawnLocationType.Inside914, - Chance = 100, - Position = Vector3.one, - Name = "Chipi chapa" - } + SpawnPoint = new[] { + new ItemSpawnPoint() + { + Location = Exiled.API.Enums.SpawnLocationType.Inside914, + Chance = 100, + Position = Vector3.one, + Name = "Chipi chapa" + } + }, } } }; diff --git a/UncomplicatedCustomItems/Events/Internal/Player.cs b/UncomplicatedCustomItems/Events/Internal/Player.cs index 2ff0aa4..9047f66 100644 --- a/UncomplicatedCustomItems/Events/Internal/Player.cs +++ b/UncomplicatedCustomItems/Events/Internal/Player.cs @@ -1,4 +1,5 @@ using Exiled.API.Features.Items; +using Exiled.API.Features.Pickups; using Exiled.Events.EventArgs.Player; using UncomplicatedCustomItems.API.Extensions; using UncomplicatedCustomItems.API.Features; diff --git a/UncomplicatedCustomItems/Events/Internal/Server.cs b/UncomplicatedCustomItems/Events/Internal/Server.cs index 0ecbf0b..e6009ba 100644 --- a/UncomplicatedCustomItems/Events/Internal/Server.cs +++ b/UncomplicatedCustomItems/Events/Internal/Server.cs @@ -36,21 +36,22 @@ private static void SpawnCustomItemsList(IEnumerable customTh { foreach (var customItem in customThings) { - if (customItem.SpawnPoint is null || customItem.SpawnPoint.Chance == 0) + foreach (var spawnPoint in customItem.SpawnPoint) { - continue; - } + if (customItem.SpawnPoint is null || spawnPoint.Chance == 0) + { + continue; + } - var spawnPoint = customItem.SpawnPoint; + var chance = UnityEngine.Random.Range(0, 100); - var chance = UnityEngine.Random.Range(0, 100); + if (spawnPoint.Chance != 100 && spawnPoint.Chance > chance) + { + continue; + } - if (spawnPoint.Chance != 100 && spawnPoint.Chance > chance) - { - continue; - } - - customItem.Create(null).Spawn(spawnPoint.Location.GetPosition() + spawnPoint.Position); + customItem.Create(null).Spawn(spawnPoint.Location.GetPosition() + spawnPoint.Position); + } } } }