Skip to content

Commit

Permalink
now is array
Browse files Browse the repository at this point in the history
  • Loading branch information
SpGerg committed Apr 21, 2024
1 parent a9c00b5 commit 63490b4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
25 changes: 15 additions & 10 deletions UncomplicatedCustomItems/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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"
}
},
}
}
};
Expand Down
1 change: 1 addition & 0 deletions UncomplicatedCustomItems/Events/Internal/Player.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
23 changes: 12 additions & 11 deletions UncomplicatedCustomItems/Events/Internal/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,22 @@ private static void SpawnCustomItemsList(IEnumerable<SerializableThing> 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);
}
}
}
}
Expand Down

0 comments on commit 63490b4

Please sign in to comment.