forked from DeltaV-Station/Delta-v
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add syndicate recruiter midround event (DeltaV-Station#1345)
* add SignAttemptEvent and minor signature refactor * add recruiter pen * add the recruiter ship * add recruiter antag and event * fixes * real * bad popup spam * more fix * fix blood visual maybe * fix greentext * more fixy * fix fill state not being coloured * give btamp instead of paper in pocket 2 * f * brighter filled state * fix greentext * fix error on spawn * pro * prevent using a syringe to inject anything into the pen * update stuff after upstream merge --------- Signed-off-by: deltanedas <[email protected]> Co-authored-by: deltanedas <@deltanedas:kde.org>
- Loading branch information
1 parent
e47d912
commit 4237fc9
Showing
24 changed files
with
1,183 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using Content.Shared.DeltaV.Recruiter; | ||
|
||
namespace Content.Client.DeltaV.Recruiter; | ||
|
||
public sealed class RecruiterPenSystem : SharedRecruiterPenSystem; |
15 changes: 15 additions & 0 deletions
15
Content.Server/DeltaV/Objectives/Components/RecruitingConditionComponent.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Content.Server.Objectives.Systems; | ||
using Content.Shared.DeltaV.Recruiter; | ||
|
||
namespace Content.Server.Objectives.Components; | ||
|
||
/// <summary> | ||
/// Objective condition that requires the recruiter's pen to be used by a number of people to sign paper. | ||
/// Requires <see cref="NumberObjectiveComponent"/> to function. | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(RecruitingConditionSystem), typeof(SharedRecruiterPenSystem))] | ||
public sealed partial class RecruitingConditionComponent : Component | ||
{ | ||
[DataField] | ||
public int Recruited; | ||
} |
30 changes: 30 additions & 0 deletions
30
Content.Server/DeltaV/Objectives/Systems/RecruitingConditionSystem.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Content.Server.Objectives.Components; | ||
using Content.Shared.Objectives.Components; | ||
|
||
namespace Content.Server.Objectives.Systems; | ||
|
||
public sealed class RecruitingConditionSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly NumberObjectiveSystem _number = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<RecruitingConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress); | ||
} | ||
|
||
private void OnGetProgress(Entity<RecruitingConditionComponent> ent, ref ObjectiveGetProgressEvent args) | ||
{ | ||
args.Progress = Progress(ent.Comp.Recruited, _number.GetTarget(ent.Owner)); | ||
} | ||
|
||
private float Progress(int recruited, int target) | ||
{ | ||
// prevent divide-by-zero | ||
if (target == 0) | ||
return 1f; | ||
|
||
return MathF.Min(recruited / (float) target, 1f); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Content.Server.Body.Components; | ||
using Content.Server.Forensics; | ||
using Content.Server.Objectives.Components; | ||
using Content.Shared.Chemistry.Components; | ||
using Content.Shared.Chemistry.EntitySystems; | ||
using Content.Shared.DeltaV.Recruiter; | ||
using Content.Shared.Popups; | ||
|
||
namespace Content.Server.DeltaV.Recruiter; | ||
|
||
/// <summary> | ||
/// Handles bloodstream related code since that isn't in shared. | ||
/// </summary> | ||
public sealed class RecruiterPenSystem : SharedRecruiterPenSystem | ||
{ | ||
[Dependency] private readonly ForensicsSystem _forensics = default!; | ||
[Dependency] private readonly SolutionTransferSystem _transfer = default!; | ||
|
||
protected override void DrawBlood(EntityUid uid, Entity<SolutionComponent> dest, EntityUid user) | ||
{ | ||
// how did you even use this mr plushie... | ||
if (CompOrNull<BloodstreamComponent>(user)?.BloodSolution is not {} blood) | ||
return; | ||
|
||
var desired = dest.Comp.Solution.AvailableVolume; | ||
// TODO: when bloodstream is shared put the transfer in shared so PopupClient is actually used, and this popup isnt needed | ||
if (desired == 0) | ||
{ | ||
Popup.PopupEntity(Loc.GetString("recruiter-pen-prick-full", ("pen", uid)), user, user); | ||
return; | ||
} | ||
|
||
if (_transfer.Transfer(user, user, blood, uid, dest, desired) != desired) | ||
return; | ||
|
||
// this is why you have to keep the pen safe, it has the dna of everyone you recruited! | ||
_forensics.TransferDna(uid, user, canDnaBeCleaned: false); | ||
|
||
Popup.PopupEntity(Loc.GetString("recruiter-pen-pricked", ("pen", uid)), user, user, PopupType.LargeCaution); | ||
} | ||
|
||
protected override void Recruit(Entity<RecruiterPenComponent> ent, EntityUid user) | ||
{ | ||
// only increment count once if 1 person signs multiple papers | ||
if (!ent.Comp.Recruited.Add(user)) | ||
return; | ||
|
||
if (ent.Comp.RecruiterMind is {} mindId && | ||
Mind.TryGetObjectiveComp<RecruitingConditionComponent>(mindId, out var obj, null)) | ||
{ | ||
obj.Recruited++; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Content.Shared.DeltaV.Paper; | ||
|
||
/// <summary> | ||
/// Raised on the pen when trying to sign a paper. | ||
/// If it's cancelled the signature isn't made. | ||
/// </summary> | ||
[ByRefEvent] | ||
public record struct SignAttemptEvent(EntityUid Paper, EntityUid User, bool Cancelled = false); |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Content.Shared.FixedPoint; | ||
using Content.Shared.Whitelist; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared.DeltaV.Recruiter; | ||
|
||
/// <summary> | ||
/// Pen that can be pricked with the user's blood, and requires blood to sign papers. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent, Access(typeof(SharedRecruiterPenSystem))] | ||
[AutoGenerateComponentState] | ||
public sealed partial class RecruiterPenComponent : Component | ||
{ | ||
/// <summary> | ||
/// Solution on the pen to draw blood to and use for signing. | ||
/// </summary> | ||
[DataField] | ||
public string Solution = "blood"; | ||
|
||
/// <summary> | ||
/// Mind of the recruiter this pen belongs to. | ||
/// Used for objective and is set when first picked up. | ||
/// </summary> | ||
[DataField] | ||
public EntityUid? RecruiterMind; | ||
|
||
/// <summary> | ||
/// Lets other clients predict recruiter being bound without knowing who it is. | ||
/// </summary> | ||
[DataField, AutoNetworkedField] | ||
public bool Bound; | ||
|
||
/// <summary> | ||
/// Entities of every person that signed paper with this pen. | ||
/// Used to prevent someone gaming it by signing multiple papers. | ||
/// </summary> | ||
[DataField] | ||
public HashSet<EntityUid> Recruited = new(); | ||
|
||
/// <summary> | ||
/// If the user matches this blacklist they can't use this pen. | ||
/// </summary> | ||
[DataField] | ||
public EntityWhitelist? Blacklist; | ||
|
||
/// <summary> | ||
/// If the user's mind matches this blacklist they can't use this pen. | ||
/// </summary> | ||
[DataField] | ||
public EntityWhitelist? MindBlacklist; | ||
} |
Oops, something went wrong.