forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
39 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 23 additions & 3 deletions
26
Content.Server/SS220/Store/Conditions/BuyTimeForListingCondition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
using Content.Server.Mind; | ||
using Content.Server.Roles; | ||
using Content.Shared.Roles; | ||
using Content.Shared.Store; | ||
using Microsoft.CodeAnalysis.Elfie.Serialization; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Server.SS220.Store.Conditions; | ||
|
||
public sealed partial class BuyTimeForListingCondition : ListingCondition | ||
{ | ||
private IGameTiming _gameTiming; | ||
private MindSystem _mindSystem; | ||
private SharedRoleSystem _role; | ||
|
||
[DataField(required: true)] | ||
public int TimeAmount; | ||
public TimeSpan TimeAmount; | ||
|
||
public override bool Condition(ListingConditionArgs args) | ||
{ | ||
return IoCManager.Resolve<IGameTiming>().CurTime <= TimeSpan.FromSeconds(TimeAmount); //todo fix | ||
_gameTiming = IoCManager.Resolve<IGameTiming>(); | ||
_mindSystem = args.EntityManager.System<MindSystem>(); | ||
_role = args.EntityManager.System<SharedRoleSystem>(); | ||
|
||
_mindSystem.TryGetMind(args.Buyer, out var mind, out _); | ||
|
||
if (!_role.MindHasRole<TraitorRoleComponent>(mind, out var traitorRoleComponent)) | ||
return false; | ||
|
||
var currentTime = _gameTiming.CurTime; | ||
|
||
var creationTime = traitorRoleComponent.Value.Comp2.TimeOfAssignment; | ||
|
||
return currentTime < creationTime + TimeAmount; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters