Skip to content

Commit

Permalink
audio and solution fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheackraze committed Jan 10, 2024
1 parent dee39f1 commit 32ce3c3
Show file tree
Hide file tree
Showing 34 changed files with 112 additions and 346 deletions.
3 changes: 1 addition & 2 deletions Content.Client/Info/PlaytimeStats/PlaytimeStatsHeader.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Control xmlns="https://spacestation14.io"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
EnableAllKeybinds="True">
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls">
<PanelContainer Name="BackgroundColorPlaytimePanel" Access="Public"/>
<BoxContainer Orientation="Vertical"
HorizontalExpand="True">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Shared.GameTicking;
using Robust.Client.Player;
using Robust.Client.Graphics;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;

namespace Content.Client.IgnoreHumanoids
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Robust.Client.GameObjects;
using Content.Client.Chemistry.Visualizers;
using Content.Client.Kitchen.Components;
using Content.Shared.Chemistry.Components;
using Content.Shared.Kitchen.Components;

namespace Content.Client.Kitchen.Visualizers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Player;

namespace Content.Client.Nyanotrasen.Overlays;
public sealed class DogVisionSystem : EntitySystem
Expand Down
155 changes: 12 additions & 143 deletions Content.Client/Salvage/UI/SalvageExpeditionConsoleBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
using System.Linq;
using Content.Client.Stylesheets;
using Content.Shared.CCVar;
using Content.Shared.Procedural;
using Content.Shared.Salvage.Expeditions;
using Content.Shared.Salvage.Expeditions.Modifiers;
using JetBrains.Annotations;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Client.GameObjects;

namespace Content.Client.Salvage.UI;

[UsedImplicitly]
public sealed class SalvageExpeditionConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private OfferingWindow? _window;

[Dependency] private readonly IConfigurationManager _cfgManager = default!;
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
private SalvageExpeditionWindow? _window;

public SalvageExpeditionConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
}

protected override void Open()
{
base.Open();
_window = new OfferingWindow();
_window.Title = Loc.GetString("salvage-expedition-window-title");
_window = new SalvageExpeditionWindow();
_window.ClaimMission += index =>
{
SendMessage(new ClaimSalvageMessage()
{
Index = index,
});
};
_window.OnClose += Close;
_window?.OpenCenteredLeft();
}
Expand All @@ -47,133 +40,9 @@ protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is not SalvageExpeditionConsoleState current || _window == null)
if (state is not SalvageExpeditionConsoleState current)
return;

_window.Progression = null;
_window.Cooldown = TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionCooldown));
_window.NextOffer = current.NextOffer;
_window.Claimed = current.Claimed;
_window.ClearOptions();
var salvage = _entManager.System<SalvageSystem>();

