Skip to content

Commit

Permalink
Merge branch 'master' into gunmelee
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaaankas authored Aug 28, 2024
2 parents 409bd06 + 419edd6 commit 4c247fe
Show file tree
Hide file tree
Showing 69 changed files with 1,599 additions and 260 deletions.
1 change: 0 additions & 1 deletion Content.Client/Buckle/BuckleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ private void OnAppearanceChange(EntityUid uid, BuckleComponent component, ref Ap
!buckled ||
args.Sprite == null)
{
_rotationVisualizerSystem.SetHorizontalAngle((uid, rotVisuals), rotVisuals.DefaultRotation);
return;
}

Expand Down
1 change: 1 addition & 0 deletions Content.Client/Input/ContentContexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public static void SetupContexts(IInputContextContainer contexts)
human.AddFunction(ContentKeyFunctions.Arcade1);
human.AddFunction(ContentKeyFunctions.Arcade2);
human.AddFunction(ContentKeyFunctions.Arcade3);
human.AddFunction(ContentKeyFunctions.LookUp); // WD EDIT

// actions should be common (for ghosts, mobs, etc)
common.AddFunction(ContentKeyFunctions.OpenActionsMenu);
Expand Down
16 changes: 16 additions & 0 deletions Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Numerics;
using Content.Client.Stylesheets;
using Content.Shared._White;
using Content.Shared.CCVar;
using Content.Shared.Input;
using Robust.Client.AutoGenerated;
Expand Down Expand Up @@ -97,12 +98,24 @@ private void HandleToggleWalk(BaseButton.ButtonToggledEventArgs args)
_deferCommands.Add(_inputManager.SaveToUserData);
}

private void HandleHoldLookUp(BaseButton.ButtonToggledEventArgs args) // WD EDIT
{
_cfg.SetCVar(WhiteCVars.HoldLookUp, args.Pressed);
_cfg.SaveToFile();
}

private void HandleStaticStorageUI(BaseButton.ButtonToggledEventArgs args)
{
_cfg.SetCVar(CCVars.StaticStorageUI, args.Pressed);
_cfg.SaveToFile();
}

private void HandleToggleAutoGetUp(BaseButton.ButtonToggledEventArgs args) // WD EDIT
{
_cfg.SetCVar(WhiteCVars.AutoGetUp, args.Pressed);
_cfg.SaveToFile();
}

public KeyRebindTab()
{
IoCManager.InjectDependencies(this);
Expand Down Expand Up @@ -186,6 +199,9 @@ void AddCheckBox(string checkBoxName, bool currentState, Action<BaseButton.Butto
AddButton(ContentKeyFunctions.OfferItem);
AddButton(ContentKeyFunctions.SaveItemLocation);
AddButton(ContentKeyFunctions.ToggleStanding);
AddButton(ContentKeyFunctions.LookUp); // WD EDIT
AddCheckBox("ui-options-function-auto-get-up", _cfg.GetCVar(WhiteCVars.AutoGetUp), HandleToggleAutoGetUp); // WD EDIT
AddCheckBox("ui-options-function-hold-look-up", _cfg.GetCVar(WhiteCVars.HoldLookUp), HandleHoldLookUp); // WD EDIT

AddHeader("ui-options-header-interaction-adv");
AddButton(ContentKeyFunctions.SmartEquipBackpack);
Expand Down
4 changes: 4 additions & 0 deletions Content.Client/Store/Ui/StoreMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ private void AddListingGui(ListingData listing)
}

var newListing = new StoreListingControl(listing, GetListingPriceString(listing), hasBalance, texture);

if (listing.DiscountValue > 0) // WD EDIT
newListing.StoreItemBuyButton.AddStyleClass("ButtonColorRed");

newListing.StoreItemBuyButton.OnButtonDown += args
=> OnListingButtonPressed?.Invoke(args, listing);

Expand Down
22 changes: 22 additions & 0 deletions Content.Client/Weapons/Melee/MeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using Content.Client.Gameplay;
using Content.Shared._White.Blink;
using Content.Shared.CCVar;
using Content.Shared.CombatMode;
using Content.Shared.Effects;
Expand Down Expand Up @@ -128,6 +129,27 @@ public override void Update(float frameTime)
RaisePredictiveEvent(new LightAttackEvent(GetNetEntity(target), GetNetEntity(weaponUid), GetNetCoordinates(coordinates)));
return;
}

