Skip to content

Commit

Permalink
Merge branch 'master' of http://github.com/hivehum/imp-station-14
Browse files Browse the repository at this point in the history
  • Loading branch information
hivehum committed Jan 1, 2025
2 parents 9a6a7fb + c33e653 commit ecbbd22
Show file tree
Hide file tree
Showing 389 changed files with 14,679 additions and 812 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Announcements/Systems/AnnouncerSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Linq;
using Content.Client.Audio;
using Content.Shared._EinsteinEngine.CCVar;
using Content.Shared._EinsteinEngines.CCVar;
using Content.Shared.Announcements.Events;
using Content.Shared.Announcements.Systems;
using Robust.Client.Audio;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Options/UI/Tabs/AudioTab.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Content.Client.Audio;
using Content.Shared._EinsteinEngine.CCVar;
using Content.Shared._EinsteinEngines.CCVar;
using Content.Shared._Impstation.CCVar;
using Content.Shared.CCVar;
using Robust.Client.Audio;
Expand Down
54 changes: 49 additions & 5 deletions Content.Client/Stealth/StealthSystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Content.Client.Administration.Managers;
using Content.Client.Interactable.Components;
using Content.Client.StatusIcon;
using Content.Shared.Ghost;
using Content.Shared.Stealth;
using Content.Shared.Stealth.Components;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Prototypes;

namespace Content.Client.Stealth;
Expand All @@ -12,23 +14,32 @@ public sealed class StealthSystem : SharedStealthSystem
{
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IClientAdminManager _adminManager = default!;
[Dependency] private readonly ContainerSystem _containerSystem = default!;

private ShaderInstance _shader = default!;
private ShaderInstance _altShader = default!;

private float timer = 0;

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

_shader = _protoMan.Index<ShaderPrototype>("Stealth").InstanceUnique();
_altShader = _protoMan.Index<ShaderPrototype>("AccessibleFullStealth").InstanceUnique();

SubscribeLocalEvent<StealthComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<StealthComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<StealthComponent, BeforePostShaderRenderEvent>(OnShaderRender);
}

//no longer needs a force update! yaaaaay!

