forked from space-wizards/space-station-14
-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'impstation:master' into master
- Loading branch information
Showing
36 changed files
with
571 additions
and
28 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,56 @@ | ||
using System.Numerics; | ||
using Content.Client.Alerts; | ||
using Content.Shared.Revenant; | ||
using Content.Shared.Revenant.Components; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Utility; | ||
using Timer = Robust.Shared.Timing.Timer; | ||
|
||
namespace Content.Client.Revenant; | ||
|
||
public sealed class RevenantRegenModifierSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SpriteSystem _sprite = default!; | ||
|
||
private readonly SpriteSpecifier _witnessIndicator = new SpriteSpecifier.Texture(new ResPath("Interface/Actions/scream.png")); | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<RevenantRegenModifierComponent, UpdateAlertSpriteEvent>(OnUpdateAlert); | ||
SubscribeNetworkEvent<RevenantHauntWitnessEvent>(OnWitnesses); | ||
} | ||
|
||
private void OnWitnesses(RevenantHauntWitnessEvent args) | ||
{ | ||
foreach (var witness in args.Witnesses) | ||
{ | ||
var ent = GetEntity(witness); | ||
if (TryComp<SpriteComponent>(ent, out var sprite)) | ||
{ | ||
var layerID = sprite.AddLayer(_witnessIndicator); | ||
if (sprite.TryGetLayer(layerID, out var layer)) | ||
{ | ||
layer.Offset = new Vector2(0, 0.8f); | ||
layer.Scale = new Vector2(0.65f, 0.65f); | ||
} | ||
Timer.Spawn(TimeSpan.FromSeconds(5), () => sprite.RemoveLayer(layerID)); | ||
} | ||
} | ||
} | ||
|
||
private void OnUpdateAlert(Entity<RevenantRegenModifierComponent> ent, ref UpdateAlertSpriteEvent args) | ||
{ | ||
if (args.Alert.ID != ent.Comp.Alert) | ||
return; | ||
|
||
var sprite = args.SpriteViewEnt.Comp; | ||
var witnesses = Math.Clamp(ent.Comp.Witnesses.Count, 0, 99); | ||
sprite.LayerSetState(RevenantVisualLayers.Digit1, $"{witnesses / 10}"); | ||
sprite.LayerSetState(RevenantVisualLayers.Digit2, $"{witnesses % 10}"); | ||
} | ||
} |
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
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 Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Lens; | ||
|
||
/// <summary> | ||
/// This component is used alongside <see cref="ItemSlotsComponent"/> to find a specific container. | ||
/// Enables clothing to change functionality based on items inside of it. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class LensSlotComponent : Component | ||
{ | ||
[DataField("LensSlotId", required: true)] | ||
public string LensSlotId = string.Empty; | ||
} | ||
|
||
/// <summary> | ||
/// Raised directed at an entity with a lens slot when the lens is ejected/inserted. | ||
/// </summary> | ||
public sealed class LensChangedEvent : EntityEventArgs | ||
{ | ||
public readonly bool Ejected; | ||
|
||
public LensChangedEvent(bool ejected) | ||
{ | ||
Ejected = ejected; | ||
} | ||
} |
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,59 @@ | ||
using Content.Shared.Containers.ItemSlots; | ||
using Content.Shared.Examine; | ||
using Robust.Shared.Containers; | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Shared.Lens; | ||
|
||
public sealed class LensSlotSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<LensSlotComponent, ExaminedEvent>(OnExamine); | ||
|
||
SubscribeLocalEvent<LensSlotComponent, EntInsertedIntoContainerMessage>(OnLensInserted); | ||
SubscribeLocalEvent<LensSlotComponent, EntRemovedFromContainerMessage>(OnLensRemoved); | ||
} | ||
|
||
private void OnExamine(EntityUid glasses, LensSlotComponent component, ref ExaminedEvent args) | ||
{ | ||
if (!_itemSlots.TryGetSlot(glasses, component.LensSlotId, out var itemSlot)) | ||
return; | ||
|
||
var msg = new FormattedMessage(); | ||
|
||
if (itemSlot.Item == null) | ||
msg.AddMarkupOrThrow(Loc.GetString("lens-empty")); | ||
else | ||
{ | ||
var metadata = MetaData(itemSlot.Item.Value); | ||
msg.AddMarkupOrThrow(Loc.GetString("lens-filled") + " [color=white]" + metadata.EntityName + "[/color]."); | ||
} | ||
|
||
args.PushMessage(msg); | ||
} | ||
|
||
private void OnLensInserted(EntityUid glasses, LensSlotComponent component, EntInsertedIntoContainerMessage args) | ||
{ | ||
if (!component.Initialized) | ||
return; | ||
|
||
if (args.Container.ID != component.LensSlotId) | ||
return; | ||
|
||
RaiseLocalEvent(glasses, new LensChangedEvent(false)); | ||
} | ||
|
||
private void OnLensRemoved(EntityUid glasses, LensSlotComponent component, EntRemovedFromContainerMessage args) | ||
{ | ||
if (args.Container.ID != component.LensSlotId) | ||
return; | ||
|
||
RaiseLocalEvent(glasses, new LensChangedEvent(true)); | ||
} | ||
} |
Oops, something went wrong.