forked from DeltaV-Station/Delta-v
-
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.
Add hologram shader (DeltaV-Station#68)
* Add holograms! * Updated localization files
- Loading branch information
1 parent
8108cd0
commit fde7e1a
Showing
7 changed files
with
395 additions
and
0 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,48 @@ | ||
using Content.Shared.DeltaV.Hologram; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.DeltaV.Hologram; | ||
|
||
public sealed class HologramSystem : SharedHologramSystem | ||
{ | ||
[Dependency] private readonly IPrototypeManager _protoMan = default!; | ||
[Dependency] private readonly OccluderSystem _occluder = default!; | ||
[Dependency] private readonly EntityManager _entMan = default!; | ||
|
||
private ShaderInstance _shader = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
_shader = _protoMan.Index<ShaderPrototype>("Hologram").InstanceUnique(); | ||
SubscribeLocalEvent<HologramComponent, ComponentShutdown>(OnShutdown); | ||
SubscribeLocalEvent<HologramComponent, ComponentStartup>(OnStartup); | ||
} | ||
|
||
private void SetShader(EntityUid uid, bool enabled, HologramComponent? component = null, SpriteComponent? sprite = null) | ||
{ | ||
if (!Resolve(uid, ref component, ref sprite, false)) | ||
return; | ||
|
||
sprite.PostShader = enabled ? _shader : null; | ||
} | ||
|
||
private void OnStartup(EntityUid uid, HologramComponent component, ComponentStartup args) | ||
{ | ||
SetShader(uid, true, component); | ||
|
||
component.Occludes = _entMan.TryGetComponent<OccluderComponent>(uid, out var occluder) && occluder.Enabled; | ||
if (component.Occludes) | ||
_occluder.SetEnabled(uid, false); | ||
} | ||
|
||
private void OnShutdown(EntityUid uid, HologramComponent component, ComponentShutdown args) | ||
{ | ||
SetShader(uid, false, component); | ||
if (component.Occludes) | ||
_occluder.SetEnabled(uid, true); | ||
} | ||
} |
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,43 @@ | ||
using Content.Shared.Actions.Events; | ||
using Content.Shared.DeltaV.Hologram; | ||
using Content.Shared.Examine; | ||
using Content.Shared.IdentityManagement; | ||
using Content.Shared.Popups; | ||
using Robust.Shared.Player; | ||
|
||
namespace Content.Server.DeltaV.Hologram; | ||
|
||
public sealed class HologramSystem : SharedHologramSystem | ||
{ | ||
[Dependency] private readonly SharedPopupSystem _popup = default!; | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<HologramComponent, ExaminedEvent>(OnExamine); | ||
SubscribeLocalEvent<HologramComponent, DisarmAttemptEvent>(OnDisarmAttempt); | ||
} | ||
|
||
private void OnExamine(EntityUid uid, HologramComponent component, ExaminedEvent args) | ||
{ | ||
args.PushMarkup(Loc.GetString("hologram-on-examine")); | ||
} | ||
|
||
private void OnDisarmAttempt(EntityUid uid, HologramComponent component, DisarmAttemptEvent args) | ||
{ | ||
if (component.PreventDisarm) | ||
{ | ||
args.Cancel(); | ||
|
||
var filterOther = Filter.PvsExcept(args.DisarmerUid, entityManager: EntityManager); | ||
var messageUser = Loc.GetString("hologram-disarm-blocked", | ||
("target", Identity.Entity(args.TargetUid, EntityManager))); | ||
var messageOther = Loc.GetString("hologram-disarm-blocked-other", | ||
("target", Identity.Entity(args.TargetUid, EntityManager)), ("performerName", args.DisarmerUid)); | ||
|
||
_popup.PopupEntity(messageOther, args.DisarmerUid, filterOther, true); | ||
_popup.PopupEntity(messageUser, args.TargetUid, args.DisarmerUid); | ||
} | ||
|
||
} | ||
} |
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,21 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.DeltaV.Hologram; | ||
|
||
[RegisterComponent, NetworkedComponent] | ||
[Access(typeof(SharedHologramSystem))] | ||
public sealed partial class HologramComponent : Component | ||
{ | ||
/// <summary> | ||
/// To save the state of whatever the component was added to, in case it occludes when the component is added. | ||
/// </summary> | ||
[DataField("occludes")] | ||
public bool Occludes = false; | ||
|
||
/// <summary> | ||
/// Do we stop disarms or not? | ||
/// </summary> | ||
[ViewVariables(VVAccess.ReadWrite)] | ||
[DataField("preventDisarm")] | ||
public bool PreventDisarm = false; | ||
} |
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,5 @@ | ||
namespace Content.Shared.DeltaV.Hologram; | ||
|
||
public abstract class SharedHologramSystem : EntitySystem | ||
{ | ||
} |
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,3 @@ | ||
hologram-on-examine = [color=lightblue]It is but a transient specter...[/color] | ||
hologram-disarm-blocked = Your hand phases through {THE($target)}. | ||
hologram-disarm-blocked-other = {THE($performerName)}'s hand phases through {THE($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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# hologram | ||
- type: shader | ||
id: Hologram | ||
kind: source | ||
path: "/Textures/DeltaV/Shaders/hologram.swsl" | ||
params: | ||
textureHeight: 32 | ||
hue: 0.64 |
Oops, something went wrong.