public override void SetEnabled(EntityUid uid, bool value, StealthComponent? component = null)
{
if (!Resolve(uid, ref component) || component.Enabled == value)
if (!Resolve(uid, ref component))
return;

base.SetEnabled(uid, value, component);
Expand All @@ -41,7 +52,10 @@ private void SetShader(EntityUid uid, bool enabled, StealthComponent? component
return;

sprite.Color = Color.White;
sprite.PostShader = enabled ? _shader : null;
//imp special - use the alternative full-invis shader if we're set to
var shaderToUse = component.UseAltShader ? _altShader : _shader;
sprite.PostShader = enabled ? shaderToUse : null;
//imp special end
sprite.GetScreenTexture = enabled;
sprite.RaiseShaderEvent = enabled;

Expand Down Expand Up @@ -72,6 +86,36 @@ private void OnShutdown(EntityUid uid, StealthComponent component, ComponentShut

private void OnShaderRender(EntityUid uid, StealthComponent component, BeforePostShaderRenderEvent args)
{
//imp special - show an outline for people that should see it, goes along with complete invisibility
//includes the entity with the component, any admins & any ghosts
var shaderToUse = component.UseAltShader ? _altShader : _shader;
shaderToUse.SetParameter("ShowOutline", false); //make sure it's always false by default

bool isCorrectSession = false;
bool isGhost = false;
bool isInContainer = false;

if (_playerManager.LocalSession != null)
{
if (_playerManager.TryGetSessionByEntity(uid, out var playerSession))
{
isCorrectSession = playerSession.UserId == _playerManager.LocalSession.UserId;
}

isGhost = HasComp<GhostComponent>(_playerManager.LocalSession.AttachedEntity);

if (_playerManager.LocalSession.AttachedEntity is { } entity) //why can you not just use a normal nullcheck for this I hate c#
{
isInContainer = _containerSystem.ContainsEntity(uid, entity);
}
}

if (isCorrectSession || isGhost || isInContainer)
{
shaderToUse.SetParameter("ShowOutline", true);
}
//imp special end

// Distortion effect uses screen coordinates. If a player moves, the entities appear to move on screen. this
// makes the distortion very noticeable.

Expand All @@ -89,8 +133,8 @@ private void OnShaderRender(EntityUid uid, StealthComponent component, BeforePos
// actual visual visibility effect is limited to +/- 1.
visibility = Math.Clamp(visibility, -1f, 1f);

_shader.SetParameter("reference", reference);
_shader.SetParameter("visibility", visibility);
shaderToUse.SetParameter("reference", reference);
shaderToUse.SetParameter("visibility", visibility);

visibility = MathF.Max(0, visibility);
args.Sprite.Color = new Color(visibility, visibility, 1, 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Content.Shared.Damage.Systems;

namespace Content.Client.Damage;

public sealed class DamageOtherOnHitSystem : SharedDamageOtherOnHitSystem;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Numerics;
using Content.Client.Construction;
using Content.Client.UserInterface.Controls;
using Content.Shared._EinsteinEngine.ShortConstruction;
using Content.Shared._EinsteinEngines.ShortConstruction;
using Content.Shared.Construction.Prototypes;
using Content.Shared.Popups;
using Robust.Client.GameObjects;
Expand All @@ -15,7 +15,7 @@
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;

namespace Content.Client._EinsteinEngine.ShortConstruction.UI;
namespace Content.Client._EinsteinEngines.ShortConstruction.UI;

//This was originally a PR for Einstein's Engines, submitted by Github user VMSolidus.
//https://github.com/Simple-Station/Einstein-Engines/pull/861
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// ReSharper disable InconsistentNaming

namespace Content.Client._EinsteinEngine.ShortConstruction.UI;
namespace Content.Client._EinsteinEngines.ShortConstruction.UI;

[UsedImplicitly]
public sealed class ShortConstructionMenuBUI : BoundUserInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Content.Shared.Random;
using Content.Shared.Random.Helpers;
using Robust.Shared.Utility;
using Content.Shared._EinsteinEngine.CCVar;
using Content.Shared._EinsteinEngines.CCVar;

namespace Content.Server.Announcements.Systems;

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Announcements/Systems/AnnouncerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Content.Shared.Announcements.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Content.Shared._EinsteinEngine.CCVar;
using Content.Shared._EinsteinEngines.CCVar;

namespace Content.Server.Announcements.Systems;

Expand Down
19 changes: 0 additions & 19 deletions Content.Server/Damage/Components/DamageOtherOnHitComponent.cs

This file was deleted.

52 changes: 24 additions & 28 deletions Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,56 @@
using Content.Shared.Wires;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
using Content.Shared.Popups;
using Content.Shared.Damage.Components;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Utility;

namespace Content.Server.Damage.Systems
{
public sealed class DamageOtherOnHitSystem : EntitySystem
public sealed class DamageOtherOnHitSystem : SharedDamageOtherOnHitSystem
{
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly GunSystem _guns = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly DamageExamineSystem _damageExamine = default!;
[Dependency] private readonly SharedCameraRecoilSystem _sharedCameraRecoil = default!;
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;

public override void Initialize()
{
SubscribeLocalEvent<DamageOtherOnHitComponent, ThrowDoHitEvent>(OnDoHit);
base.Initialize();

SubscribeLocalEvent<StaminaComponent, BeforeThrowEvent>(OnBeforeThrow);
SubscribeLocalEvent<DamageOtherOnHitComponent, DamageExamineEvent>(OnDamageExamine);
SubscribeLocalEvent<DamageOtherOnHitComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
}

private void OnDoHit(EntityUid uid, DamageOtherOnHitComponent component, ThrowDoHitEvent args)
private void OnBeforeThrow(EntityUid uid, StaminaComponent component, ref BeforeThrowEvent args)
{
if (TerminatingOrDeleted(args.Target))
if (!TryComp<DamageOtherOnHitComponent>(args.ItemUid, out var damage))
return;

var dmg = _damageable.TryChangeDamage(args.Target, component.Damage, component.IgnoreResistances, origin: args.Component.Thrower);

// Log damage only for mobs. Useful for when people throw spears at each other, but also avoids log-spam when explosions send glass shards flying.
if (dmg != null && HasComp<MobStateComponent>(args.Target))
_adminLogger.Add(LogType.ThrowHit, $"{ToPrettyString(args.Target):target} received {dmg.GetTotal():damage} damage from collision");

if (dmg is { Empty: false })
{
_color.RaiseEffect(Color.Red, new List<EntityUid>() { args.Target }, Filter.Pvs(args.Target, entityManager: EntityManager));
}

_guns.PlayImpactSound(args.Target, dmg, null, false);
if (TryComp<PhysicsComponent>(uid, out var body) && body.LinearVelocity.LengthSquared() > 0f)
if (component.CritThreshold - component.StaminaDamage <= damage.StaminaCost)
{
var direction = body.LinearVelocity.Normalized();
_sharedCameraRecoil.KickCamera(args.Target, direction);
args.Cancelled = true;
_popup.PopupEntity(Loc.GetString("throw-no-stamina", ("item", args.ItemUid)), uid, uid);
return;
}
}

private void OnDamageExamine(EntityUid uid, DamageOtherOnHitComponent component, ref DamageExamineEvent args)
{
_damageExamine.AddDamageExamine(args.Message, component.Damage, Loc.GetString("damage-throw"));
}
_damageExamine.AddDamageExamine(args.Message, GetDamage(uid, component, args.User), Loc.GetString("damage-throw"));

/// <summary>
/// Prevent players with the Pacified status effect from throwing things that deal damage.
/// </summary>
private void OnAttemptPacifiedThrow(Entity<DamageOtherOnHitComponent> ent, ref AttemptPacifiedThrowEvent args)
{
args.Cancel("pacified-cannot-throw");
if (component.StaminaCost == 0)
return;

var staminaCostMarkup = FormattedMessage.FromMarkupOrThrow(
Loc.GetString("damage-stamina-cost",
("type", Loc.GetString("damage-throw")), ("cost", component.StaminaCost)));
args.Message.PushNewline();
args.Message.AddMessage(staminaCostMarkup);
}
}
}
3 changes: 3 additions & 0 deletions Content.Server/Dragon/Components/DragonRiftComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ public sealed partial class DragonRiftComponent : SharedDragonRiftComponent

[ViewVariables(VVAccess.ReadWrite), DataField("spawn", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string SpawnPrototype = "MobCarpDragon";

[ViewVariables(VVAccess.ReadWrite), DataField("announcement")]
public string Announcement = "carp-rift-warning";
}
2 changes: 1 addition & 1 deletion Content.Server/Dragon/DragonRiftSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public override void Update(float frameTime)
comp.State = DragonRiftState.AlmostFinished;
Dirty(uid, comp);

_announcer.SendAnnouncement(_announcer.GetAnnouncementId("CarpRift"), Filter.Broadcast(), "carp-rift-warning", colorOverride: Color.Red, localeArgs: ("location", FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString((uid, xform)))));
_announcer.SendAnnouncement(_announcer.GetAnnouncementId("CarpRift"), Filter.Broadcast(), comp.Announcement, colorOverride: Color.Red, localeArgs: ("location", FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString((uid, xform)))));
_navMap.SetBeaconEnabled(uid, true);
}

Expand Down
20 changes: 14 additions & 6 deletions Content.Server/Flash/FlashSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Robust.Shared.Audio;
using Robust.Shared.Random;
using InventoryComponent = Content.Shared.Inventory.InventoryComponent;
using Content.Shared.Throwing;

namespace Content.Server.Flash
{
Expand All @@ -46,6 +47,7 @@ public override void Initialize()
SubscribeLocalEvent<FlashComponent, MeleeHitEvent>(OnFlashMeleeHit);
// ran before toggling light for extra-bright lantern
SubscribeLocalEvent<FlashComponent, UseInHandEvent>(OnFlashUseInHand, before: new[] { typeof(HandheldLightSystem) });
SubscribeLocalEvent<FlashComponent, ThrowDoHitEvent>(OnFlashThrowHitEvent);
SubscribeLocalEvent<InventoryComponent, FlashAttemptEvent>(OnInventoryFlashAttempt);
SubscribeLocalEvent<FlashImmunityComponent, FlashAttemptEvent>(OnFlashImmunityFlashAttempt);
SubscribeLocalEvent<PermanentBlindnessComponent, FlashAttemptEvent>(OnPermanentBlindnessFlashAttempt);
Expand All @@ -56,10 +58,8 @@ private void OnFlashMeleeHit(EntityUid uid, FlashComponent comp, MeleeHitEvent a
{
if (!args.IsHit ||
!args.HitEntities.Any() ||
!UseFlash(uid, comp, args.User))
{
!UseFlash(uid, comp))
return;
}

args.Handled = true;
foreach (var e in args.HitEntities)
Expand All @@ -70,14 +70,22 @@ private void OnFlashMeleeHit(EntityUid uid, FlashComponent comp, MeleeHitEvent a

private void OnFlashUseInHand(EntityUid uid, FlashComponent comp, UseInHandEvent args)
{
if (args.Handled || !UseFlash(uid, comp, args.User))
if (args.Handled || !UseFlash(uid, comp))
return;

args.Handled = true;
FlashArea(uid, args.User, comp.Range, comp.AoeFlashDuration, comp.SlowTo, true, comp.Probability);
}

private bool UseFlash(EntityUid uid, FlashComponent comp, EntityUid user)
private void OnFlashThrowHitEvent(EntityUid uid, FlashComponent comp, ThrowDoHitEvent args)
{
if (!UseFlash(uid, comp))
return;

FlashArea(uid, args.User, comp.Range, comp.AoeFlashDuration, comp.SlowTo, false, comp.Probability);
}

private bool UseFlash(EntityUid uid, FlashComponent comp)
{
if (comp.Flashing)
return false;
Expand All @@ -95,7 +103,7 @@ private bool UseFlash(EntityUid uid, FlashComponent comp, EntityUid user)
{
_appearance.SetData(uid, FlashVisuals.Burnt, true);
_tag.AddTag(uid, "Trash");
_popup.PopupEntity(Loc.GetString("flash-component-becomes-empty"), user);
_popup.PopupEntity(Loc.GetString("flash-component-becomes-empty"), uid);
}

uid.SpawnTimer(400, () =>
Expand Down
6 changes: 6 additions & 0 deletions Content.Server/Hands/Systems/HandsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ hands.ActiveHandEntity is not { } throwEnt ||

// Let other systems change the thrown entity (useful for virtual items)
// or the throw strength.
var itemEv = new BeforeGettingThrownEvent(throwEnt, direction, throwSpeed, player);
RaiseLocalEvent(throwEnt, ref itemEv);

if (itemEv.Cancelled)
return true;

var ev = new BeforeThrowEvent(throwEnt, direction, throwSpeed, player);
RaiseLocalEvent(player, ref ev);

Expand Down
Loading

0 comments on commit ecbbd22

Please sign in to comment.