// WD EDIT START
if (HasComp<BlinkComponent>(weaponUid))
{
if (!_xformQuery.TryGetComponent(entity, out var userXform) || !Timing.IsFirstTimePredicted)
{
return;
}

var targetMap = coordinates.ToMap(EntityManager, TransformSystem);

if (targetMap.MapId != userXform.MapID)
return;

var userPos = TransformSystem.GetWorldPosition(userXform);
var direction = targetMap.Position - userPos;

RaiseNetworkEvent(new BlinkEvent(GetNetEntity(weaponUid), direction));
return;
}
// WD EDIT END

// Otherwise do a wide swing
ClientHeavyAttack(entity, coordinates, weaponUid, weapon);
Expand Down
82 changes: 82 additions & 0 deletions Content.Client/_White/Standing/LayingDownSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using Content.Shared._White.Standing;
using Content.Shared.Buckle;
using Content.Shared.Rotation;
using Content.Shared.Standing;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Timing;

namespace Content.Client._White.Standing;

public sealed class LayingDownSystem : SharedLayingDownSystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly StandingStateSystem _standing = default!;
[Dependency] private readonly AnimationPlayerSystem _animation = default!;
[Dependency] private readonly SharedBuckleSystem _buckle = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<LayingDownComponent, MoveEvent>(OnMovementInput);

SubscribeNetworkEvent<CheckAutoGetUpEvent>(OnCheckAutoGetUp);
}

private void OnMovementInput(EntityUid uid, LayingDownComponent component, MoveEvent args)
{
if (!_timing.IsFirstTimePredicted)
return;

if (!_standing.IsDown(uid))
return;

if (_buckle.IsBuckled(uid))
return;

if (_animation.HasRunningAnimation(uid, "rotate"))
return;

if (!TryComp<TransformComponent>(uid, out var transform)
|| !TryComp<SpriteComponent>(uid, out var sprite)
|| !TryComp<RotationVisualsComponent>(uid, out var rotationVisuals))
{
return;
}

var rotation = transform.LocalRotation + (_eyeManager.CurrentEye.Rotation - (transform.LocalRotation - transform.WorldRotation));

if (rotation.GetDir() is Direction.SouthEast or Direction.East or Direction.NorthEast or Direction.North)
{
rotationVisuals.HorizontalRotation = Angle.FromDegrees(270);
sprite.Rotation = Angle.FromDegrees(270);
return;
}

rotationVisuals.HorizontalRotation = Angle.FromDegrees(90);
sprite.Rotation = Angle.FromDegrees(90);
}

private void OnCheckAutoGetUp(CheckAutoGetUpEvent ev, EntitySessionEventArgs args)
{
if (!_timing.IsFirstTimePredicted)
return;

var uid = GetEntity(ev.User);

if (!TryComp<TransformComponent>(uid, out var transform) || !TryComp<RotationVisualsComponent>(uid, out var rotationVisuals))
return;

var rotation = transform.LocalRotation + (_eyeManager.CurrentEye.Rotation - (transform.LocalRotation - transform.WorldRotation));

if (rotation.GetDir() is Direction.SouthEast or Direction.East or Direction.NorthEast or Direction.North)
{
rotationVisuals.HorizontalRotation = Angle.FromDegrees(270);
return;
}

rotationVisuals.HorizontalRotation = Angle.FromDegrees(90);
}
}
126 changes: 126 additions & 0 deletions Content.Client/_White/Telescope/TelescopeSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
using System.Numerics;
using Content.Client.Viewport;
using Content.Shared._White;
using Content.Shared._White.Telescope;
using Content.Shared.Input;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Shared.Configuration;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared.Timing;

namespace Content.Client._White.Telescope;

