Merge remote-tracking branch 'upstream/stable' into ed-25-08-2025-upstream-sync

# Conflicts:
#	.github/CODEOWNERS
#	Content.Client/UserInterface/Systems/Actions/Controls/ActionButton.cs
#	Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs
#	Content.Server/Chat/Systems/ChatSystem.cs
#	Content.Server/Explosion/EntitySystems/TriggerSystem.cs
#	Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs
#	Content.Shared/Lock/LockSystem.cs
#	Content.Shared/Nutrition/Components/FoodComponent.cs
#	Content.Shared/Speech/ListenEvent.cs
#	Resources/Prototypes/Entities/Effects/admin_triggers.yml
This commit is contained in:
Ed
2025-08-25 16:22:32 +03:00
1069 changed files with 42396 additions and 29527 deletions

View File

@@ -0,0 +1,27 @@
using System.Numerics;
using Robust.Shared.GameStates;
namespace Content.Shared.Sprite;
/// <summary>
/// Used to set the <see cref="Robust.Client.GameObjects.SpriteComponent.Scale"/> datafield to a certain value from the server.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(SharedScaleVisualsSystem))]
public sealed partial class ScaleVisualsComponent : Component
{
/// <summary>
/// The current sprite scale.
/// </summary>
[DataField, AutoNetworkedField]
[ViewVariables]
public Vector2 Scale = Vector2.One;
/// <summary>
/// The original sprite scale, which we revert to if this component is removed.
/// Only set on the client.
/// </summary>
[DataField]
[ViewVariables]
public Vector2? OriginalScale;
}

View File

@@ -0,0 +1,78 @@
using System.Numerics;
using Robust.Shared.Serialization;
namespace Content.Shared.Sprite;
public abstract class SharedScaleVisualsSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ScaleVisualsComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<ScaleVisualsComponent, ComponentShutdown>(OnComponentShutdown);
}
private void OnMapInit(Entity<ScaleVisualsComponent> ent, ref MapInitEvent args)
{
SetSpriteScale(ent.Owner, ent.Comp.Scale);
}
private void OnComponentShutdown(Entity<ScaleVisualsComponent> ent, ref ComponentShutdown args)
{
ResetScale(ent);
}
protected virtual void ResetScale(Entity<ScaleVisualsComponent> ent)
{
_appearance.RemoveData(ent.Owner, ScaleVisuals.Scale);
var ev = new ScaleEntityEvent(ent.Owner, Vector2.One);
RaiseLocalEvent(ent.Owner, ref ev);
}
/// <summary>
/// Used to set the <see cref="Robust.Client.GameObjects.SpriteComponent.Scale"/> datafield to a certain value from the server.
/// </summary>
public void SetSpriteScale(EntityUid uid, Vector2 scale)
{
var comp = EnsureComp<ScaleVisualsComponent>(uid);
comp.Scale = scale;
Dirty(uid, comp);
var appearanceComponent = EnsureComp<AppearanceComponent>(uid);
_appearance.SetData(uid, ScaleVisuals.Scale, scale, appearanceComponent);
// Raise an event for content use.
var ev = new ScaleEntityEvent(uid, scale);
RaiseLocalEvent(uid, ref ev);
}
/// <summary>
/// Gets the current scale set by <see cref="SetSpriteScale"/>.
/// This does not include any direct changes made to the SpriteComponent.
/// </summary>
public Vector2 GetSpriteScale(EntityUid uid)
{
if (!TryComp<AppearanceComponent>(uid, out var appearanceComponent))
return Vector2.One;
if (!_appearance.TryGetData<Vector2>(uid, ScaleVisuals.Scale, out var scale, appearanceComponent))
scale = Vector2.One;
return scale;
}
}
/// <summary>
/// Raised when a sprite scale is changed.
/// </summary>
[ByRefEvent]
public readonly record struct ScaleEntityEvent(EntityUid Uid, Vector2 Scale);
[Serializable, NetSerializable]
public enum ScaleVisuals : byte
{
Scale,
}