Skip to content

Commit

Permalink
Merge pull request #1454 from space-syndicate/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Morb0 authored Sep 24, 2023
2 parents ba5d0cf + f7ee847 commit ae593e6
Show file tree
Hide file tree
Showing 110 changed files with 1,009 additions and 198 deletions.
8 changes: 4 additions & 4 deletions Content.Client/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public sealed class GhostSystem : SharedGhostSystem
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly ILightManager _lightManager = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly ContentEyeSystem _contentEye = default!;

public int AvailableGhostRoleCount { get; private set; }
Expand Down Expand Up @@ -83,7 +82,7 @@ private void OnToggleLighting(EntityUid uid, GhostComponent component, ToggleLig
if (args.Handled)
return;

_popup.PopupEntity(Loc.GetString("ghost-gui-toggle-lighting-manager-popup"), args.Performer);
Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-lighting-manager-popup"), args.Performer);
_lightManager.Enabled = !_lightManager.Enabled;
args.Handled = true;
}
Expand All @@ -93,7 +92,7 @@ private void OnToggleFoV(EntityUid uid, GhostComponent component, ToggleFoVActio
if (args.Handled)
return;

_popup.PopupEntity(Loc.GetString("ghost-gui-toggle-fov-popup"), args.Performer);
Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-fov-popup"), args.Performer);
_contentEye.RequestToggleFov(uid);
args.Handled = true;
}
Expand All @@ -103,7 +102,7 @@ private void OnToggleGhosts(EntityUid uid, GhostComponent component, ToggleGhost
if (args.Handled)
return;

_popup.PopupEntity(Loc.GetString("ghost-gui-toggle-ghost-visibility-popup"), args.Performer);
Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-ghost-visibility-popup"), args.Performer);
ToggleGhostVisibility();
args.Handled = true;
}
Expand All @@ -113,6 +112,7 @@ private void OnGhostRemove(EntityUid uid, GhostComponent component, ComponentRem
_actions.RemoveAction(uid, component.ToggleLightingActionEntity);
_actions.RemoveAction(uid, component.ToggleFoVActionEntity);
_actions.RemoveAction(uid, component.ToggleGhostsActionEntity);
_actions.RemoveAction(uid, component.ToggleGhostHearingActionEntity);

if (uid != _playerManager.LocalPlayer?.ControlledEntity)
return;
Expand Down
16 changes: 16 additions & 0 deletions Content.Client/MouseRotator/MouseRotatorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ public override void Update(float frameTime)

var curRot = _transform.GetWorldRotation(xform);

// 4-dir handling is separate --
// only raise event if the cardinal direction has changed
if (rotator.Simple4DirMode)
{
var angleDir = angle.GetCardinalDir();
if (angleDir == curRot.GetCardinalDir())
return;

RaisePredictiveEvent(new RequestMouseRotatorRotationSimpleEvent()
{
Direction = angleDir,
});

return;
}

// Don't raise event if mouse ~hasn't moved (or if too close to goal rotation already)
var diff = Angle.ShortestDistance(angle, curRot);
if (Math.Abs(diff.Theta) < rotator.AngleTolerance.Theta)
Expand Down
4 changes: 4 additions & 0 deletions Content.Client/Weapons/Melee/MeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public override void Update(float frameTime)
target = screen.GetClickedEntity(mousePos);
}

// Don't light-attack if interaction will be handling this instead
if (Interaction.CombatModeCanHandInteract(entity, target))
return;

