Skip to content

Commit

Permalink
change diff, some locale
Browse files Browse the repository at this point in the history
  • Loading branch information
ReeZer2 committed Dec 27, 2024
1 parent 07ebdc8 commit 9e6bf58
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
/// This handles...
/// </summary>
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<ContractorPortalOnTriggerComponent, StartCollideEvent>(OnEnterPortal);
Expand Down Expand Up @@ -65,11 +64,10 @@ private void OnEnterPortal(Entity<ContractorPortalOnTriggerComponent> 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

Expand Down
36 changes: 22 additions & 14 deletions Content.Server/SS220/Contractor/ContractorServerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ public void GenerateContracts(Entity<ContractorComponent> 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<ContractorWarpPointComponent>();

Expand All @@ -237,26 +237,26 @@ public void GenerateContracts(Entity<ContractorComponent> 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)
Expand All @@ -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<ContractorTargetComponent>(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
}
}
2 changes: 1 addition & 1 deletion Content.Shared/SS220/Contractor/ContractorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}
3 changes: 3 additions & 0 deletions Resources/Locale/ru-RU/ss220/contractor/contractor.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
contractor-uplink-current-reputation = Текущая репутация: {$currentReputation}
contractor-uplink-current-tc = Имеется ТК: {$amountTc}
contractor-uplink-current-contracts-completed = Выполнено контрактов: {$amountContractsCompleted}

0 comments on commit 9e6bf58

Please sign in to comment.