diff --git a/Content.Client/SS220/Contractor/UI/ContractorBoundUserInterface.cs b/Content.Client/SS220/Contractor/UI/ContractorBoundUserInterface.cs index 64c9f79811955b..32a87c82b182de 100644 --- a/Content.Client/SS220/Contractor/UI/ContractorBoundUserInterface.cs +++ b/Content.Client/SS220/Contractor/UI/ContractorBoundUserInterface.cs @@ -106,9 +106,12 @@ private void UpdateStats() if (_contractorComponent == null) return; - _menu.ReputationCountLabel.Text = $"Текущая репутация: " + _contractorComponent.Reputation; - _menu.TcAmountLabel.Text = $"Имеется ТК: " + _contractorComponent.AmountTc; - _menu.ContractsFinishedAmountLabel.Text = $"Выполнено контрактов: " + _contractorComponent.ContractsCompleted; + _menu.ReputationCountLabel.Text = + Loc.GetString("contractor-uplink-current-reputation", ("currentReputation", _contractorComponent.Reputation)); + _menu.TcAmountLabel.Text = + Loc.GetString("contractor-uplink-current-tc", ("amountTc", _contractorComponent.AmountTc)); + _menu.ContractsFinishedAmountLabel.Text = + Loc.GetString("contractor-uplink-current-contracts-completed", ("amountContractsCompleted", _contractorComponent.ContractsCompleted)); } private void UpdateContracts(EntityUid contractor, EntityUid pda) diff --git a/Content.Shared/SS220/Contractor/SharedContractorPortalSystem.cs b/Content.Server/SS220/Contractor/ContractorPortalServerSystem.cs similarity index 81% rename from Content.Shared/SS220/Contractor/SharedContractorPortalSystem.cs rename to Content.Server/SS220/Contractor/ContractorPortalServerSystem.cs index a3eb43968a432e..ed28854282c9d8 100644 --- a/Content.Shared/SS220/Contractor/SharedContractorPortalSystem.cs +++ b/Content.Server/SS220/Contractor/ContractorPortalServerSystem.cs @@ -1,22 +1,21 @@ -using Content.Shared.DoAfter; using Content.Shared.Popups; -using Robust.Shared.Network; +using Content.Shared.SS220.Contractor; using Robust.Shared.Physics.Events; -using Robust.Shared.Serialization; using Robust.Shared.Timing; -namespace Content.Shared.SS220.Contractor; +namespace Content.Server.SS220.Contractor; /// /// This handles... /// -public sealed class SharedContractorPortalSystem : EntitySystem +public sealed class ContractorPortalServerSystem : EntitySystem { [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!; - [Dependency] private readonly INetManager _net = default!; [Dependency] private readonly SharedTransformSystem _transformSystem = default!; [Dependency] private readonly SharedPopupSystem _popup = default!; + [Dependency] private readonly ContractorServerSystem _contractorServer = default!; + public override void Initialize() { SubscribeLocalEvent(OnEnterPortal); @@ -65,11 +64,10 @@ private void OnEnterPortal(Entity ent, ref S contractorComponent.AmountTc += targetComponent.AmountTc; contractorComponent.ContractsCompleted++; - if (_net.IsServer) - { - _uiSystem.ServerSendUiMessage(GetEntity(contractorComponent.PdaEntity)!.Value, ContractorPdaKey.Key, new ContractorUpdateStatsMessage()); - _uiSystem.ServerSendUiMessage(GetEntity(contractorComponent.PdaEntity)!.Value, ContractorPdaKey.Key, new ContractorCompletedContractMessage()); - } + _uiSystem.ServerSendUiMessage(GetEntity(contractorComponent.PdaEntity)!.Value, ContractorPdaKey.Key, new ContractorUpdateStatsMessage()); + _uiSystem.ServerSendUiMessage(GetEntity(contractorComponent.PdaEntity)!.Value, ContractorPdaKey.Key, new ContractorCompletedContractMessage()); + + _contractorServer.GenerateContracts((contractorEntity, contractorComponent)); _transformSystem.SetCoordinates(args.OtherEntity, Transform(contractorEntity).Coordinates); // tp target to other map in future diff --git a/Content.Server/SS220/Contractor/ContractorServerSystem.cs b/Content.Server/SS220/Contractor/ContractorServerSystem.cs index 267b45cda473a6..3e0085deba2b74 100644 --- a/Content.Server/SS220/Contractor/ContractorServerSystem.cs +++ b/Content.Server/SS220/Contractor/ContractorServerSystem.cs @@ -226,9 +226,9 @@ public void GenerateContracts(Entity ent) } } - private List<(NetEntity Uid, string Location, FixedPoint2 TcReward, string Difficulty)> GeneratePositionsForTarget() + private List<(NetEntity Uid, string Location, FixedPoint2 TcReward, Difficulty Difficulty)> GeneratePositionsForTarget() { - List<(NetEntity Uid, string Location, FixedPoint2 TcReward, string Difficulty)> allLocations = []; + var allLocations = new List<(NetEntity Uid, string Location, FixedPoint2 TcReward, Difficulty Difficulty)>(); var query = EntityQueryEnumerator(); @@ -237,26 +237,26 @@ public void GenerateContracts(Entity ent) allLocations.Add((GetNetEntity(uid), comp.LocationName, comp.AmountTc, comp.Difficulty)); } - var easyLocations = allLocations.Where(loc => loc.Difficulty == "Easy").ToList(); - var mediumLocations = allLocations.Where(loc => loc.Difficulty == "Medium").ToList(); - var hardLocations = allLocations.Where(loc => loc.Difficulty == "Hard").ToList(); + var easyLocations = allLocations.Where(loc => loc.Difficulty == Difficulty.Easy).ToList(); + var mediumLocations = allLocations.Where(loc => loc.Difficulty == Difficulty.Medium).ToList(); + var hardLocations = allLocations.Where(loc => loc.Difficulty == Difficulty.Hard).ToList(); _random.Shuffle(easyLocations); _random.Shuffle(mediumLocations); _random.Shuffle(hardLocations); - var result = new List<(NetEntity uid, string Location, FixedPoint2 Value, string Difficulty)>(); + allLocations.Clear(); if (easyLocations.Count > 0) - result.Add(easyLocations[0]); + allLocations.Add(easyLocations[0]); if (mediumLocations.Count > 0) - result.Add(mediumLocations[0]); + allLocations.Add(mediumLocations[0]); if (hardLocations.Count > 0) - result.Add(hardLocations[0]); + allLocations.Add(hardLocations[0]); - return result; + return allLocations; } public bool IsCloseWithPosition(NetEntity playerNet) @@ -270,12 +270,20 @@ public bool IsCloseWithPosition(NetEntity playerNet) contractorComponent.CurrentContractData is null) return false; - var playerPosition = GetNetCoordinates(Transform(player).Coordinates).Position; + var targetEntity = GetEntity(contractorComponent.CurrentContractEntity); + + if (!TryComp(targetEntity, out var targetComponent)) + return false; + + var playerPosition = Transform(player).Coordinates.Position; + var targetPosition = Transform(targetEntity.Value).Coordinates.Position; + + var targetPortalPosition = targetComponent.PortalPosition.Position; - var targetPosition = GetNetCoordinates(Transform(GetEntity(contractorComponent.CurrentContractData!.Value.AmountPositions.First().Uid)).Coordinates).Position; - var distance = (playerPosition - targetPosition).Length(); + var isPlayerCloseToPortal = (playerPosition - targetPortalPosition).Length() < 1f; + var isTargetCloseToPortal = (targetPosition - targetPortalPosition).Length() < 1f; - return distance < 1f; //4 tiles distance + return isPlayerCloseToPortal && isTargetCloseToPortal; //tile distance } } diff --git a/Content.Shared/SS220/Contractor/ContractorComponent.cs b/Content.Shared/SS220/Contractor/ContractorComponent.cs index 51ded923402257..2ea9278139b349 100644 --- a/Content.Shared/SS220/Contractor/ContractorComponent.cs +++ b/Content.Shared/SS220/Contractor/ContractorComponent.cs @@ -48,5 +48,5 @@ public sealed partial class ContractorComponent : Component public struct ContractorContract { public string Job; - public List<(NetEntity Uid, string Location, FixedPoint2 TcReward, string Difficulty)> AmountPositions; + public List<(NetEntity Uid, string Location, FixedPoint2 TcReward, Difficulty Difficulty)> AmountPositions; } diff --git a/Content.Server/SS220/Contractor/ContractorWarpPointComponent.cs b/Content.Shared/SS220/Contractor/ContractorWarpPointComponent.cs similarity index 61% rename from Content.Server/SS220/Contractor/ContractorWarpPointComponent.cs rename to Content.Shared/SS220/Contractor/ContractorWarpPointComponent.cs index bc7b4256861ddb..74fa70ceb7d5ff 100644 --- a/Content.Server/SS220/Contractor/ContractorWarpPointComponent.cs +++ b/Content.Shared/SS220/Contractor/ContractorWarpPointComponent.cs @@ -1,6 +1,6 @@ using Content.Shared.FixedPoint; -namespace Content.Server.SS220.Contractor; +namespace Content.Shared.SS220.Contractor; [RegisterComponent] public sealed partial class ContractorWarpPointComponent : Component @@ -12,5 +12,13 @@ public sealed partial class ContractorWarpPointComponent : Component public FixedPoint2 AmountTc; [DataField] - public string Difficulty; + public Difficulty Difficulty; +} + +[Serializable] +public enum Difficulty +{ + Easy, + Medium, + Hard } diff --git a/Resources/Locale/ru-RU/ss220/contractor/contractor.ftl b/Resources/Locale/ru-RU/ss220/contractor/contractor.ftl new file mode 100644 index 00000000000000..85a1de3f9b65de --- /dev/null +++ b/Resources/Locale/ru-RU/ss220/contractor/contractor.ftl @@ -0,0 +1,3 @@ +contractor-uplink-current-reputation = Текущая репутация: {$currentReputation} +contractor-uplink-current-tc = Имеется ТК: {$amountTc} +contractor-uplink-current-contracts-completed = Выполнено контрактов: {$amountContractsCompleted}