forked from Simple-Station/Einstein-Engines
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Simple-Station#21 from gluesniffler/SHITMED
Mocho Shitmed Release 1
- Loading branch information
Showing
28 changed files
with
487 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
Content.Client/UserInterface/Systems/Targeting/TargetingUIController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Content.Client.UserInterface.Systems.Gameplay; | ||
using Content.Client.UserInterface.Systems.Targeting.Widgets; | ||
using Content.Shared.Targeting; | ||
using Content.Shared.Targeting.Events; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.UserInterface.Controllers; | ||
using Robust.Shared.Utility; | ||
using Robust.Client.Player; | ||
|
||
namespace Content.Client.UserInterface.Systems.Targeting; | ||
|
||
public sealed class TargetingUIController : UIController | ||
{ | ||
[Dependency] private readonly IEntityManager _entManager = default!; | ||
[Dependency] private readonly IEntityNetworkManager _net = default!; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
|
||
private SpriteSystem _spriteSystem = default!; | ||
private TargetBodyPart _currentTarget = TargetBodyPart.Torso; // Default to torso | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
var gameplayStateLoad = UIManager.GetUIController<GameplayStateLoadController>(); | ||
gameplayStateLoad.OnScreenLoad += OnScreenLoad; | ||
} | ||
|
||
private void OnScreenLoad() | ||
{ | ||
_spriteSystem = _entManager.System<SpriteSystem>(); | ||
} | ||
|
||
public void CycleTarget(TargetingControl control) | ||
{ | ||
if (_playerManager.LocalEntity is not { } user) | ||
return; | ||
|
||
var player = _entManager.GetNetEntity(user); | ||
_currentTarget = (TargetBodyPart) (((int) _currentTarget + 1) % Enum.GetValues(typeof(TargetBodyPart)).Length); | ||
var msg = new TargetChangeEvent(player, _currentTarget); | ||
_net.SendSystemNetworkMessage(msg); | ||
UpdateVisuals(control); | ||
} | ||
|
||
public void UpdateVisuals(TargetingControl control) | ||
{ | ||
var stateName = $"doll-{_currentTarget.ToString().ToLowerInvariant()}"; | ||
var spriteSpecifier = new SpriteSpecifier.Rsi(new ResPath("/Textures/Interface/Targeting/bodydoll.rsi"), stateName); | ||
control.SetTargetImage(_spriteSystem.Frame0(spriteSpecifier)); | ||
} | ||
|
||
|
||
} |
17 changes: 17 additions & 0 deletions
17
Content.Client/UserInterface/Systems/Targeting/Widgets/TargetingControl.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<widgets:TargetingControl | ||
xmlns="https://spacestation14.io" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Targeting.Widgets" | ||
Name="TargetingButton" | ||
VerticalAlignment="Bottom" | ||
HorizontalAlignment="Right" | ||
> | ||
<Control> | ||
<TextureButton | ||
Name="TargetImage" | ||
TexturePath="/Textures/Interface/Targeting/bodydoll.rsi/doll.png" | ||
MouseFilter="Stop" | ||
Scale="2.5 2.5" | ||
/> | ||
</Control> | ||
</widgets:TargetingControl> |
29 changes: 29 additions & 0 deletions
29
Content.Client/UserInterface/Systems/Targeting/Widgets/TargetingControl.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client.UserInterface.Systems.Targeting.Widgets; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class TargetingControl : UIWidget | ||
{ | ||
private readonly TargetingUIController _controller; | ||
|
||
public TargetingControl() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
_controller = UserInterfaceManager.GetUIController<TargetingUIController>(); | ||
TargetImage.OnPressed += OnTargetImagePressed; | ||
} | ||
private void OnTargetImagePressed(BaseButton.ButtonEventArgs args) | ||
{ | ||
_controller.CycleTarget(this); | ||
} | ||
|
||
public void SetTargetImage(Texture texture) | ||
{ | ||
TargetImage.TextureNormal = texture; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Content.Shared.Targeting; | ||
using Content.Shared.Targeting.Events; | ||
using Robust.Server.Audio; | ||
using Robust.Shared.Audio; | ||
|
||
namespace Content.Server.Targeting; | ||
public sealed class TargetingSystem : SharedTargetingSystem | ||
{ | ||
[Dependency] private readonly AudioSystem _audio = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeNetworkEvent<TargetChangeEvent>(OnTargetChange); | ||
} | ||
|
||
private void OnTargetChange(TargetChangeEvent message, EntitySessionEventArgs args) | ||
{ | ||
if (!TryComp<TargetingComponent>(GetEntity(message.Uid), out var target)) | ||
return; | ||
|
||
// Todo, get a better sound for this shit. | ||
//_audio.PlayGlobal(target.SwapSound, args.SenderSession, AudioParams.Default.WithVolume(-8f)); | ||
target.Target = message.BodyPart; | ||
Dirty(GetEntity(message.Uid), target); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.