forked from Rxup/space-station-14
-
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.
* stage 0.1 * stage 0.2 * stage 0.2.1 * stage 0.2.3 * small fix.... * fix * stage 0.2.4 * fix chat * stage 0.5 * stage 0.8 * add station events, fix * save * fix mind swap --------- Co-authored-by: Zack Backmen <[email protected]>
- Loading branch information
Showing
322 changed files
with
5,829 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Content.Shared.Backmen.Abilities.Psionics; | ||
using Content.Client.Chat.Managers; | ||
using Robust.Client.Player; | ||
|
||
namespace Content.Client.Backmen.Chat; | ||
|
||
public sealed class PsionicChatUpdateSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IChatManager _chatManager = default!; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<PsionicComponent, ComponentInit>(OnInit); | ||
SubscribeLocalEvent<PsionicComponent, ComponentRemove>(OnRemove); | ||
} | ||
|
||
public PsionicComponent? Player => CompOrNull<PsionicComponent>(_playerManager.LocalPlayer?.ControlledEntity); | ||
public bool IsPsionic => Player != null; | ||
|
||
private void OnInit(EntityUid uid, PsionicComponent component, ComponentInit args) | ||
{ | ||
_chatManager.UpdatePermissions(); | ||
} | ||
|
||
private void OnRemove(EntityUid uid, PsionicComponent component, ComponentRemove args) | ||
{ | ||
_chatManager.UpdatePermissions(); | ||
} | ||
} |
158 changes: 158 additions & 0 deletions
158
Content.Client/Backmen/EntityHealthBar/EntityHealthBarOverlay.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,158 @@ | ||
using System.Numerics; | ||
using Content.Shared.Damage; | ||
using Content.Shared.Mobs; | ||
using Content.Shared.Mobs.Components; | ||
using Content.Shared.Mobs.Systems; | ||
using Content.Shared.FixedPoint; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Client.Backmen.EntityHealthBar; | ||
|
||
/// <summary> | ||
/// Yeah a lot of this is duplicated from doafters. | ||
/// Not much to be done until there's a generic HUD system | ||
/// </summary> | ||
public sealed class EntityHealthBarOverlay : Overlay | ||
{ | ||
private readonly IEntityManager _entManager; | ||
private readonly SharedTransformSystem _transform; | ||
private readonly MobStateSystem _mobStateSystem; | ||
private readonly MobThresholdSystem _mobThresholdSystem; | ||
private readonly Texture _barTexture; | ||
private readonly ShaderInstance _shader; | ||
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV; | ||
public List<string> DamageContainers = new(); | ||
|
||
public EntityHealthBarOverlay(IEntityManager entManager, IPrototypeManager protoManager) | ||
{ | ||
_entManager = entManager; | ||
_transform = _entManager.EntitySysManager.GetEntitySystem<SharedTransformSystem>(); | ||
_mobStateSystem = _entManager.EntitySysManager.GetEntitySystem<MobStateSystem>(); | ||
_mobThresholdSystem = _entManager.EntitySysManager.GetEntitySystem<MobThresholdSystem>(); | ||
|
||
var sprite = new SpriteSpecifier.Rsi(new ("/Textures/Interface/Misc/health_bar.rsi"), "icon"); | ||
_barTexture = _entManager.EntitySysManager.GetEntitySystem<SpriteSystem>().Frame0(sprite); | ||
|
||
_shader = protoManager.Index<ShaderPrototype>("unshaded").Instance(); | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
var handle = args.WorldHandle; | ||
var rotation = args.Viewport.Eye?.Rotation ?? Angle.Zero; | ||
var spriteQuery = _entManager.GetEntityQuery<SpriteComponent>(); | ||
var xformQuery = _entManager.GetEntityQuery<TransformComponent>(); | ||
|
||
const float scale = 1f; | ||
var scaleMatrix = Matrix3.CreateScale(new Vector2(scale, scale)); | ||
var rotationMatrix = Matrix3.CreateRotation(-rotation); | ||
handle.UseShader(_shader); | ||
|
||
foreach (var (thresholds, mob, dmg) in _entManager.EntityQuery<MobThresholdsComponent, MobStateComponent, DamageableComponent>(true)) | ||
{ | ||
if (!xformQuery.TryGetComponent(mob.Owner, out var xform) || | ||
xform.MapID != args.MapId) | ||
{ | ||
continue; | ||
} | ||
|
||
if (dmg.DamageContainerID == null || !DamageContainers.Contains(dmg.DamageContainerID)) | ||
continue; | ||
|
||
var worldPosition = _transform.GetWorldPosition(xform); | ||
var worldMatrix = Matrix3.CreateTranslation(worldPosition); | ||
|
||
Matrix3.Multiply(scaleMatrix, worldMatrix, out var scaledWorld); | ||
Matrix3.Multiply(rotationMatrix, scaledWorld, out var matty); | ||
|
||
handle.SetTransform(matty); | ||
|
||
float yOffset; | ||
if (spriteQuery.TryGetComponent(mob.Owner, out var sprite)) | ||
{ | ||
yOffset = sprite.Bounds.Height + 15f; | ||
} | ||
else | ||
{ | ||
yOffset = 1f; | ||
} | ||
|
||
var position = new Vector2(-_barTexture.Width / 2f / EyeManager.PixelsPerMeter, | ||
yOffset / EyeManager.PixelsPerMeter); | ||
|
||
// Draw the underlying bar texture | ||
handle.DrawTexture(_barTexture, position); | ||
|
||
// we are all progressing towards death every day | ||
(float ratio, bool inCrit) deathProgress = CalcProgress(mob.Owner, mob, dmg, thresholds); | ||
|
||
var color = GetProgressColor(deathProgress.ratio, deathProgress.inCrit); | ||
|
||
// Hardcoded width of the progress bar because it doesn't match the texture. | ||
const float startX = 2f; | ||
const float endX = 22f; | ||
|
||
var xProgress = (endX - startX) * deathProgress.ratio + startX; | ||
|
||
var box = new Box2(new Vector2(startX, 3f) / EyeManager.PixelsPerMeter, new Vector2(xProgress, 4f) / EyeManager.PixelsPerMeter); | ||
box = box.Translated(position); | ||
handle.DrawRect(box, color); | ||
} | ||
|
||
handle.UseShader(null); | ||
handle.SetTransform(Matrix3.Identity); | ||
} | ||
|
||
/// <summary> | ||
/// Returns a ratio between 0 and 1, and whether the entity is in crit. | ||
/// </summary> | ||
private (float, bool) CalcProgress(EntityUid uid, MobStateComponent component, DamageableComponent dmg, MobThresholdsComponent thresholds) | ||
{ | ||
if (_mobStateSystem.IsAlive(uid, component)) | ||
{ | ||
if (!_mobThresholdSystem.TryGetThresholdForState(uid, MobState.Critical, out var threshold, thresholds)) | ||
return (1, false); | ||
|
||
var ratio = 1 - ((FixedPoint2)(dmg.TotalDamage / threshold)).Float(); | ||
return (ratio, false); | ||
} | ||
|
||
if (_mobStateSystem.IsCritical(uid, component)) | ||
{ | ||
if (!_mobThresholdSystem.TryGetThresholdForState(uid, MobState.Critical, out var critThreshold, thresholds) || | ||
!_mobThresholdSystem.TryGetThresholdForState(uid, MobState.Dead, out var deadThreshold, thresholds)) | ||
{ | ||
return (1, true); | ||
} | ||
|
||
var ratio = 1 - | ||
((dmg.TotalDamage - critThreshold) / | ||
(deadThreshold - critThreshold)).Value.Float(); | ||
|
||
return (ratio, true); | ||
} | ||
|
||
return (0, true); | ||
} | ||
|
||
public static Color GetProgressColor(float progress, bool crit) | ||
{ | ||
if (progress >= 1.0f) | ||
{ | ||
return new Color(0f, 1f, 0f); | ||
} | ||
// lerp | ||
if (!crit) | ||
{ | ||
var hue = (5f / 18f) * progress; | ||
return Color.FromHsv((hue, 1f, 0.75f, 1f)); | ||
} else | ||
{ | ||
return Color.Red; | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
Content.Client/Backmen/EntityHealthBar/ShowHealthBarsSystem.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,68 @@ | ||
using Content.Shared.Backmen.EntityHealthBar; | ||
using Content.Shared.Backmen.EntityHealthBar; | ||
using Content.Shared.GameTicking; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.Backmen.EntityHealthBar; | ||
|
||
public sealed class ShowHealthBarsSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IPlayerManager _player = default!; | ||
[Dependency] private readonly IPrototypeManager _protoMan = default!; | ||
[Dependency] private readonly IOverlayManager _overlayMan = default!; | ||
|
||
private EntityHealthBarOverlay _overlay = default!; | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<ShowHealthBarsComponent, ComponentInit>(OnInit); | ||
SubscribeLocalEvent<ShowHealthBarsComponent, ComponentRemove>(OnRemove); | ||
SubscribeLocalEvent<ShowHealthBarsComponent, PlayerAttachedEvent>(OnPlayerAttached); | ||
SubscribeLocalEvent<ShowHealthBarsComponent, PlayerDetachedEvent>(OnPlayerDetached); | ||
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart); | ||
|
||
_overlay = new(EntityManager, _protoMan); | ||
} | ||
|
||
private void OnInit(EntityUid uid, ShowHealthBarsComponent component, ComponentInit args) | ||
{ | ||
if (_player.LocalPlayer?.ControlledEntity == uid) | ||
{ | ||
ApplyOverlays(component); | ||
} | ||
} | ||
|
||
private void OnRemove(EntityUid uid, ShowHealthBarsComponent component, ComponentRemove args) | ||
{ | ||
if (_player.LocalPlayer?.ControlledEntity == uid) | ||
{ | ||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
} | ||
|
||
private void OnPlayerAttached(EntityUid uid, ShowHealthBarsComponent component, PlayerAttachedEvent args) | ||
{ | ||
ApplyOverlays(component); | ||
} | ||
|
||
private void ApplyOverlays(ShowHealthBarsComponent component) | ||
{ | ||
_overlayMan.AddOverlay(_overlay); | ||
_overlay.DamageContainers.Clear(); | ||
_overlay.DamageContainers.AddRange(component.DamageContainers); | ||
} | ||
|
||
private void OnPlayerDetached(EntityUid uid, ShowHealthBarsComponent component, PlayerDetachedEvent args) | ||
{ | ||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
|
||
private void OnRoundRestart(RoundRestartCleanupEvent args) | ||
{ | ||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
Content.Client/Backmen/Psionics/Glimmer/GlimmerReactiveVisuals.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,6 @@ | ||
namespace Content.Client.Psionics.Glimmer; | ||
|
||
public enum GlimmerReactiveVisualLayers : byte | ||
{ | ||
GlimmerEffect, | ||
} |
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,42 @@ | ||
using Content.Client.Eui; | ||
using Content.Shared.Backmen.Psionics; | ||
using JetBrains.Annotations; | ||
using Robust.Client.Graphics; | ||
|
||
namespace Content.Client.Psionics.UI | ||
{ | ||
[UsedImplicitly] | ||
public sealed class AcceptPsionicsEui : BaseEui | ||
{ | ||
private readonly AcceptPsionicsWindow _window; | ||
|
||
public AcceptPsionicsEui() | ||
{ | ||
_window = new AcceptPsionicsWindow(); | ||
|
||
_window.DenyButton.OnPressed += _ => | ||
{ | ||
SendMessage(new AcceptPsionicsChoiceMessage(AcceptPsionicsUiButton.Deny)); | ||
_window.Close(); | ||
}; | ||
|
||
_window.AcceptButton.OnPressed += _ => | ||
{ | ||
SendMessage(new AcceptPsionicsChoiceMessage(AcceptPsionicsUiButton.Accept)); | ||
_window.Close(); | ||
}; | ||
} | ||
|
||
public override void Opened() | ||
{ | ||
IoCManager.Resolve<IClyde>().RequestWindowAttention(); | ||
_window.OpenCentered(); | ||
} | ||
|
||
public override void Closed() | ||
{ | ||
_window.Close(); | ||
} | ||
|
||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
Content.Client/Backmen/Psionics/UI/AcceptPsionicsWindow.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,62 @@ | ||
using System.Numerics; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Shared.Localization; | ||
using static Robust.Client.UserInterface.Controls.BoxContainer; | ||
|
||
namespace Content.Client.Psionics.UI | ||
{ | ||
public sealed class AcceptPsionicsWindow : DefaultWindow | ||
{ | ||
public readonly Button DenyButton; | ||
public readonly Button AcceptButton; | ||
|
||
public AcceptPsionicsWindow() | ||
{ | ||
|
||
Title = Loc.GetString("accept-psionics-window-title"); | ||
|
||
Contents.AddChild(new BoxContainer | ||
{ | ||
Orientation = LayoutOrientation.Vertical, | ||
Children = | ||
{ | ||
new BoxContainer | ||
{ | ||
Orientation = LayoutOrientation.Vertical, | ||
Children = | ||
{ | ||
(new Label() | ||
{ | ||
Text = Loc.GetString("accept-psionics-window-prompt-text-part") | ||
}), | ||
new BoxContainer | ||
{ | ||
Orientation = LayoutOrientation.Horizontal, | ||
Align = AlignMode.Center, | ||
Children = | ||
{ | ||
(AcceptButton = new Button | ||
{ | ||
Text = Loc.GetString("accept-cloning-window-accept-button"), | ||
}), | ||
|
||
(new Control() | ||
{ | ||
MinSize = new Vector2(20, 0) | ||
}), | ||
|
||
(DenyButton = new Button | ||
{ | ||
Text = Loc.GetString("accept-cloning-window-deny-button"), | ||
}) | ||
} | ||
}, | ||
} | ||
}, | ||
} | ||
}); | ||
} | ||
} | ||
} |
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.