Skip to content

Commit

Permalink
feat: Add scale property to SpawnLocation record (#517)
Browse files Browse the repository at this point in the history
* Add scale property to SpawnLocation record

* Fix breaking change

* Fix more compiler errors
  • Loading branch information
LeeTwentyThree committed Jan 1, 2024
1 parent 782ed96 commit f788ad9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Nautilus/Assets/Gadgets/GadgetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ public static ICustomPrefab SetSpawns(this ICustomPrefab customPrefab, params Sp
{
customPrefab.AddOnRegister(() =>
{
foreach ((Vector3 position, Vector3 eulerAngles) in spawnLocations)
foreach (var spawnLocation in spawnLocations)
{
CoordinatedSpawnsHandler.RegisterCoordinatedSpawn(new SpawnInfo(customPrefab.Info.ClassID, position, eulerAngles));
CoordinatedSpawnsHandler.RegisterCoordinatedSpawn(new SpawnInfo(customPrefab.Info.ClassID, spawnLocation.Position, spawnLocation.EulerAngles, spawnLocation.Scale));
}
});

Expand Down
19 changes: 18 additions & 1 deletion Nautilus/Assets/SpawnLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,21 @@ namespace Nautilus.Assets;
/// </summary>
/// <param name="Position">The world position.</param>
/// <param name="EulerAngles">Euler angles for the rotation the spawned object will appear with.</param>
public record SpawnLocation(Vector3 Position, Vector3 EulerAngles = default);
public record SpawnLocation(Vector3 Position, Vector3 EulerAngles = default)
{
/// <summary>
/// The scale that the object is spawned at. If default (0, 0, 0) will be resolved to (1, 1, 1).
/// </summary>
public Vector3 Scale { get; init; }

/// <summary>
/// Defines the spawn location with world position and optional euler angles. Used in the Coordinated Spawns system.
/// </summary>
/// <param name="Position">The world position.</param>
/// <param name="EulerAngles">Euler angles for the rotation the spawned object will appear with.</param>
/// <param name="Scale">The scale that the object is spawned at. If default (0, 0, 0) will be resolved to (1, 1, 1).</param>
public SpawnLocation(Vector3 Position, Vector3 EulerAngles, Vector3 Scale) : this(Position, EulerAngles)
{
this.Scale = Scale;
}
}
2 changes: 1 addition & 1 deletion Nautilus/Handlers/CoordinatedSpawnsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void RegisterCoordinatedSpawns(List<SpawnInfo> spawnInfos)
/// <param name="spawnLocations">The spawn locations to spawn in. Euler angles are optional.</param>
public static void RegisterCoordinatedSpawnsForOneTechType(TechType techTypeToSpawn, params SpawnLocation[] spawnLocations)
{
var spawnInfos = spawnLocations.Select(spawnLocation => new SpawnInfo(techTypeToSpawn, spawnLocation.Position, spawnLocation.EulerAngles)).ToList();
var spawnInfos = spawnLocations.Select(spawnLocation => new SpawnInfo(techTypeToSpawn, spawnLocation.Position, spawnLocation.EulerAngles, spawnLocation.Scale)).ToList();
RegisterCoordinatedSpawns(spawnInfos);
}
}
Expand Down

0 comments on commit f788ad9

Please sign in to comment.