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
46 changes: 16 additions & 30 deletions EXILED/Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ public ScpSpawnPreferences.SpawnPreferences ScpPreferences
public Vector3 Scale
{
get => ReferenceHub.transform.localScale;
set => SetScale(value, List);
set => SetScale(value);
}

/// <summary>
Expand Down Expand Up @@ -2065,27 +2065,25 @@ public void Disconnect(string reason = null) =>
/// </summary>
public void ResetStamina() => Stamina = StaminaStat.MaxValue;

/// <summary>
/// Sets the scale of a player on the server side.
/// </summary>
/// <param name="scale">The scale to set.</param>
public void SetScale(Vector3 scale)
{
ReferenceHub.transform.localScale = scale;
new SyncedScaleMessages.ScaleMessage(scale, ReferenceHub).SendToAuthenticated();
}

/// <summary>
/// Sets the scale of a player on the server side.
/// </summary>
/// <param name="scale">The scale to set.</param>
/// <param name="viewers">Who should see the updated scale.</param>
public void SetScale(Vector3 scale, IEnumerable<Player> viewers)
{
if (scale == Scale)
return;

try
{
ReferenceHub.transform.localScale = scale;

foreach (Player target in viewers)
Server.SendSpawnMessage?.Invoke(null, new object[] { NetworkIdentity, target.Connection });
}
catch (Exception exception)
{
Log.Error($"{nameof(SetScale)} error: {exception}");
}
ReferenceHub.transform.localScale = scale;
new SyncedScaleMessages.ScaleMessage(scale, ReferenceHub).SendToHubsConditionally(x => x != null && viewers.Contains(Get(x)));
}

/// <summary>
Expand All @@ -2095,21 +2093,9 @@ public void SetScale(Vector3 scale, IEnumerable<Player> viewers)
/// <param name="viewers">Who should see the fake scale.</param>
public void SetFakeScale(Vector3 fakeScale, IEnumerable<Player> viewers)
{
Vector3 currentScale = Scale;

try
{
ReferenceHub.transform.localScale = fakeScale;

foreach (Player target in viewers)
Server.SendSpawnMessage.Invoke(null, new object[] { NetworkIdentity, target.Connection });

ReferenceHub.transform.localScale = currentScale;
}
catch (Exception ex)
{
Log.Error($"{nameof(SetFakeScale)}: {ex}");
}
SyncedScaleMessages.ScaleMessage scaleMessage = new(fakeScale, ReferenceHub);
foreach (Player player in viewers)
player.Connection.Send(scaleMessage, 0);
}

/// <summary>
Expand Down
9 changes: 9 additions & 0 deletions EXILED/Exiled.API/Features/Roles/FpcRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ public Vector3 Gravity
set => FirstPersonController.FpcModule.Motor.GravityController.Gravity = value;
}

/// <summary>
/// Gets or sets the player's scale.
/// </summary>
public Vector3 Scale
{
get => FirstPersonController.FpcModule.Motor.ScaleController.Scale;
set => FirstPersonController.FpcModule.Motor.ScaleController.Scale = value;
}

/// <summary>
/// Gets or sets a value indicating whether if the player should get <see cref="Enums.DamageType.Falldown"/> damage.
/// </summary>
Expand Down
3 changes: 1 addition & 2 deletions EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ public virtual void AddRole(Player player)
Log.Debug($"{Name}: Setting health values.");
player.Health = MaxHealth;
player.MaxHealth = MaxHealth;
player.Scale = Scale;
Timing.CallDelayed(0.1f, () => player.Scale = Scale); // To fix : remove the delay in 14.1.2 once the crash issue is resolved
if (Gravity.HasValue && player.Role is FpcRole fpcRole)
fpcRole.Gravity = Gravity.Value;
Vector3 position = GetSpawnPosition();
Expand Down Expand Up @@ -627,7 +627,6 @@ public virtual void RemoveRole(Player player)
TrackedPlayers.Remove(player);
player.CustomInfo = string.Empty;
player.InfoArea |= PlayerInfoArea.Role | PlayerInfoArea.Nickname;
player.Scale = Vector3.one;
if (CustomAbilities is not null)
{
foreach (CustomAbility ability in CustomAbilities)
Expand Down
9 changes: 6 additions & 3 deletions EXILED/Exiled.Events/Handlers/Internal/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ namespace Exiled.Events.Handlers.Internal
using InventorySystem.Items.Usables;
using InventorySystem.Items.Usables.Scp244.Hypothermia;
using PlayerRoles;
using PlayerRoles.FirstPersonControl;
using PlayerRoles.RoleAssign;
using UnityEngine;
using Utils.Networking;
using Utils.NonAllocLINQ;

/// <summary>
Expand Down Expand Up @@ -114,10 +117,10 @@ public static void OnVerified(VerifiedEventArgs ev)
ev.Player.SendFakeSyncVar(room.RoomLightControllerNetIdentity, typeof(RoomLightController), nameof(RoomLightController.NetworkLightsEnabled), false);
}

// TODO: Remove if this has been fixed for https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/947
if (ev.Player.TryGetEffect(out Hypothermia hypothermia))
// Fix bug that player that Join do not receive information about other players Scale
foreach (Player player in ReferenceHub.AllHubs.Select(Player.Get))
{
hypothermia.SubEffects = hypothermia.SubEffects.Where(x => x.GetType() != typeof(PostProcessSubEffect)).ToArray();
player.SetFakeScale(player.Scale, new List<Player>() { ev.Player });
}
}

Expand Down