RaisePredictiveEvent(new LightAttackEvent(GetNetEntity(target), GetNetEntity(weaponUid), GetNetCoordinates(coordinates)));
}
}
Expand Down
44 changes: 30 additions & 14 deletions Content.Server/Ame/EntitySystems/AmeControllerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,28 @@ private void UpdateController(EntityUid uid, TimeSpan curTime, AmeControllerComp

if (TryComp<AmeFuelContainerComponent>(controller.JarSlot.ContainedEntity, out var fuelJar))
{
var availableInject = Math.Min(controller.InjectionAmount, fuelJar.FuelAmount);
var powerOutput = group.InjectFuel(availableInject, out var overloading);
if (TryComp<PowerSupplierComponent>(uid, out var powerOutlet))
powerOutlet.MaxSupply = powerOutput;
fuelJar.FuelAmount -= availableInject;
_audioSystem.PlayPvs(controller.InjectSound, uid, AudioParams.Default.WithVolume(overloading ? 10f : 0f));
UpdateUi(uid, controller);
// if the jar is empty shut down the AME
if (fuelJar.FuelAmount <= 0)
{
SetInjecting(uid, false, null, controller);
}
else
{
var availableInject = Math.Min(controller.InjectionAmount, fuelJar.FuelAmount);
var powerOutput = group.InjectFuel(availableInject, out var overloading);
if (TryComp<PowerSupplierComponent>(uid, out var powerOutlet))
powerOutlet.MaxSupply = powerOutput;
fuelJar.FuelAmount -= availableInject;
// only play audio if we actually had an injection
if (availableInject > 0)
_audioSystem.PlayPvs(controller.InjectSound, uid, AudioParams.Default.WithVolume(overloading ? 10f : 0f));
UpdateUi(uid, controller);
}
}

controller.Stability = group.GetTotalStability();

group.UpdateCoreVisuals();
UpdateDisplay(uid, controller.Stability, controller);

if (controller.Stability <= 0)
Expand Down Expand Up @@ -155,7 +166,7 @@ public void SetInjecting(EntityUid uid, bool value, EntityUid? user = null, AmeC
return;

controller.Injecting = value;
_appearanceSystem.SetData(uid, AmeControllerVisuals.DisplayState, value ? AmeControllerState.On : AmeControllerState.Off);
UpdateDisplay(uid, controller.Stability, controller);
if (!value && TryComp<PowerSupplierComponent>(uid, out var powerOut))
powerOut.MaxSupply = 0;

Expand Down Expand Up @@ -215,15 +226,20 @@ private void UpdateDisplay(EntityUid uid, int stability, AmeControllerComponent?
if (!Resolve(uid, ref controller, ref appearance))
return;

var ameControllerState = stability switch
{
< 10 => AmeControllerState.Fuck,
< 50 => AmeControllerState.Critical,
_ => AmeControllerState.On,
};

if (!controller.Injecting)
ameControllerState = AmeControllerState.Off;

_appearanceSystem.SetData(
uid,
AmeControllerVisuals.DisplayState,
stability switch
{
< 10 => AmeControllerState.Fuck,
< 50 => AmeControllerState.Critical,
_ => AmeControllerState.On,
},
ameControllerState,
appearance
);
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Atmos/Components/GasTankComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Content.Server.Atmos.Components
[RegisterComponent]
public sealed partial class GasTankComponent : Component, IGasMixtureHolder
{
public const float MaxExplosionRange = 80f;
public const float MaxExplosionRange = 26f;
private const float DefaultLowPressure = 0f;
private const float DefaultOutputPressure = Atmospherics.OneAtmosphere;

Expand Down
6 changes: 3 additions & 3 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ private Dictionary<ICommonSession, ICChatRecipientData> GetRecipients(EntityUid
// TODO proper speech occlusion

var recipients = new Dictionary<ICommonSession, ICChatRecipientData>();
var ghosts = GetEntityQuery<GhostComponent>();
var ghostHearing = GetEntityQuery<GhostHearingComponent>();
var xforms = GetEntityQuery<TransformComponent>();

var transformSource = xforms.GetComponent(source);
Expand All @@ -767,9 +767,9 @@ private Dictionary<ICommonSession, ICChatRecipientData> GetRecipients(EntityUid
if (transformEntity.MapID != sourceMapId)
continue;

var observer = ghosts.HasComponent(playerEntity);
var observer = ghostHearing.HasComponent(playerEntity);

// even if they are an observer, in some situations we still need the range
// even if they are a ghost hearer, in some situations we still need the range
if (sourceCoords.TryDistance(EntityManager, transformEntity.Coordinates, out var distance) && distance < voiceGetRange)
{
recipients.Add(player, new ICChatRecipientData(distance, observer));
Expand Down
7 changes: 4 additions & 3 deletions Content.Server/Chemistry/ReagentEffects/SatiateThirst.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Content.Server.Nutrition.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
using Robust.Shared.Prototypes;

namespace Content.Server.Chemistry.ReagentEffects
Expand All @@ -21,8 +21,9 @@ public sealed partial class SatiateThirst : ReagentEffect
/// Satiate thirst if a ThirstComponent can be found
public override void Effect(ReagentEffectArgs args)
{
if (args.EntityManager.TryGetComponent(args.SolutionEntity, out ThirstComponent? thirst))
EntitySystem.Get<ThirstSystem>().UpdateThirst(thirst, HydrationFactor);
var uid = args.SolutionEntity;
if (args.EntityManager.TryGetComponent(uid, out ThirstComponent? thirst))
EntitySystem.Get<ThirstSystem>().ModifyThirst(uid, thirst, HydrationFactor);
}

protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Server.NPC.Components;
using Content.Server.RoundEnd;
using Content.Server.StationEvents.Events;
using Content.Shared.Dataset;
using Content.Shared.Roles;
Expand Down Expand Up @@ -31,10 +32,34 @@ public sealed partial class NukeopsRuleComponent : Component
public int MaxOperatives = 5;

/// <summary>
/// Whether or not all of the nuclear operatives dying will end the round. Used by LoneOpsSpawn event.
/// What will happen if all of the nuclear operatives will die. Used by LoneOpsSpawn event.
/// </summary>
[DataField("endsRound")]
public bool EndsRound = true;
[DataField("roundEndBehavior")]
public RoundEndBehavior RoundEndBehavior = RoundEndBehavior.ShuttleCall;

/// <summary>
/// Text for shuttle call if RoundEndBehavior is ShuttleCall.
/// </summary>
[DataField("roundEndTextSender")]
public string RoundEndTextSender = "comms-console-announcement-title-centcom";

/// <summary>
/// Text for shuttle call if RoundEndBehavior is ShuttleCall.
/// </summary>
[DataField("roundEndTextShuttleCall")]
public string RoundEndTextShuttleCall = "nuke-ops-no-more-threat-announcement-shuttle-call";

/// <summary>
/// Text for announcement if RoundEndBehavior is ShuttleCall. Used if shuttle is already called
/// </summary>
[DataField("roundEndTextAnnouncement")]
public string RoundEndTextAnnouncement = "nuke-ops-no-more-threat-announcement";

/// <summary>
/// Time to emergency shuttle to arrive if RoundEndBehavior is ShuttleCall.
/// </summary>
[DataField("evacShuttleTime")]
public TimeSpan EvacShuttleTime = TimeSpan.FromMinutes(10);

/// <summary>
/// Whether or not to spawn the nuclear operative outpost. Used by LoneOpsSpawn event.
Expand Down
15 changes: 10 additions & 5 deletions Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,14 @@ private void OnRoundEndText(RoundEndTextAppendEvent ev)
}
}

private void SetWinType(EntityUid uid, WinType type, NukeopsRuleComponent? component = null)
private void SetWinType(EntityUid uid, WinType type, NukeopsRuleComponent? component = null, bool endRound = true)
{
if (!Resolve(uid, ref component))
return;

component.WinType = type;

if (type == WinType.CrewMajor || type == WinType.OpsMajor)
if (endRound && (type == WinType.CrewMajor || type == WinType.OpsMajor))
_roundEndSystem.EndRound();
}

Expand All @@ -508,7 +508,7 @@ private void CheckRoundShouldEnd()
if (!GameTicker.IsGameRuleAdded(uid, gameRule))
continue;

if (!nukeops.EndsRound || nukeops.WinType == WinType.CrewMajor || nukeops.WinType == WinType.OpsMajor)
if (nukeops.RoundEndBehavior == RoundEndBehavior.Nothing || nukeops.WinType == WinType.CrewMajor || nukeops.WinType == WinType.OpsMajor)
continue;

// If there are any nuclear bombs that are active, immediately return. We're not over yet.
Expand Down Expand Up @@ -561,7 +561,12 @@ private void CheckRoundShouldEnd()
? WinCondition.NukiesAbandoned
: WinCondition.AllNukiesDead);

SetWinType(uid, WinType.CrewMajor, nukeops);
SetWinType(uid, WinType.CrewMajor, nukeops, false);
_roundEndSystem.DoRoundEndBehavior(
nukeops.RoundEndBehavior, nukeops.EvacShuttleTime, nukeops.RoundEndTextSender, nukeops.RoundEndTextShuttleCall, nukeops.RoundEndTextAnnouncement);

// prevent it called multiple times
nukeops.RoundEndBehavior = RoundEndBehavior.Nothing;
}
}

Expand Down Expand Up @@ -765,7 +770,7 @@ private void OnMindAdded(EntityUid uid, NukeOperativeComponent component, MindAd

foreach (var (nukeops, gameRule) in EntityQuery<NukeopsRuleComponent, GameRuleComponent>())
{
if (nukeops.OperativeMindPendingData.TryGetValue(uid, out var role) || !nukeops.SpawnOutpost || !nukeops.EndsRound)
if (nukeops.OperativeMindPendingData.TryGetValue(uid, out var role) || !nukeops.SpawnOutpost || nukeops.RoundEndBehavior == RoundEndBehavior.Nothing)
{
role ??= nukeops.OperativeRoleProto;
_roles.MindAddRole(mindId, new NukeopsRoleComponent { PrototypeId = role });
Expand Down
26 changes: 26 additions & 0 deletions Content.Server/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Events;
using Content.Shared.Popups;
using Content.Shared.Storage.Components;
using Robust.Server.GameObjects;
using Robust.Server.Player;
Expand Down Expand Up @@ -64,11 +65,35 @@ public override void Initialize()
SubscribeNetworkEvent<GhostWarpToTargetRequestEvent>(OnGhostWarpToTargetRequest);

SubscribeLocalEvent<GhostComponent, BooActionEvent>(OnActionPerform);
SubscribeLocalEvent<GhostComponent, ToggleGhostHearingActionEvent>(OnGhostHearingAction);
SubscribeLocalEvent<GhostComponent, InsertIntoEntityStorageAttemptEvent>(OnEntityStorageInsertAttempt);

SubscribeLocalEvent<RoundEndTextAppendEvent>(_ => MakeVisible(true));
}

private void OnGhostHearingAction(EntityUid uid, GhostComponent component, ToggleGhostHearingActionEvent args)
{
args.Handled = true;

if (HasComp<GhostHearingComponent>(uid))
{
RemComp<GhostHearingComponent>(uid);
_actions.SetToggled(component.ToggleGhostHearingActionEntity, true);
}
else
{
AddComp<GhostHearingComponent>(uid);
_actions.SetToggled(component.ToggleGhostHearingActionEntity, false);
}

var str = HasComp<GhostHearingComponent>(uid)
? Loc.GetString("ghost-gui-toggle-hearing-popup-on")
: Loc.GetString("ghost-gui-toggle-hearing-popup-off");

Popup.PopupEntity(str, uid, uid);
Dirty(uid, component);
}

private void OnActionPerform(EntityUid uid, GhostComponent component, BooActionEvent args)
{
if (args.Handled)
Expand Down Expand Up @@ -164,6 +189,7 @@ private void OnMapInit(EntityUid uid, GhostComponent component, MapInitEvent arg
_actions.SetCooldown(component.BooActionEntity.Value, start, end);
}

_actions.AddAction(uid, ref component.ToggleGhostHearingActionEntity, component.ToggleGhostHearingAction);
_actions.AddAction(uid, ref component.ToggleLightingActionEntity, component.ToggleLightingAction);
_actions.AddAction(uid, ref component.ToggleFoVActionEntity, component.ToggleFoVAction);
_actions.AddAction(uid, ref component.ToggleGhostsActionEntity, component.ToggleGhostsAction);
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Medical/VomitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Vomit(EntityUid uid, float thirstAdded = -40f, float hungerAdded = -
_hunger.ModifyHunger(uid, hungerAdded, hunger);

if (TryComp<ThirstComponent>(uid, out var thirst))
_thirst.UpdateThirst(thirst, thirstAdded);
_thirst.ModifyThirst(uid, thirst, thirstAdded);

// It fully empties the stomach, this amount from the chem stream is relatively small
var solutionSize = (MathF.Abs(thirstAdded) + MathF.Abs(hungerAdded)) / 6;
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Nutrition/Components/FoodComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public sealed partial class FoodComponent : Component
[DataField]
public SoundSpecifier UseSound = new SoundPathSpecifier("/Audio/Items/eatfood.ogg");

[DataField]
[DataField("trash")]
public EntProtoId? TrashPrototype;

[DataField]
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Nutrition/EntitySystems/FoodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Inventory;
using Content.Server.Nutrition.Components;
using Content.Server.Popups;
using Content.Server.Stack;
Expand Down Expand Up @@ -61,7 +62,7 @@ public override void Initialize()

// TODO add InteractNoHandEvent for entities like mice.
// run after openable for wrapped/peelable foods
SubscribeLocalEvent<FoodComponent, UseInHandEvent>(OnUseFoodInHand, after: new[] { typeof(OpenableSystem) });
SubscribeLocalEvent<FoodComponent, UseInHandEvent>(OnUseFoodInHand, after: new[] { typeof(OpenableSystem), typeof(ServerInventorySystem) });
SubscribeLocalEvent<FoodComponent, AfterInteractEvent>(OnFeedFood);
SubscribeLocalEvent<FoodComponent, GetVerbsEvent<AlternativeVerb>>(AddEatVerb);
SubscribeLocalEvent<FoodComponent, ConsumeDoAfterEvent>(OnDoAfter);
Expand Down
Loading

0 comments on commit ae593e6

Please sign in to comment.