Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions EXILED/Exiled.API/Features/Spawn/RoomSpawnPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public override Vector3 Position
{
Room roomInstance = Features.Room.Get(Room) ?? throw new InvalidOperationException("The room instance could not be found.");

if (roomInstance.Type == RoomType.Surface)
return Offset != Vector3.zero ? Offset : roomInstance.Position;

return Offset != Vector3.zero ? roomInstance.transform.TransformPoint(Offset) : roomInstance.Position;
}
set => throw new InvalidOperationException("The position of this type of SpawnPoint cannot be changed.");
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 @@ -35,7 +35,7 @@ public override void OnEnabled()
roundHandler = new MapHandler();
playerHandler = new PlayerHandler();

Exiled.Events.Handlers.Map.Generated += roundHandler.OnMapGenerated;
Exiled.Events.Handlers.Server.WaitingForPlayers += roundHandler.OnWaitingForPlayers;

Exiled.Events.Handlers.Player.ChangingItem += playerHandler.OnChangingItem;

Expand All @@ -50,7 +50,7 @@ public override void OnEnabled()
/// <inheritdoc />
public override void OnDisabled()
{
Exiled.Events.Handlers.Map.Generated -= roundHandler!.OnMapGenerated;
Exiled.Events.Handlers.Server.WaitingForPlayers -= roundHandler!.OnWaitingForPlayers;

Exiled.Events.Handlers.Player.ChangingItem -= playerHandler!.OnChangingItem;

Expand Down
18 changes: 14 additions & 4 deletions EXILED/Exiled.CustomItems/Events/MapHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Exiled.CustomItems.Events
{
using Exiled.API.Features;
using Exiled.CustomItems.API.Features;
using MEC;

Expand All @@ -15,13 +16,22 @@ namespace Exiled.CustomItems.Events
/// </summary>
internal sealed class MapHandler
{
/// <inheritdoc cref="Exiled.Events.Handlers.Map.Generated"/>
public void OnMapGenerated()
/// <inheritdoc cref="Exiled.Events.Handlers.Server.WaitingForPlayers"/>
public void OnWaitingForPlayers()
{
Timing.CallDelayed(0.5f, () => // Delay its necessary for the spawnpoints of lockers and rooms to be generated.
Timing.CallDelayed(2, () => // The delay is necessary because the generation of the lockers takes time, due to the way they are made in the base game.
Comment on lines -21 to +22
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be good if exiled OnWaitingPlayer get call when locker have finish to spawn too

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imagen
And how do you know when the lockers are created?

The Exiled lockers are created in the Awake of the base game lockers but the only way to know if they are already created would be to increase the delay that OnWaitingForPlayers already has.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fuck that kinda problematic yeah

{
foreach (CustomItem customItem in CustomItem.Registered)
customItem?.SpawnAll();
{
try
{
customItem?.SpawnAll();
}
catch (System.Exception e)
{
Log.Error($"There was an error while spawning the custom item '{customItem?.Name}' ({customItem?.Id}) | {e.Message}");
}
}
});
}
}
Expand Down