diff --git a/Content.Server/SS220/Contractor/ContractorPortalServerSystem.cs b/Content.Server/SS220/Contractor/ContractorPortalServerSystem.cs
index ed28854282c9d8..6e0fad0b746273 100644
--- a/Content.Server/SS220/Contractor/ContractorPortalServerSystem.cs
+++ b/Content.Server/SS220/Contractor/ContractorPortalServerSystem.cs
@@ -5,9 +5,6 @@
namespace Content.Server.SS220.Contractor;
-///
-/// This handles...
-///
public sealed class ContractorPortalServerSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
@@ -21,11 +18,14 @@ public override void Initialize()
SubscribeLocalEvent(OnEnterPortal);
}
+ ///
+ /// This is used for what doing when player enter portal
+ ///
private void OnEnterPortal(Entity ent, ref StartCollideEvent args)
{
if (!TryComp(args.OtherEntity, out var targetComponent))
{
- _popup.PopupClient("Портал недоступен для вас", args.OtherEntity, PopupType.Medium);
+ _popup.PopupClient(Loc.GetString("contractor-portal-for-non-target"), args.OtherEntity, PopupType.Medium);
return;
}
@@ -56,7 +56,7 @@ private void OnEnterPortal(Entity ent, ref S
if (needsPortalEntity != args.OurEntity)
{
- _popup.PopupClient("Этот портал предназначен не для этой цели", args.OtherEntity, PopupType.Medium);
+ _popup.PopupClient(Loc.GetString("contractor-portal-for-another-target"), args.OtherEntity, PopupType.Medium);
return;
}
@@ -67,9 +67,10 @@ private void OnEnterPortal(Entity ent, ref S
_uiSystem.ServerSendUiMessage(GetEntity(contractorComponent.PdaEntity)!.Value, ContractorPdaKey.Key, new ContractorUpdateStatsMessage());
_uiSystem.ServerSendUiMessage(GetEntity(contractorComponent.PdaEntity)!.Value, ContractorPdaKey.Key, new ContractorCompletedContractMessage());
- _contractorServer.GenerateContracts((contractorEntity, contractorComponent));
+ _contractorServer.GenerateContracts((contractorEntity, contractorComponent)); // generate new contracts
- _transformSystem.SetCoordinates(args.OtherEntity, Transform(contractorEntity).Coordinates); // tp target to other map in future
+ // TODO: create new warp point for another map (tajpan???)
+ _transformSystem.SetCoordinates(args.OtherEntity, Transform(contractorEntity).Coordinates);
Dirty(contractorPdaEntity, contractorPdaComponent);
Dirty(contractorEntity, contractorComponent);
diff --git a/Content.Server/SS220/Contractor/ContractorServerSystem.cs b/Content.Server/SS220/Contractor/ContractorServerSystem.cs
index ac13187fc2eb3c..b81b1cd91b3aeb 100644
--- a/Content.Server/SS220/Contractor/ContractorServerSystem.cs
+++ b/Content.Server/SS220/Contractor/ContractorServerSystem.cs
@@ -75,11 +75,17 @@ public override void Update(float frameTime)
}
}
+ ///
+ /// Generate contracts on server, once time while called CompInit event
+ ///
private void OnContractorCompInit(Entity ent, ref ComponentInit ev)
{
GenerateContracts(ent);
}
+ ///
+ /// Handle open portal event
+ ///
private void OnOpenPortalEvent(Entity ent, ref OpenPortalContractorEvent args)
{
if (!TryComp(GetEntity(ent.Comp.CurrentContractEntity), out var target))
@@ -97,6 +103,9 @@ private void OnOpenPortalEvent(Entity ent, ref OpenPortalCo
}
//TODO server and checks
+ ///
+ /// Raised when clicked on position button on pda
+ ///
private void OnNewContractAccepted(Entity ent, ref ContractorNewContractAcceptedMessage ev)
{
if (!TryComp(ev.Actor, out var contractorComponent))
@@ -110,9 +119,7 @@ private void OnNewContractAccepted(Entity ent, ref Contr
EnsureComp(GetEntity(ev.ContractEntity), out var target);
- //Only for test
- /*
- if (target.AmountTc > 8)
+ if (target.AmountTc > 8 || ev.TcReward > 8)
{
_adminLogger.Add(
LogType.Action,
@@ -121,7 +128,6 @@ private void OnNewContractAccepted(Entity ent, ref Contr
return;
}
- */
target.PortalPosition = Transform(GetEntity(ev.WarpPointEntity)).Coordinates;
target.AmountTc = ev.TcReward;
@@ -131,7 +137,7 @@ private void OnNewContractAccepted(Entity ent, ref Contr
contractorComponent.CurrentContractData = ev.ContractData;
contractorComponent.CurrentContractEntity = ev.ContractEntity;
- contractorComponent.PdaEntity = ev.Entity;
+ //contractorComponent.PdaEntity = ev.Entity; //why this shit here?
Dirty(ev.Actor, contractorComponent);
@@ -145,7 +151,9 @@ private void OnNewContractAccepted(Entity ent, ref Contr
HandleContractAccepted(ev.ContractEntity, ev.Actor);
}
- // TODO on server //DONE
+ ///
+ /// Raised when clicked on execute button, then doAfter, then open portal.
+ ///
private void OnExecuteContract(Entity ent, ref ContractorExecutionButtonPressedMessage ev)
{
var entity = GetEntity(ent.Comp.CurrentContractEntity);
@@ -195,6 +203,11 @@ private void OnBuyContractorKit(StoreBuyListingMessage ev)
EnsureComp(ev.Actor);
}
+ ///
+ /// When contractor accepts new contract, remove this contract from other contractors and generate another contract for them
+ ///
+ /// Target, on what contractor accepted
+ /// Contractor, who accepted
public void HandleContractAccepted(NetEntity acceptedPlayer, EntityUid contractor)
{
var query = EntityQueryEnumerator();
@@ -210,7 +223,7 @@ public void HandleContractAccepted(NetEntity acceptedPlayer, EntityUid contracto
if (contractorComp.Contracts.Count >= 5)
continue;
- var newContract = GenerateContractForContractor(uid);
+ var newContract = GenerateContractForContractor((uid, contractorComp));
if (newContract != null)
{
@@ -223,7 +236,12 @@ public void HandleContractAccepted(NetEntity acceptedPlayer, EntityUid contracto
}
}
- private (NetEntity Target, ContractorContract Contract)? GenerateContractForContractor(EntityUid contractor)
+ ///
+ /// Generate a new contract or contracts for contractors, if another contractor has accepted their contract
+ ///
+ ///
+ ///
+ private (NetEntity Target, ContractorContract Contract)? GenerateContractForContractor(Entity contractor)
{
var playerPool = _playerManager.Sessions
.Where(p => p is { Status: SessionStatus.InGame, AttachedEntity: not null })
@@ -242,6 +260,9 @@ public void HandleContractAccepted(NetEntity acceptedPlayer, EntityUid contracto
continue;
}
+ if (contractor.Comp.Contracts.ContainsKey(GetNetEntity(player)))
+ continue;
+
if (!_mindSystem.TryGetMind(player, out var mindId, out _))
continue;
@@ -336,7 +357,7 @@ public void GenerateContracts(Entity ent)
return allLocations;
}
- public bool IsCloseWithPosition(NetEntity playerNet)
+ private bool IsCloseWithPosition(NetEntity playerNet)
{
var player = GetEntity(playerNet);
@@ -357,10 +378,9 @@ public bool IsCloseWithPosition(NetEntity playerNet)
var targetPortalPosition = targetComponent.PortalPosition.Position;
-
var isPlayerCloseToPortal = (playerPosition - targetPortalPosition).Length() < 1f;
var isTargetCloseToPortal = (targetPosition - targetPortalPosition).Length() < 1f;
- return isPlayerCloseToPortal && isTargetCloseToPortal; //tile distance
+ return isPlayerCloseToPortal && isTargetCloseToPortal;
}
}
diff --git a/Content.Shared/SS220/Contractor/ContractorPortalOnTriggerComponent.cs b/Content.Shared/SS220/Contractor/ContractorPortalOnTriggerComponent.cs
index 04b0cc734a2098..96535ab9d3c50d 100644
--- a/Content.Shared/SS220/Contractor/ContractorPortalOnTriggerComponent.cs
+++ b/Content.Shared/SS220/Contractor/ContractorPortalOnTriggerComponent.cs
@@ -3,7 +3,7 @@
namespace Content.Shared.SS220.Contractor;
///
-/// This is used for...
+/// This is used for marking a portal.
///
[RegisterComponent]
[NetworkedComponent]
diff --git a/Content.Shared/SS220/Contractor/ContractorTargetComponent.cs b/Content.Shared/SS220/Contractor/ContractorTargetComponent.cs
index 49198e0854ced8..756aeb4b6db01a 100644
--- a/Content.Shared/SS220/Contractor/ContractorTargetComponent.cs
+++ b/Content.Shared/SS220/Contractor/ContractorTargetComponent.cs
@@ -6,7 +6,7 @@
namespace Content.Shared.SS220.Contractor;
///
-/// This is used for...
+/// This is used for marking target for contractor.
///
[RegisterComponent]
[NetworkedComponent]
diff --git a/Content.Shared/SS220/Contractor/SharedContractorItemPrototype.cs b/Content.Shared/SS220/Contractor/SharedContractorItemPrototype.cs
index e607ae02c36c53..257ce1b1e8d7f9 100644
--- a/Content.Shared/SS220/Contractor/SharedContractorItemPrototype.cs
+++ b/Content.Shared/SS220/Contractor/SharedContractorItemPrototype.cs
@@ -5,7 +5,7 @@
namespace Content.Shared.SS220.Contractor;
///
-/// This is a prototype for...
+/// This is a prototype for contractor items in uplink.
///
[Serializable, NetSerializable, Prototype("contractorItems")]
public sealed partial class SharedContractorItemPrototype : IPrototype
diff --git a/Content.Shared/SS220/Contractor/SharedContractorSystem.cs b/Content.Shared/SS220/Contractor/SharedContractorSystem.cs
index 5c7ff18f4e582a..6c08de656a0ecf 100644
--- a/Content.Shared/SS220/Contractor/SharedContractorSystem.cs
+++ b/Content.Shared/SS220/Contractor/SharedContractorSystem.cs
@@ -13,12 +13,17 @@ public abstract class SharedContractorSystem : EntitySystem
public override void Initialize()
{
- SubscribeLocalEvent(OnContractorPdaMapInit);
+ SubscribeLocalEvent(OnContractorPdaCompInit);
SubscribeLocalEvent(OnOpenUI);
SubscribeLocalEvent(OnBuyItem);
}
- private void OnContractorPdaMapInit(Entity ent, ref ComponentInit args)
+ ///
+ /// On CompInit pda generate available items
+ ///
+ /// Entity pda
+ /// Event
+ private void OnContractorPdaCompInit(Entity ent, ref ComponentInit args)
{
if (ent.Comp.AvailableItems.Count > 0)
return;
@@ -32,6 +37,10 @@ private void OnContractorPdaMapInit(Entity ent, ref Comp
}
}
+ ///
+ /// Will generate a pda owner once for the person who first opened it
+ ///
+ /// PDA entity
private void OnOpenUI(Entity ent, ref BoundUIOpenedEvent args)
{
if (ent.Comp.PdaOwner != null)
@@ -50,6 +59,9 @@ private void OnOpenUI(Entity ent, ref BoundUIOpenedEvent
Dirty(ent);
}
+ ///
+ /// Raise event for buying an item, but only if buyer is pda owner
+ ///
private void OnBuyItem(Entity ent, ref ContractorHubBuyItemMessage ev)
{
if (!TryComp(ev.Actor, out var contractorComponent))
@@ -72,6 +84,10 @@ private void OnBuyItem(Entity ent, ref ContractorHubBuyI
Dirty(ev.Actor, contractorComponent);
}
+ ///
+ /// Used in bound ui on client, to get contracts for pda
+ ///
+ /// Return dictionary of contracts
public Dictionary? GetContractsForPda(EntityUid contractor, EntityUid pdaEntity)
{
AddContractsToPda(contractor, pdaEntity);
@@ -91,6 +107,9 @@ private void AddContractsToPda(EntityUid contractor, EntityUid pdaEntity)
}
+///
+/// Event for opening a portal
+///
[Serializable, NetSerializable]
public sealed partial class OpenPortalContractorEvent : DoAfterEvent
{
diff --git a/Resources/Locale/ru-RU/ss220/contractor/contractor.ftl b/Resources/Locale/ru-RU/ss220/contractor/contractor.ftl
index 85a1de3f9b65de..7556f4e80e3ebb 100644
--- a/Resources/Locale/ru-RU/ss220/contractor/contractor.ftl
+++ b/Resources/Locale/ru-RU/ss220/contractor/contractor.ftl
@@ -1,3 +1,6 @@
contractor-uplink-current-reputation = Текущая репутация: {$currentReputation}
contractor-uplink-current-tc = Имеется ТК: {$amountTc}
contractor-uplink-current-contracts-completed = Выполнено контрактов: {$amountContractsCompleted}
+
+contractor-portal-for-non-target = Портал недоступен для вас
+contractor-portal-for-another-target = Этот портал предназначен не для этой цели
diff --git a/Resources/Prototypes/SS220/Antags/contractor_items.yml b/Resources/Prototypes/SS220/Antags/contractor_items.yml
index d8a7c6ccc55669..2c2aa0db2f8d2a 100644
--- a/Resources/Prototypes/SS220/Antags/contractor_items.yml
+++ b/Resources/Prototypes/SS220/Antags/contractor_items.yml
@@ -34,7 +34,6 @@
shape:
- 0,0,2,2
- type: Storage
- maxItemSize: Small
grid:
- 0,0,6,4
- type: Sprite