public sealed class TelescopeSystem : SharedTelescopeSystem
{
[Dependency] private readonly InputSystem _inputSystem = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IInputManager _input = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;

private ScalingViewport? _viewport;
private bool _holdLookUp;
private bool _toggled;

public override void Initialize()
{
base.Initialize();

_cfg.OnValueChanged(WhiteCVars.HoldLookUp,
val =>
{
var input = val ? null : InputCmdHandler.FromDelegate(_ => _toggled = !_toggled);
_input.SetInputCommand(ContentKeyFunctions.LookUp, input);
_holdLookUp = val;
_toggled = false;
},
true);
}

public override void FrameUpdate(float frameTime)
{
base.FrameUpdate(frameTime);

if (_timing.ApplyingState || !_timing.IsFirstTimePredicted || !_input.MouseScreenPosition.IsValid)
return;

var player = _player.LocalEntity;

var telescope = GetRightTelescope(player);

if (telescope == null)
{
_toggled = false;
return;
}

if (!TryComp<EyeComponent>(player, out var eye))
return;

var offset = Vector2.Zero;

if (_holdLookUp)
{
if (_inputSystem.CmdStates.GetState(ContentKeyFunctions.LookUp) != BoundKeyState.Down)
{
RaiseEvent(offset);
return;
}
}
else if (!_toggled)
{
RaiseEvent(offset);
return;
}

var mousePos = _input.MouseScreenPosition;

if (_uiManager.MouseGetControl(mousePos) as ScalingViewport is { } viewport)
_viewport = viewport;

if (_viewport == null)
return;

var centerPos = _eyeManager.WorldToScreen(eye.Eye.Position.Position + eye.Offset);

var diff = mousePos.Position - centerPos;
var len = diff.Length();

var size = _viewport.PixelSize;

var maxLength = Math.Min(size.X, size.Y) * 0.4f;
var minLength = maxLength * 0.2f;

if (len > maxLength)
{
diff *= maxLength / len;
len = maxLength;
}

var divisor = maxLength * telescope.Divisor;

if (len > minLength)
{
diff -= diff * minLength / len;
offset = new Vector2(diff.X / divisor, -diff.Y / divisor);
offset = new Angle(-eye.Rotation.Theta).RotateVec(offset);
}

RaiseEvent(offset);
}

private void RaiseEvent(Vector2 offset)
{
RaisePredictiveEvent(new EyeOffsetChangedEvent
{
Offset = offset
});
}
}
28 changes: 28 additions & 0 deletions Content.IntegrationTests/Pair/TestPair.Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.Preferences.Managers;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
Expand Down Expand Up @@ -128,4 +131,29 @@ public List<EntityPrototype> GetPrototypesWithComponent<T>(

return list;
}

/// <summary>
/// Helper method for enabling or disabling a antag role
/// </summary>
public async Task SetAntagPref(ProtoId<AntagPrototype> id, bool value)
{
var prefMan = Server.ResolveDependency<IServerPreferencesManager>();

var prefs = prefMan.GetPreferences(Client.User!.Value);
// what even is the point of ICharacterProfile if we always cast it to HumanoidCharacterProfile to make it usable?
var profile = (HumanoidCharacterProfile) prefs.SelectedCharacter;

Assert.That(profile.AntagPreferences.Any(preference => preference == id), Is.EqualTo(!value));
var newProfile = profile.WithAntagPreference(id, value);

await Server.WaitPost(() =>
{
prefMan.SetProfile(Client.User.Value, prefs.SelectedCharacterIndex, newProfile).Wait();
});

// And why the fuck does it always create a new preference and profile object instead of just reusing them?
var newPrefs = prefMan.GetPreferences(Client.User.Value);
var newProf = (HumanoidCharacterProfile) newPrefs.SelectedCharacter;
Assert.That(newProf.AntagPreferences.Any(preference => preference == id), Is.EqualTo(value));
}
}
4 changes: 2 additions & 2 deletions Content.IntegrationTests/PoolManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ public static partial class PoolManager

options.BeforeStart += () =>
{
// Server-only systems (i.e., systems that subscribe to events with server-only components)
var entSysMan = IoCManager.Resolve<IEntitySystemManager>();
entSysMan.LoadExtraSystemType<ResettingEntitySystemTests.TestRoundRestartCleanupEvent>();
entSysMan.LoadExtraSystemType<InteractionSystemTests.TestInteractionSystem>();
entSysMan.LoadExtraSystemType<DeviceNetworkTestSystem>();
entSysMan.LoadExtraSystemType<TestDestructibleListenerSystem>();
IoCManager.Resolve<ILogManager>().GetSawmill("loc").Level = LogLevel.Error;
IoCManager.Resolve<IConfigurationManager>()
.OnValueChanged(RTCVars.FailureLogLevel, value => logHandler.FailureLevel = value, true);
Expand Down
Loading

0 comments on commit 4c247fe

Please sign in to comment.