Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into upstream
Browse files Browse the repository at this point in the history
# Conflicts:
#	Resources/Changelog/Changelog.yml
  • Loading branch information
Remuchi committed Sep 5, 2024
2 parents 612abe2 + f815317 commit 8e9ecf7
Show file tree
Hide file tree
Showing 1,530 changed files with 11,846 additions and 575 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<ui:RadialMenu xmlns="https://spacestation14.io"
xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls"
BackButtonStyleClass="RadialMenuBackButton"
CloseButtonStyleClass="RadialMenuCloseButton"
VerticalExpand="True"
HorizontalExpand="True"
MinSize="350 350">

<!-- Main container to hold all crafts-->
<ui:RadialContainer Name="Main" VerticalExpand="True" HorizontalExpand="True" Radius="100"
ReserveSpaceForHiddenChildren="False" />
</ui:RadialMenu>
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System.Numerics;
using Content.Client.Construction;
using Content.Client.UserInterface.Controls;
using Content.Shared._White.ShortConstruction;
using Content.Shared.Construction.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Placement;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;

namespace Content.Client._White.ShortConstruction.UI;

[GenerateTypedNameReferences]
public sealed partial class ShortConstructionMenu : RadialMenu
{
[Dependency] private readonly EntityManager _entManager = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly IPlacementManager _placementManager = default!;

private readonly ConstructionSystem _construction;

public ShortConstructionMenu(EntityUid owner)
{
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
_construction = _entManager.System<ConstructionSystem>();

if (!_entManager.TryGetComponent<ShortConstructionComponent>(owner, out var crafting))
return;

var spriteSystem = _entManager.System<SpriteSystem>();
var main = FindControl<RadialContainer>("Main");

foreach (var protoId in crafting.Prototypes)
{
if (!_protoManager.TryIndex(protoId, out var proto))
continue;

var button = new RadialMenuTextureButton
{
ToolTip = Loc.GetString(proto.Name),
StyleClasses = { "RadialMenuButton" },
SetSize = new Vector2(48f, 48f),
};

var texture = new TextureRect
{
VerticalAlignment = VAlignment.Center,
HorizontalAlignment = HAlignment.Center,
Texture = spriteSystem.Frame0(proto.Icon),
TextureScale = new Vector2(1.5f, 1.5f),
};

button.AddChild(texture);

button.OnButtonUp += _ =>
{
if (ConstructItem(proto))
Close();
};

main.AddChild(button);
}
}

/// <summary>
/// Makes an item or places a schematic based on the type of construction recipe.
/// </summary>
/// <returns>Whatever the menu should be closed or not. By default crafting items does not close the window</returns>
private bool ConstructItem(ConstructionPrototype prototype)
{
if (prototype.Type == ConstructionType.Item)
{
_construction.TryStartItemConstruction(prototype.ID);
return false;
}

_placementManager.BeginPlacing(new PlacementInformation
{
IsTile = false,
PlacementOption = prototype.PlacementMode
}, new ConstructionPlacementHijack(_construction, prototype));
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using JetBrains.Annotations;
using Robust.Client.Graphics;
using Robust.Client.Input;

// ReSharper disable InconsistentNaming

namespace Content.Client._White.ShortConstruction.UI;

[UsedImplicitly]
public sealed class ShortConstructionMenuBUI(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey)
{
[Dependency] private readonly IClyde _displayManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
private ShortConstructionMenu? _menu;

protected override void Open()
{
_menu = new ShortConstructionMenu(Owner);
_menu.OnClose += Close;

var vpSize = _displayManager.ScreenSize;
_menu.OpenCenteredAt(_inputManager.MouseScreenPosition.Position / vpSize);
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;

_menu?.Dispose();
}
}
12 changes: 7 additions & 5 deletions Content.Server/Administration/Commands/AdminWhoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Content.Server.Administration.Commands;

[AdminCommand(AdminFlags.Admin)]
[AnyCommand] // WD EDIT
public sealed class AdminWhoCommand : IConsoleCommand
{
public string Command => "adminwho";
Expand All @@ -33,15 +33,17 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
var first = true;
foreach (var admin in adminMgr.ActiveAdmins)
{
if (!first)
sb.Append('\n');
first = false;

// WD EDIT START
var adminData = adminMgr.GetAdminData(admin)!;
DebugTools.AssertNotNull(adminData);

if (adminData.Stealth && !seeStealth)
continue;
// WD EDIT END

if (!first)
sb.Append('\n');
first = false;

sb.Append(admin.Name);
if (adminData.Title is { } title)
Expand Down
11 changes: 7 additions & 4 deletions Content.Shared/Storage/Components/MagnetPickupComponent.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
using Content.Shared.Inventory;
using Robust.Shared.GameStates;

namespace Content.Server.Storage.Components;

/// <summary>
/// Applies an ongoing pickup area around the attached entity.
/// </summary>
[RegisterComponent, AutoGenerateComponentPause]
[NetworkedComponent]
[RegisterComponent, AutoGenerateComponentPause, AutoGenerateComponentState]
public sealed partial class MagnetPickupComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("nextScan")]
[AutoPausedField]
public TimeSpan NextScan = TimeSpan.Zero;

/// <summary>
/// What container slot the magnet needs to be in to work.
/// If true, ignores SlotFlags and can magnet pickup on hands/ground.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("slotFlags")]
public SlotFlags SlotFlags = SlotFlags.BELT;
[ViewVariables(VVAccess.ReadWrite), DataField]
[AutoNetworkedField]
public bool ForcePickup = true;

[ViewVariables(VVAccess.ReadWrite), DataField("range")]
public float Range = 1f;
Expand Down
45 changes: 36 additions & 9 deletions Content.Shared/Storage/EntitySystems/MagnetPickupSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using Content.Server.Storage.Components;
using Content.Shared.Examine;
using Content.Shared.Inventory;
using Content.Shared.Item;
using Content.Shared.Item.ItemToggle;
using Content.Shared.Item.ItemToggle.Components;
using Robust.Shared.Map;
using Robust.Shared.Physics.Components;
using Robust.Shared.Timing;
Expand All @@ -16,6 +20,8 @@ public sealed class MagnetPickupSystem : EntitySystem
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedStorageSystem _storage = default!;
[Dependency] private readonly SharedItemToggleSystem _itemToggle = default!; // WD EDIT
[Dependency] private readonly SharedItemSystem _item = default!; // White Dream

private static readonly TimeSpan ScanDelay = TimeSpan.FromSeconds(1);

Expand All @@ -25,6 +31,8 @@ public override void Initialize()
{
base.Initialize();
_physicsQuery = GetEntityQuery<PhysicsComponent>();
SubscribeLocalEvent<MagnetPickupComponent, ItemToggledEvent>(OnItemToggled); // White Dream
SubscribeLocalEvent<MagnetPickupComponent, ExaminedEvent>(OnExamined); // WD EDIT
SubscribeLocalEvent<MagnetPickupComponent, MapInitEvent>(OnMagnetMapInit);
}

Expand All @@ -33,6 +41,21 @@ private void OnMagnetMapInit(EntityUid uid, MagnetPickupComponent component, Map
component.NextScan = _timing.CurTime;
}

//WD EDIT start
private void OnExamined(Entity<MagnetPickupComponent> entity, ref ExaminedEvent args)
{
var onMsg = _itemToggle.IsActivated(entity.Owner)
? Loc.GetString("comp-magnet-pickup-examined-on")
: Loc.GetString("comp-magnet-pickup-examined-off");
args.PushMarkup(onMsg);
}

private void OnItemToggled(Entity<MagnetPickupComponent> entity, ref ItemToggledEvent args)
{
_item.SetHeldPrefix(entity.Owner, args.Activated ? "on" : "off");
}
//WD EDIT end

public override void Update(float frameTime)
{
base.Update(frameTime);
Expand All @@ -41,16 +64,23 @@ public override void Update(float frameTime)

while (query.MoveNext(out var uid, out var comp, out var storage, out var xform, out var meta))
{
if (comp.NextScan > currentTime)
// WD EDIT START
if (!TryComp<ItemToggleComponent>(uid, out var toggle))
continue;

comp.NextScan += ScanDelay;
if (!_itemToggle.IsActivated(uid, toggle))
continue;
// WD EDIT END

if (!_inventory.TryGetContainingSlot((uid, xform, meta), out var slotDef))
if (comp.NextScan > currentTime)
continue;

if ((slotDef.SlotFlags & comp.SlotFlags) == 0x0)
comp.NextScan += ScanDelay;

// WD EDIT START. Added ForcePickup.
if (!comp.ForcePickup && !_inventory.TryGetContainingSlot((uid, xform, meta), out _))
continue;
//WD EDIT END.

// No space
if (!_storage.HasSpace((uid, storage)))
Expand All @@ -77,17 +107,14 @@ public override void Update(float frameTime)
// the problem is that stack pickups delete the original entity, which is fine, but due to
// game state handling we can't show a lerp animation for it.
var nearXform = Transform(near);
var nearMap = nearXform.MapPosition;
var nearMap = _transform.GetMapCoordinates(near);
var nearCoords = EntityCoordinates.FromMap(moverCoords.EntityId, nearMap, _transform, EntityManager);

if (!_storage.Insert(uid, near, out var stacked, storageComp: storage, playSound: !playedSound))
continue;

// Play pickup animation for either the stack entity or the original entity.
if (stacked != null)
_storage.PlayPickupAnimation(stacked.Value, nearCoords, finalCoords, nearXform.LocalRotation);
else
_storage.PlayPickupAnimation(near, nearCoords, finalCoords, nearXform.LocalRotation);
_storage.PlayPickupAnimation(stacked ?? near, nearCoords, finalCoords, nearXform.LocalRotation);

playedSound = true;
}
Expand Down
2 changes: 2 additions & 0 deletions Content.Shared/Throwing/ThrownItemComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,7 @@ public sealed partial class ThrownItemComponent : Component
/// </summary>
[DataField]
public Vector2? OriginalScale = null;

public readonly List<EntityUid> Processed = new(); // WD EDIT
}
}
11 changes: 9 additions & 2 deletions Content.Shared/Throwing/ThrownItemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ private void HandleCollision(EntityUid uid, ThrownItemComponent component, ref S
if (args.OtherEntity == component.Thrower)
return;

// WD EDIT START
if (component.Processed.Contains(args.OtherEntity))
return;
// WD EDIT END

ThrowCollideInteraction(component, args.OurEntity, args.OtherEntity);
component.Processed.Add(args.OtherEntity); // WD EDIT
}

private void PreventCollision(EntityUid uid, ThrownItemComponent component, ref PreventCollideEvent args)
Expand Down Expand Up @@ -110,6 +116,7 @@ public void StopThrow(EntityUid uid, ThrownItemComponent thrownItemComponent)

EntityManager.EventBus.RaiseLocalEvent(uid, new StopThrowEvent { User = thrownItemComponent.Thrower }, true);
EntityManager.RemoveComponent<ThrownItemComponent>(uid);
thrownItemComponent.Processed.Clear(); // WD EDIT
}

public void LandComponent(EntityUid uid, ThrownItemComponent thrownItem, PhysicsComponent physics, bool playSound)
Expand Down Expand Up @@ -137,10 +144,10 @@ public void ThrowCollideInteraction(ThrownItemComponent component, EntityUid thr
_adminLogger.Add(LogType.ThrowHit, LogImpact.Low,
$"{ToPrettyString(thrown):thrown} thrown by {ToPrettyString(component.Thrower.Value):thrower} hit {ToPrettyString(target):target}.");

if (component.Thrower is not null)// Nyano - Summary: Gotta check if there was a thrower.
if (component.Thrower is not null)// Nyano - Summary: Gotta check if there was a thrower.
RaiseLocalEvent(target, new ThrowHitByEvent(component.Thrower.Value, thrown, target, component), true); // Nyano - Summary: Gotta update for who threw it.
else
RaiseLocalEvent(target, new ThrowHitByEvent(null, thrown, target, component), true); // Nyano - Summary: No thrower.
RaiseLocalEvent(target, new ThrowHitByEvent(null, thrown, target, component), true); // Nyano - Summary: No thrower.
RaiseLocalEvent(thrown, new ThrowDoHitEvent(thrown, target, component), true);
}

Expand Down
9 changes: 7 additions & 2 deletions Content.Shared/Weapons/Melee/MeleeWeaponComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public sealed partial class MeleeWeaponComponent : Component
/// Weapon damage is multiplied by this amount for heavy swings
/// </summary>
[DataField, AutoNetworkedField]
public float HeavyDamageBaseModifier = 1.2f;
public float HeavyDamageBaseModifier = 1f; // WD EDIT

/// <summary>
/// Total width of the angle for wide attacks.
Expand All @@ -117,6 +117,11 @@ public sealed partial class MeleeWeaponComponent : Component
[DataField, AutoNetworkedField]
public EntProtoId WideAnimation = "WeaponArcSlash";

// WD EDIT START
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
public EntProtoId DisarmAnimation = "WeaponArcDisarm";
// WD EDIT END

/// <summary>
/// Rotation of the animation.
/// 0 degrees means the top faces the attacker.
Expand All @@ -128,7 +133,7 @@ public sealed partial class MeleeWeaponComponent : Component
public bool SwingLeft;

[DataField, AutoNetworkedField]
public float HeavyStaminaCost = 20f;
public float HeavyStaminaCost = 20f; // WD EDIT

[DataField, AutoNetworkedField]
public int MaxTargets = 5;
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ private bool AttemptAttack(EntityUid user, EntityUid weaponUid, MeleeWeaponCompo
if (!DoDisarm(user, disarm, weaponUid, weapon, session))
return false;

animation = weapon.Animation;
animation = weapon.DisarmAnimation; // WD EDIT
break;
case HeavyAttackEvent heavy:
if (!DoHeavyAttack(user, heavy, weaponUid, weapon, session))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Content.Shared.Construction.Prototypes;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;

namespace Content.Shared._White.ShortConstruction;

[RegisterComponent, NetworkedComponent]
public sealed partial class ShortConstructionComponent : Component
{
[DataField(required: true)]
public List<ProtoId<ConstructionPrototype>> Prototypes = new();
}

[NetSerializable, Serializable]
public enum ShortConstructionUiKey : byte
{
Key,
}
Loading

0 comments on commit 8e9ecf7

Please sign in to comment.