for (var i = 0; i < current.Missions.Count; i++)
{
var missionParams = current.Missions[i];

var offering = new OfferingWindowOption();
offering.Title = Loc.GetString($"salvage-expedition-type");

var difficultyId = "Moderate";
var difficultyProto = _protoManager.Index<SalvageDifficultyPrototype>(difficultyId);
// TODO: Selectable difficulty soon.
var mission = salvage.GetMission(difficultyProto, missionParams.Seed);

// Difficulty
// Details
offering.AddContent(new Label()
{
Text = Loc.GetString("salvage-expedition-window-difficulty")
});

var difficultyColor = difficultyProto.Color;

offering.AddContent(new Label
{
Text = Loc.GetString("salvage-expedition-difficulty-Moderate"),
FontColorOverride = difficultyColor,
HorizontalAlignment = Control.HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});

offering.AddContent(new Label
{
Text = Loc.GetString("salvage-expedition-difficulty-players"),
HorizontalAlignment = Control.HAlignment.Left,
});

offering.AddContent(new Label
{
Text = difficultyProto.RecommendedPlayers.ToString(),
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = Control.HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});

// Details
offering.AddContent(new Label
{
Text = Loc.GetString("salvage-expedition-window-hostiles")
});

var faction = mission.Faction;

offering.AddContent(new Label
{
Text = faction,
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = Control.HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});

// Duration
offering.AddContent(new Label
{
Text = Loc.GetString("salvage-expedition-window-duration")
});

offering.AddContent(new Label
{
Text = mission.Duration.ToString(),
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = Control.HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});

// Biome
offering.AddContent(new Label
{
Text = Loc.GetString("salvage-expedition-window-biome")
});

var biome = mission.Biome;

offering.AddContent(new Label
{
Text = Loc.GetString(_protoManager.Index<SalvageBiomeModPrototype>(biome).ID),
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = Control.HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});

// Modifiers
offering.AddContent(new Label
{
Text = Loc.GetString("salvage-expedition-window-modifiers")
});

var mods = mission.Modifiers;

offering.AddContent(new Label
{
Text = string.Join("\n", mods.Select(o => "- " + o)).TrimEnd(),
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = Control.HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});

offering.ClaimPressed += args =>
{
SendMessage(new ClaimSalvageMessage()
{
Index = missionParams.Index,
});
};

offering.Claimed = current.ActiveMission == missionParams.Index;
offering.Disabled = current.Claimed || current.Cooldown;

_window.AddOption(offering);
}
_window?.UpdateState(current);
}
}
23 changes: 23 additions & 0 deletions Content.Client/Salvage/UI/SalvageExpeditionWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="{Loc 'salvage-expedition-window-title'}"
MinSize="800 360">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
<Label Name="NextOfferLabel"
Text="{Loc 'salvage-expedition-window-next'}"
Margin="5"></Label>
<ProgressBar Name="NextOfferBar"
HorizontalExpand="True"
MinValue="0"
MaxValue="1"
SetHeight="25"/>
<Label Name="NextOfferText" Text="0.00"
Margin="5"/>
</BoxContainer>
<controls:HLine Color="#404040" Thickness="2" Margin="0 5 0 5"/>
<BoxContainer Name="Container"
Orientation="Horizontal"
Margin="5 0 5 0"/>
</BoxContainer>
</controls:FancyWindow>
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void Populate(List<VendingMachineInventoryEntry> inventory, float priceMo

if (prototype != null && prototype.TryGetComponent<SolutionContainerManagerComponent>(out var priceSolutions))
{
foreach (var solution in priceSolutions.Solutions.Values)
foreach (var solution in priceSolutions.Solutions!.Values)
{
foreach (var (reagent, quantity) in solution.Contents)
{
Expand Down
2 changes: 0 additions & 2 deletions Content.Server/Body/Components/RespiratorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ public sealed partial class RespiratorComponent : Component
[DataField("CPRSound")]
public SoundSpecifier CPRSound { get; set; } = new SoundPathSpecifier("/Audio/Effects/CPR.ogg");

public IPlayingAudioStream? CPRPlayingStream;

public bool IsReceivingCPR = false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Body/Systems/RespiratorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using JetBrains.Annotations;
using Robust.Shared.Timing;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Random;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
Expand Down Expand Up @@ -237,7 +238,6 @@ private void OnApplyMetabolicMultiplier(EntityUid uid, RespiratorComponent compo

private void OnDoAfter(EntityUid uid, RespiratorComponent component, DoAfterEvent args)
{
component.CPRPlayingStream?.Stop();
component.IsReceivingCPR = false;

if (args.Handled || args.Cancelled)
Expand Down Expand Up @@ -292,7 +292,7 @@ public void AttemptCPR(EntityUid uid, RespiratorComponent component, EntityUid u
_popupSystem.PopupEntity(Loc.GetString("cpr-start-second-person-patient", ("user", Identity.Entity(user, EntityManager))), uid, uid, Shared.Popups.PopupType.Medium);

component.IsReceivingCPR = true;
component.CPRPlayingStream = _audio.PlayPvs(component.CPRSound, uid, audioParams: AudioParams.Default.WithVolume(-3f));
//_audio.PlayPvs(component.CPRSound, uid, audioParams: AudioParams.Default.WithVolume(-3f));

var args = new DoAfterArgs(EntityManager, user, Math.Min(component.CycleDelay * 2, 6f), new CPRDoAfterEvent(), uid, target: uid)
{
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Botany/Systems/MutationSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private void MutateGasses(ref Dictionary<Gas, float> gasses, float min, float ma
Gas.Nitrogen,
Gas.CarbonDioxide,
Gas.NitrousOxide,
Gas.Miasma,
Gas.Ammonia,
Gas.Plasma,
Gas.Tritium,
Gas.WaterVapor,
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Cargo/Systems/PricingSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using Content.Server.Administration;
using Content.Server.Body.Systems;
using Content.Server.Cargo.Components;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Audio.Systems;

namespace Content.Server.Chemistry.EntitySystems
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void SetFireMode(EntityUid uid, EnergyGunComponent component, EnergyWeap

if (TryComp<AppearanceComponent>(uid, out var _) && TryComp<ItemComponent>(uid, out var item))
{
_item.SetHeldPrefix(uid, component.CurrentFireMode.State, item);
_item.SetHeldPrefix(uid, component.CurrentFireMode.State, component: item);
switch (component.CurrentFireMode.State)
{
case "disabler":
Expand Down
13 changes: 0 additions & 13 deletions Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -989,19 +989,6 @@ private void SpawnOperatives(int spawnCount, List<ICommonSession> sessions, bool
}
}

/// <summary>
/// Display a greeting message and play a sound for a nukie
/// </summary>
private void NotifyNukie(ICommonSession session, NukeOperativeComponent nukeop, NukeopsRuleComponent nukeopsRule)
{
if (nukeopsRule.TargetStation is not { } station)
return;

_chatManager.DispatchServerMessage(session, Loc.GetString("nukeops-welcome", ("station", station), ("name", nukeopsRule.OperationName)));
_audio.PlayGlobal(nukeop.GreetSoundNotification, session);
}


private void SpawnOperativesForGhostRoles(EntityUid uid, NukeopsRuleComponent? component = null)
{
if (!Resolve(uid, ref component))
Expand Down
11 changes: 6 additions & 5 deletions Content.Server/Interaction/InteractionPopupSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public sealed class InteractionPopupSystem : EntitySystem
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -82,19 +83,19 @@ public void TryHug(EntityUid uid, InteractionPopupComponent component, EntityUid
if (component.MessagePerceivedByOthers != null)
{
var msgOthers = Loc.GetString(component.MessagePerceivedByOthers,
("user", Identity.Entity(args.User, EntityManager)), ("target", Identity.Entity(uid, EntityManager)));
_popupSystem.PopupEntity(msg, uid, args.User);
_popupSystem.PopupEntity(msgOthers, uid, Filter.PvsExcept(args.User, entityManager: EntityManager), true);
("user", Identity.Entity(user, EntityManager)), ("target", Identity.Entity(uid, EntityManager)));
_popupSystem.PopupEntity(msg, uid, user);
_popupSystem.PopupEntity(msgOthers, uid, Filter.PvsExcept(user, entityManager: EntityManager), true);
}
else
_popupSystem.PopupEntity(msg, uid, user); //play only for the initiating entity.

if (sfx is not null) //not all cases will have sound.
{
if (component.SoundPerceivedByOthers)
_audio.PlayPvs(sfx, args.Target); //play for everyone in range
_audio.PlayPvs(sfx, uid); //play for everyone in range
else
_audio.PlayEntity(sfx, Filter.Entities(args.User, args.Target), args.Target, true); //play only for the initiating entity and its target.
_audio.PlayEntity(sfx, Filter.Entities(user, uid), uid, true); //play only for the initiating entity and its target.
}

component.LastInteractTime = curTime;
Expand Down
Loading

0 comments on commit 32ce3c3

Please sign in to comment.