From 35e533b8655f4689cd0e2614387264da959e1442 Mon Sep 17 00:00:00 2001 From: Aviu00 Date: Thu, 11 Jan 2024 09:44:36 +0300 Subject: [PATCH] Fix errors --- .../Administration/Commands/RollCommand.cs | 5 +- .../Body/Components/RespiratorComponent.cs | 2 +- .../Body/Systems/RespiratorSystem.cs | 8 +-- .../Conditions/BuyerBlockForAntagCondition.cs | 20 +++----- .../Conditions/BuyerBlockForMindProtected.cs | 17 +++---- .../Conditions/DonationTierLockCondition.cs | 4 +- .../Store/Systems/StoreSystem.Ui.cs | 2 +- .../Ranged/Systems/GunSystem.Battery.cs | 5 +- .../White/Commands/PoshelnahuiCommand.cs | 4 +- .../White/MeatyOre/MeatyOreStoreSystem.cs | 51 ++++++++----------- .../TwoModeEnergyAmmoProviderComponent.cs | 2 +- .../Ranged/Systems/SharedGunSystem.Battery.cs | 6 +-- .../White/CPR/Events/CPREndedEvent.cs | 18 +------ .../White/MeatyOre/SharedMeatyOre.cs | 2 +- 14 files changed, 56 insertions(+), 90 deletions(-) diff --git a/Content.Server/Administration/Commands/RollCommand.cs b/Content.Server/Administration/Commands/RollCommand.cs index 4b32e9a936..da47304301 100644 --- a/Content.Server/Administration/Commands/RollCommand.cs +++ b/Content.Server/Administration/Commands/RollCommand.cs @@ -1,6 +1,5 @@ using Content.Server.Chat.Managers; using Content.Shared.Administration; -using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Random; @@ -16,7 +15,7 @@ namespace Content.Server.Administration.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not IPlayerSession player) + if (shell.Player == null) { shell.WriteLine("You cannot use this command from the server console."); return; @@ -36,7 +35,7 @@ namespace Content.Server.Administration.Commands var random = IoCManager.Resolve(); var chatManager = IoCManager.Resolve(); - chatManager.DispatchServerAnnouncement($"{player.Name} has thrown the D{maxNum} and the {random.Next(1, maxNum)} rolled."); + chatManager.DispatchServerAnnouncement($"{shell.Player.Name} has thrown the D{maxNum} and the {random.Next(1, maxNum)} rolled."); } } diff --git a/Content.Server/Body/Components/RespiratorComponent.cs b/Content.Server/Body/Components/RespiratorComponent.cs index 8e1d8dbbca..4114d0576a 100644 --- a/Content.Server/Body/Components/RespiratorComponent.cs +++ b/Content.Server/Body/Components/RespiratorComponent.cs @@ -66,7 +66,7 @@ namespace Content.Server.Body.Components [DataField("CPRSound")] public SoundSpecifier CPRSound { get; set; } = new SoundPathSpecifier("/White/Audio/CPR.ogg"); - public IPlayingAudioStream? CPRPlayingStream; + public EntityUid? CPRPlayingStream; public EntityUid? CPRPerformedBy = null; // WD end diff --git a/Content.Server/Body/Systems/RespiratorSystem.cs b/Content.Server/Body/Systems/RespiratorSystem.cs index 6e190927e6..c1d1a11a5b 100644 --- a/Content.Server/Body/Systems/RespiratorSystem.cs +++ b/Content.Server/Body/Systems/RespiratorSystem.cs @@ -291,7 +291,7 @@ namespace Content.Server.Body.Systems private void DoCPR(EntityUid target, RespiratorComponent comp, EntityUid user) { - var doAfterEventArgs = new DoAfterArgs(EntityManager, user, comp.CycleDelay * 4, new CPREndedEvent(user, target), target, target: target) + var doAfterEventArgs = new DoAfterArgs(EntityManager, user, comp.CycleDelay * 4, new CPREndedEvent(), target, target: target) { BreakOnTargetMove = true, BreakOnUserMove = true, @@ -309,7 +309,7 @@ namespace Content.Server.Body.Systems comp.CPRPerformedBy = user; _popupSystem.PopupEntity(Loc.GetString("cpr-started", ("target", Identity.Entity(target, EntityManager)), ("user", Identity.Entity(user, EntityManager))), target, PopupType.Medium); - comp.CPRPlayingStream = _audio.PlayPvs(comp.CPRSound, target, audioParams: AudioParams.Default.WithVolume(-3f).WithLoop(true)); + comp.CPRPlayingStream = _audio.PlayPvs(comp.CPRSound, target, audioParams: AudioParams.Default.WithVolume(-3f).WithLoop(true)).Value.Entity; _adminLogger.Add(LogType.Action, LogImpact.High, $"{ToPrettyString(user):entity} начал произовдить СЛР на {ToPrettyString(target):entity}"); } @@ -321,7 +321,7 @@ namespace Content.Server.Body.Systems if (args.Cancelled || !TryComp(args.Target, out var targetState) || targetState!.CurrentState != MobState.Critical) { - component.CPRPlayingStream?.Stop(); + _audio.Stop(component.CPRPlayingStream); component.CPRPerformedBy = null; _popupSystem.PopupEntity(Loc.GetString("cpr-failed"), args.User, args.User); _adminLogger.Add(LogType.Action, LogImpact.High, $"{ToPrettyString(args.User):entity} не удалось произвести СЛР на {ToPrettyString(args.Target):entity}"); @@ -336,7 +336,7 @@ namespace Content.Server.Body.Systems _adminLogger.Add(LogType.Action, LogImpact.High, $"{ToPrettyString(args.User):entity} произвёл СЛР на {ToPrettyString(args.Target):entity}"); - if (CanCPR(args.Target, component, args.User)) + if (args.Target != null && CanCPR(args.Target.Value, component, args.User)) args.Repeat = true; else component.CPRPerformedBy = null; diff --git a/Content.Server/Store/Conditions/BuyerBlockForAntagCondition.cs b/Content.Server/Store/Conditions/BuyerBlockForAntagCondition.cs index 204fbb3b87..f9d55ee3d0 100644 --- a/Content.Server/Store/Conditions/BuyerBlockForAntagCondition.cs +++ b/Content.Server/Store/Conditions/BuyerBlockForAntagCondition.cs @@ -1,24 +1,18 @@ -using Content.Server.Mind.Components; -using Content.Server.Traitor; +using Content.Server.Mind; +using Content.Server.Roles; using Content.Shared.Store; namespace Content.Server.Store.Conditions; -public sealed class BuyerBlockForAntagCondition : ListingCondition +public sealed partial class BuyerBlockForAntagCondition : ListingCondition { public override bool Condition(ListingConditionArgs args) { var ent = args.EntityManager; - - if (!ent.TryGetComponent(args.Buyer, out var mind) || mind.Mind == null) + var roleSystem = ent.System(); + var mindSystem = ent.System(); + if (!mindSystem.TryGetMind(args.Buyer, out var mindId, out var mind)) return false; - - foreach (var role in mind.Mind.AllRoles) - { - if (role is TraitorRole traitorRole) - return false; - } - - return true; + return !roleSystem.MindIsAntagonist(mindId); } } diff --git a/Content.Server/Store/Conditions/BuyerBlockForMindProtected.cs b/Content.Server/Store/Conditions/BuyerBlockForMindProtected.cs index b364cf56dc..8358827729 100644 --- a/Content.Server/Store/Conditions/BuyerBlockForMindProtected.cs +++ b/Content.Server/Store/Conditions/BuyerBlockForMindProtected.cs @@ -1,21 +1,20 @@ -using Content.Server.Mind.Components; +using Content.Server.Mind; +using Content.Server.Roles.Jobs; using Content.Shared.Store; namespace Content.Server.Store.Conditions; -public sealed class BuyerBlockForMindProtected : ListingCondition +public sealed partial class BuyerBlockForMindProtected : ListingCondition { public override bool Condition(ListingConditionArgs args) { - var buyer = args.Buyer; var ent = args.EntityManager; - - if (!ent.TryGetComponent(buyer, out var mind) || mind.Mind == null) + var roleSystem = ent.System(); + var mindSystem = ent.System(); + if (!mindSystem.TryGetMind(args.Buyer, out var mindId, out var mind)) return false; - - if (mind.Mind.CurrentJob?.CanBeAntag != true) + if (mind.Session == null) return false; - - return true; + return !roleSystem.CanBeAntag(mind.Session); } } diff --git a/Content.Server/Store/Conditions/DonationTierLockCondition.cs b/Content.Server/Store/Conditions/DonationTierLockCondition.cs index 828eb74973..716566bd45 100644 --- a/Content.Server/Store/Conditions/DonationTierLockCondition.cs +++ b/Content.Server/Store/Conditions/DonationTierLockCondition.cs @@ -1,10 +1,10 @@ using Content.Server.White.Sponsors; using Content.Shared.Store; -using Robust.Server.GameObjects; +using Robust.Shared.Player; namespace Content.Server.Store.Conditions; -public sealed class DonationTierLockCondition : ListingCondition +public sealed partial class DonationTierLockCondition : ListingCondition { [DataField("tier", required: true)] public int Tier; diff --git a/Content.Server/Store/Systems/StoreSystem.Ui.cs b/Content.Server/Store/Systems/StoreSystem.Ui.cs index 68e5273fa3..93b921beec 100644 --- a/Content.Server/Store/Systems/StoreSystem.Ui.cs +++ b/Content.Server/Store/Systems/StoreSystem.Ui.cs @@ -227,7 +227,7 @@ public sealed partial class StoreSystem UpdateUserInterface(buyer, uid, component); } - public void CloseUi(EntityUid user, StoreComponent component) + public void CloseSessionUi(EntityUid user, StoreComponent component) { if (!TryComp(user, out var actor)) return; diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.Battery.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.Battery.cs index 0c1e85f24d..35256ad976 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.Battery.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.Battery.cs @@ -6,13 +6,14 @@ using Content.Shared.Interaction.Events; using Content.Shared.Projectiles; using Content.Shared.Weapons.Ranged; using Content.Shared.Weapons.Ranged.Components; +using Robust.Server.Audio; using Robust.Shared.Prototypes; namespace Content.Server.Weapons.Ranged.Systems; public sealed partial class GunSystem { - [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly AudioSystem _audio = default!; protected override void InitializeBattery() { @@ -31,7 +32,7 @@ public sealed partial class GunSystem //TwoModeEnergy SubscribeLocalEvent(OnBatteryStartup); SubscribeLocalEvent(OnBatteryChargeChange); - SubscribeLocalEvent(OnBatteryDamageExamine); + SubscribeLocalEvent(OnBatteryDamageExamine); SubscribeLocalEvent(OnBatteryModeChange); } diff --git a/Content.Server/White/Commands/PoshelnahuiCommand.cs b/Content.Server/White/Commands/PoshelnahuiCommand.cs index 598a6dccaa..067194cfba 100644 --- a/Content.Server/White/Commands/PoshelnahuiCommand.cs +++ b/Content.Server/White/Commands/PoshelnahuiCommand.cs @@ -21,7 +21,7 @@ public sealed class PoshelnahuiCommand : IConsoleCommand } var playerManager = IoCManager.Resolve(); - var players = playerManager.ServerSessions.ToList(); + var players = playerManager.Sessions.ToList(); var player = players.Find(x => x.Name == args[0]); @@ -40,7 +40,7 @@ public sealed class PoshelnahuiCommand : IConsoleCommand if (args.Length == 1) { var playerMgr = IoCManager.Resolve(); - var options = playerMgr.ServerSessions.Select(c => c.Name).OrderBy(c => c).ToArray(); + var options = playerMgr.Sessions.Select(c => c.Name).OrderBy(c => c).ToArray(); return CompletionResult.FromHintOptions(options, "ckey"); } diff --git a/Content.Server/White/MeatyOre/MeatyOreStoreSystem.cs b/Content.Server/White/MeatyOre/MeatyOreStoreSystem.cs index e04227cb94..50e9c847eb 100644 --- a/Content.Server/White/MeatyOre/MeatyOreStoreSystem.cs +++ b/Content.Server/White/MeatyOre/MeatyOreStoreSystem.cs @@ -1,35 +1,28 @@ -using System.Linq; -using Content.Server.Actions; -using Content.Server.Administration.Managers; +using Content.Server.Administration.Managers; using Content.Server.Chat.Managers; using Content.Server.GameTicking.Rules; -using Content.Server.Mind.Components; +using Content.Server.Mind; +using Content.Server.Roles; using Content.Server.Store.Components; using Content.Server.Store.Systems; using Content.Server.White.Sponsors; -using Content.Shared.Actions.ActionTypes; -using Content.Shared.Administration; -using Content.Shared.CCVar; using Content.Shared.FixedPoint; using Content.Shared.GameTicking; using Content.Shared.Humanoid; +using Content.Shared.Mind; using Content.Shared.Mobs; using Content.Shared.Mobs.Components; -using Content.Shared.Nuke; +using Content.Shared.Roles.Jobs; using Content.Shared.Verbs; using Content.Shared.White; using Content.Shared.White.MeatyOre; -using Content.Shared.White.Sponsors; -using Robust.Server.GameObjects; using Robust.Server.GameStates; using Robust.Server.Player; using Robust.Shared.Configuration; -using Robust.Shared.Enums; using Robust.Shared.Map; using Robust.Shared.Network; -using Robust.Shared.Players; +using Robust.Shared.Player; using Robust.Shared.Random; -using Robust.Shared.Utility; namespace Content.Server.White; @@ -37,14 +30,15 @@ public sealed class MeatyOreStoreSystem : EntitySystem { [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly StoreSystem _storeSystem = default!; - [Dependency] private readonly IAdminManager _adminManager = default!; [Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly TraitorRuleSystem _traitorRuleSystem = default!; [Dependency] private readonly IConfigurationManager _configurationManager = default!; [Dependency] private readonly IChatManager _chatManager = default!; [Dependency] private readonly SponsorsManager _sponsorsManager = default!; - [Dependency] private readonly IRobustRandom _robustRandom = default!; - [Dependency] private readonly PVSOverrideSystem _pvsOverrideSystem = default!; + [Dependency] private readonly PvsOverrideSystem _pvsOverrideSystem = default!; + [Dependency] private readonly RoleSystem _roleSystem = default!; + [Dependency] private readonly MindSystem _mindSystem = default!; + [Dependency] private readonly SharedJobSystem _jobSystem = default!; private static readonly string StorePresetPrototype = "StorePresetMeatyOre"; @@ -75,11 +69,11 @@ public sealed class MeatyOreStoreSystem : EntitySystem if(!TryComp(ev.Target, out var state) || state?.CurrentState != MobState.Alive) return; if(!TryGetStore(actorComponent.PlayerSession, out var store)) return; - if(!TryComp(ev.Target, out var targetMind) || !targetMind.HasMind) return; - if (targetMind!.Mind!.AllRoles.Any(x => x.Antagonist)) return; + if(!_mindSystem.TryGetMind(ev.Target, out var mindId, out var mind)) return; + if (_roleSystem.MindIsAntagonist(mindId)) return; - if(targetMind.Mind.CurrentJob?.CanBeAntag != true) return; - if(targetMind.Mind.Session == null) return; + if(mind.Session == null) return; + if(!_jobSystem.CanBeAntag(mind.Session)) return; if (!store.Balance.TryGetValue("MeatyOreCoin", out var currency)) return; @@ -93,7 +87,7 @@ public sealed class MeatyOreStoreSystem : EntitySystem Act = () => { _storeSystem.TryAddCurrency(new Dictionary {{MeatyOreCurrensyPrototype, -10}}, store.Owner, store); - _traitorRuleSystem.MakeTraitor(targetMind.Mind.Session); + _traitorRuleSystem.MakeTraitor(mind.Session); }, Category = VerbCategory.MeatyOre }; @@ -113,7 +107,7 @@ public sealed class MeatyOreStoreSystem : EntitySystem var playerEntity = session.AttachedEntity; if(!playerEntity.HasValue) continue; - _storeSystem.CloseUi(playerEntity.Value, meatyOreStoreData.Value); + _storeSystem.CloseSessionUi(playerEntity.Value, meatyOreStoreData.Value); } } MeatyOrePanelEnabled = newValue; @@ -122,16 +116,15 @@ public sealed class MeatyOreStoreSystem : EntitySystem private void OnAntagPurchase(EntityUid uid, MindComponent component, MeatyTraitorRequestActionEvent args) { - if(component.Mind == null) return; - if(component.Mind.Session == null) return; + if(component.Session == null) return; - _traitorRuleSystem.MakeTraitor(component.Mind?.Session!); + _traitorRuleSystem.MakeTraitor(component.Session!); } private void OnShopRequested(MeatyOreShopRequestEvent msg, EntitySessionEventArgs args) { - var playerSession = args.SenderSession as IPlayerSession; + var playerSession = args.SenderSession; if (!MeatyOrePanelEnabled) { @@ -149,7 +142,7 @@ public sealed class MeatyOreStoreSystem : EntitySystem _storeSystem.ToggleUi(playerEntity.Value, storeComponent.Owner, storeComponent); } - private bool TryGetStore(IPlayerSession session, out StoreComponent store) + private bool TryGetStore(ICommonSession session, out StoreComponent store) { store = null!; @@ -190,8 +183,4 @@ public sealed class MeatyOreStoreSystem : EntitySystem return storeComponent; } - - - - } diff --git a/Content.Shared/Weapons/Ranged/Components/TwoModeEnergyAmmoProviderComponent.cs b/Content.Shared/Weapons/Ranged/Components/TwoModeEnergyAmmoProviderComponent.cs index 5d089287b8..05756e2134 100644 --- a/Content.Shared/Weapons/Ranged/Components/TwoModeEnergyAmmoProviderComponent.cs +++ b/Content.Shared/Weapons/Ranged/Components/TwoModeEnergyAmmoProviderComponent.cs @@ -6,7 +6,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy namespace Content.Shared.Weapons.Ranged.Components; [RegisterComponent, NetworkedComponent] -public sealed class TwoModeEnergyAmmoProviderComponent : BatteryAmmoProviderComponent +public sealed partial class TwoModeEnergyAmmoProviderComponent : BatteryAmmoProviderComponent { [ViewVariables(VVAccess.ReadOnly), DataField("projProto", required: true, customTypeSerializer: typeof(PrototypeIdSerializer))] diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Battery.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Battery.cs index e5902e6189..6d9c4eaf12 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Battery.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Battery.cs @@ -74,13 +74,13 @@ public abstract partial class SharedGunSystem { if (!TryComp(uid, out var appearance)) return; - if (!TryComp(uid, out var item)) + if (!TryComp(uid, out var item)) return; if (component.InStun) - _item.SetHeldPrefix(uid, null, item); + _item.SetHeldPrefix(uid, null, false, item); else - _item.SetHeldPrefix(uid, "laser", item); + _item.SetHeldPrefix(uid, "laser", false, item); Appearance.SetData(uid, AmmoVisuals.InStun, component.InStun, appearance); diff --git a/Content.Shared/White/CPR/Events/CPREndedEvent.cs b/Content.Shared/White/CPR/Events/CPREndedEvent.cs index 18da7c7318..a1c8b08291 100644 --- a/Content.Shared/White/CPR/Events/CPREndedEvent.cs +++ b/Content.Shared/White/CPR/Events/CPREndedEvent.cs @@ -4,23 +4,7 @@ using Robust.Shared.Serialization; namespace Content.Shared.White.CPR.Events; [Serializable, NetSerializable] -public sealed class CPREndedEvent : DoAfterEvent +public sealed partial class CPREndedEvent : DoAfterEvent { - [DataField("user", required: true)] - public readonly EntityUid User = default!; - - [DataField("target", required: true)] - public readonly EntityUid Target = default!; - - private CPREndedEvent() - { - } - - public CPREndedEvent(EntityUid user, EntityUid target) - { - User = user; - Target = target; - } - public override DoAfterEvent Clone() => this; } diff --git a/Content.Shared/White/MeatyOre/SharedMeatyOre.cs b/Content.Shared/White/MeatyOre/SharedMeatyOre.cs index 1265290a91..0ee10e94b4 100644 --- a/Content.Shared/White/MeatyOre/SharedMeatyOre.cs +++ b/Content.Shared/White/MeatyOre/SharedMeatyOre.cs @@ -17,7 +17,7 @@ public sealed class MeatyTraitorRequestActionEvent } [NetworkedComponent, RegisterComponent] -public sealed class IgnorBUIInteractionRangeComponent : Component +public sealed partial class IgnorBUIInteractionRangeComponent : Component { }