Skip to content

Commit

Permalink
Adding support for CustomRoles
Browse files Browse the repository at this point in the history
  • Loading branch information
SrLicht committed Aug 26, 2024
1 parent 0ff63f1 commit 7cf5ee0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
11 changes: 10 additions & 1 deletion EXILED/Exiled.CustomItems/Commands/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,23 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
.Append("- ").AppendLine(item?.Description)
.AppendLine(item?.Type.ToString())
.Append("- Spawn Limit: ").AppendLine(item?.SpawnProperties?.Limit.ToString()).AppendLine()
.Append("[Spawn Locations (").Append(item?.SpawnProperties?.DynamicSpawnPoints.Count + item?.SpawnProperties?.StaticSpawnPoints.Count).AppendLine(")]");
.Append("[Spawn Locations (").Append(item?.SpawnProperties?.Count()).AppendLine(")]");

foreach (DynamicSpawnPoint spawnPoint in item?.SpawnProperties?.DynamicSpawnPoints!)
message.Append(spawnPoint.Name).Append(' ').Append(spawnPoint.Position).Append(" Chance: ").Append(spawnPoint.Chance).AppendLine("%");

foreach (StaticSpawnPoint spawnPoint in item.SpawnProperties.StaticSpawnPoints)
message.Append(spawnPoint.Name).Append(' ').Append(spawnPoint.Position).Append(" Chance: ").Append(spawnPoint.Chance).AppendLine("%");

foreach (RoleSpawnPoint spawnPoint in item.SpawnProperties.RoleSpawnPoints)
message.Append(spawnPoint.Name).Append(' ').Append(spawnPoint.Position).Append(" Chance: ").Append(spawnPoint.Chance).AppendLine("%");

foreach (LockerSpawnPoint spawnPoint in item.SpawnProperties.LockerSpawnPoints)
message.Append(spawnPoint.Name).Append(' ').Append(spawnPoint.Position).Append(" Chance: ").Append(spawnPoint.Chance).AppendLine("%");

foreach (RoomSpawnPoint spawnPoint in item.SpawnProperties.RoomSpawnPoints)
message.Append(spawnPoint.Name).Append(' ').Append(spawnPoint.Position).Append(" Chance: ").Append(spawnPoint.Chance).AppendLine("%");

response = StringBuilderPool.Pool.ToStringReturn(message);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions EXILED/Exiled.CustomItems/CustomItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Exiled.CustomItems
/// </summary>
public class CustomItems : Plugin<Config>
{
private RoundHandler? roundHandler;
private MapHandler? roundHandler;

Check failure on line 22 in EXILED/Exiled.CustomItems/CustomItems.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'MapHandler' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 22 in EXILED/Exiled.CustomItems/CustomItems.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'MapHandler' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 22 in EXILED/Exiled.CustomItems/CustomItems.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'MapHandler' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 22 in EXILED/Exiled.CustomItems/CustomItems.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'MapHandler' could not be found (are you missing a using directive or an assembly reference?)
private PlayerHandler? playerHandler;
private Harmony? harmony;

Expand All @@ -32,7 +32,7 @@ public class CustomItems : Plugin<Config>
public override void OnEnabled()
{
Instance = this;
roundHandler = new RoundHandler();
roundHandler = new MapHandler();
playerHandler = new PlayerHandler();

Exiled.Events.Handlers.Map.Generated += roundHandler.OnMapGenerated;
Expand Down
10 changes: 10 additions & 0 deletions EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,16 @@ protected Vector3 GetSpawnPosition()
}
}

if (SpawnProperties.RoomSpawnPoints.Count > 0)
{
foreach ((float chance, Vector3 pos) in SpawnProperties.RoomSpawnPoints)
{
double r = Loader.Random.NextDouble() * 100;
if (r <= chance)
return pos;
}
}

return Vector3.zero;
}

Expand Down

0 comments on commit 7cf5ee0

Please sign in to comment.