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
31 changes: 26 additions & 5 deletions EXILED/Exiled.API/Features/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Exiled.API.Features
/// <summary>
/// Wrapper class for <see cref="Scp079Generator"/>.
/// </summary>
public class Generator : IWrapper<Scp079Generator>, IWorldSpace
public class Generator : IWrapper<Scp079Generator>, IWorldSpace, IStructureSync
{
/// <summary>
/// A <see cref="List{T}"/> of <see cref="Generator"/> on the map.
Expand All @@ -36,6 +36,7 @@ public class Generator : IWrapper<Scp079Generator>, IWorldSpace
internal Generator(Scp079Generator scp079Generator)
{
Base = scp079Generator;
PositionSync = scp079Generator.GetComponent<StructurePositionSync>();
Scp079GeneratorToGenerator.Add(scp079Generator, this);
}

Expand Down Expand Up @@ -201,14 +202,34 @@ public Player LastActivator
}

/// <summary>
/// Gets the generator position.
/// Gets or sets the position of the generator.
/// </summary>
public Vector3 Position => Base.transform.position;
public Vector3 Position
{
get => Base.transform.position;
set
{
Base.transform.position = value;
PositionSync.Network_position = value;
}
}

/// <summary>
/// Gets the generator rotation.
/// Gets or sets the rotation of the generator.
/// </summary>
public Quaternion Rotation => Base.transform.rotation;
/// <remarks>The setter only works in the y-axis (left to right) due to base game limitations.</remarks>
public Quaternion Rotation
{
get => Base.transform.rotation;
set
{
Base.transform.rotation = Quaternion.Euler(0, value.eulerAngles.y, 0);
PositionSync.Network_rotationY = (sbyte)Mathf.RoundToInt(value.eulerAngles.y / 5.625F);
}
}

/// <inheritdoc cref="IStructureSync.PositionSync"/>
public StructurePositionSync PositionSync { get; }

/// <summary>
/// Gets or sets the required permissions to interact with the generator.
Expand Down
35 changes: 30 additions & 5 deletions EXILED/Exiled.API/Features/Lockers/Locker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Exiled.API.Features.Lockers
/// <summary>
/// The in-game Locker.
/// </summary>
public class Locker : IWrapper<BaseLocker>, IWorldSpace
public class Locker : IWrapper<BaseLocker>, IWorldSpace, IStructureSync
{
/// <summary>
/// A <see cref="Dictionary{TKey,TValue}"/> containing all known <see cref="BaseLocker"/>s and their corresponding <see cref="Locker"/>.
Expand All @@ -41,6 +41,7 @@ public class Locker : IWrapper<BaseLocker>, IWorldSpace
public Locker(BaseLocker locker)
{
Base = locker;
PositionSync = locker.GetComponent<StructurePositionSync>();
BaseToExiledLockers.Add(locker, this);

Chambers = locker.Chambers.Select(x => new Chamber(x, this)).ToList();
Expand Down Expand Up @@ -72,11 +73,35 @@ public Locker(BaseLocker locker)
/// </summary>
public Transform Transform => Base.transform;

/// <inheritdoc/>
public Vector3 Position => Base.transform.position;
/// <summary>
/// Gets or sets the position of the locker.
/// </summary>
public Vector3 Position
{
get => Base.transform.position;
set
{
Base.transform.position = value;
PositionSync.Network_position = value;
}
}

/// <inheritdoc/>
public Quaternion Rotation => Base.transform.rotation;
/// <summary>
/// Gets or sets the rotation of the locker.
/// </summary>
/// <remarks>The setter only works in the y-axis (left to right) due to base game limitations.</remarks>
public Quaternion Rotation
{
get => Base.transform.rotation;
set
{
Base.transform.rotation = Quaternion.Euler(0, value.eulerAngles.y, 0);
PositionSync.Network_rotationY = (sbyte)Mathf.RoundToInt(value.eulerAngles.y / 5.625F);
}
}

/// <inheritdoc cref="IStructureSync.PositionSync"/>
public StructurePositionSync PositionSync { get; }

/// <summary>
/// Gets the <see cref="Features.Room"/> in which the <see cref="Locker"/> is located.
Expand Down
24 changes: 14 additions & 10 deletions EXILED/Exiled.API/Features/Workstation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ namespace Exiled.API.Features
using Exiled.API.Enums;
using Exiled.API.Interfaces;
using InventorySystem.Items.Firearms.Attachments;
using MapGeneration.Distributors;
using Mirror;
using UnityEngine;

/// <summary>
/// A wrapper class for <see cref="WorkstationController"/>.
/// </summary>
public class Workstation : IWrapper<WorkstationController>, IWorldSpace
public class Workstation : IWrapper<WorkstationController>, IWorldSpace, IStructureSync
{
/// <summary>
/// A dictionary mapping <see cref="WorkstationController"/> to <see cref="Workstation"/>.
Expand All @@ -36,6 +37,7 @@ internal Workstation(WorkstationController workstationController)
{
WorkstationControllerToWorkstation.Add(workstationController, this);
Base = workstationController;
PositionSync = workstationController.GetComponent<StructurePositionSync>();
}

/// <summary>
Expand Down Expand Up @@ -73,29 +75,31 @@ internal Workstation(WorkstationController workstationController)
/// </summary>
public Vector3 Position
{
get => Transform.position;
get => Base.transform.position;
set
{
NetworkServer.UnSpawn(GameObject);
Transform.position = value;
NetworkServer.Spawn(GameObject);
Base.transform.position = value;
PositionSync.Network_position = value;
}
}

/// <summary>
/// Gets or sets the rotation of the workstation.
/// Gets or sets the position of the workstation.
/// </summary>
/// <remarks>The setter only works in the y-axis (left to right) due to base game limitations.</remarks>
public Quaternion Rotation
{
get => Transform.rotation;
get => Base.transform.rotation;
set
{
NetworkServer.UnSpawn(GameObject);
Transform.rotation = value;
NetworkServer.Spawn(GameObject);
Base.transform.rotation = Quaternion.Euler(0, value.eulerAngles.y, 0);
PositionSync.Network_rotationY = (sbyte)Mathf.RoundToInt(value.eulerAngles.y / 5.625F);
}
}

/// <inheritdoc cref="IStructureSync.PositionSync"/>
public StructurePositionSync PositionSync { get; }

/// <summary>
/// Gets or sets the status of the workstation.
/// </summary>
Expand Down
22 changes: 22 additions & 0 deletions EXILED/Exiled.API/Interfaces/IStructureSync.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// -----------------------------------------------------------------------
// <copyright file="IStructureSync.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.API.Interfaces
{
using MapGeneration.Distributors;

/// <summary>
/// Represents an object with a <see cref="StructurePositionSync"/>.
/// </summary>
public interface IStructureSync
{
/// <summary>
/// Gets the <see cref="StructurePositionSync"/> of this structure.
/// </summary>
public StructurePositionSync PositionSync { get; }
}
}
Loading