forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ninja targets update #2148
Open
Alwayswannahunt
wants to merge
11
commits into
SerbiaStrong-220:master
Choose a base branch
from
Alwayswannahunt:ninja-targets
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Ninja targets update #2148
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f06e4f8
InitCommit
Alwayswannahunt cf2113a
AddedObjectives
Alwayswannahunt 3075161
WhereMyModsuit
Alwayswannahunt bb5ffab
OnceIWasToldThathNoRulesInCommitsMessageAmIRight
Alwayswannahunt 014661c
TrackerFixtures
Alwayswannahunt eb380f7
FixTestAndObjectivesAnd
Alwayswannahunt 065c8dc
Merge branch 'master' of https://github.com/Alwayswannahunt/space-sta…
Alwayswannahunt d482b13
UpstreamMoment
Alwayswannahunt 44a8d30
UpstreamMomentNumberTwo
Alwayswannahunt 5a3d6c9
Merge branch 'master' of https://github.com/Alwayswannahunt/space-sta…
Alwayswannahunt e419f85
m-and-fixes
Alwayswannahunt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
27 changes: 27 additions & 0 deletions
27
Content.Server/SS220/CriminalRecords/CriminalRecordsEvent.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,27 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
|
||
using Content.Shared.SS220.CriminalRecords; | ||
using Content.Shared.StationRecords; | ||
|
||
namespace Content.Server.SS220.CriminalRecords; | ||
|
||
public abstract class CriminalStatusEvent(EntityUid? sender, StationRecordKey key, ref CriminalRecord currentCriminalRecord) | ||
{ | ||
public EntityUid? Sender { get; } = sender; | ||
public StationRecordKey Key { get; } = key; | ||
public CriminalRecord CurrentCriminalRecord { get; } = currentCriminalRecord; | ||
} | ||
|
||
/// <summary> | ||
/// Just Look to its name | ||
/// </summary> | ||
public sealed class CriminalStatusAdded(EntityUid? sender, StationRecordKey key, ref CriminalRecord criminalRecord) | ||
: CriminalStatusEvent(sender, key, ref criminalRecord) | ||
{ } | ||
|
||
/// <summary> | ||
/// Just Look to its name | ||
/// </summary> | ||
public sealed class CriminalStatusDeleted(EntityUid? sender, StationRecordKey key, ref CriminalRecord criminalRecord) | ||
: CriminalStatusEvent(sender, key, ref criminalRecord) | ||
{ } |
14 changes: 14 additions & 0 deletions
14
Content.Server/SS220/Objectives/Components/FramePersonConditionComponent.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,14 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
|
||
using Content.Server.SS220.Trackers.Components; | ||
|
||
namespace Content.Server.SS220.Objectives.Components; | ||
|
||
[RegisterComponent] | ||
public sealed partial class FramePersonConditionComponent : Component | ||
{ | ||
[DataField(required: true)] | ||
public CriminalStatusTrackerSpecifier CriminalStatusSpecifier = new(); | ||
|
||
public bool ObjectiveIsDone = false; | ||
} |
46 changes: 46 additions & 0 deletions
46
Content.Server/SS220/Objectives/Components/IntimidatePersonConditionComponent.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,46 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
|
||
using Content.Server.SS220.Trackers.Components; | ||
|
||
namespace Content.Server.SS220.Objectives.Components; | ||
|
||
[RegisterComponent] | ||
public sealed partial class IntimidatePersonConditionComponent : Component | ||
{ | ||
[DataField(required: true)] | ||
public DamageTrackerSpecifier DamageTrackerSpecifier = new(); | ||
|
||
[ViewVariables(VVAccess.ReadWrite)] | ||
public EntityUid TargetMob; | ||
|
||
[ViewVariables(VVAccess.ReadWrite)] | ||
public bool ObjectiveIsDone = false; | ||
|
||
public IntimidatePersonDescriptionType DescriptionType; | ||
// Descriptions comes to help player differ done object from one which isn't. | ||
|
||
/// <summary> | ||
/// Description will be applied at start. No params in it | ||
/// </summary> | ||
[DataField(required: true)] | ||
public string? StartDescription; | ||
|
||
/// <summary> | ||
/// Description will be applied when objective is done. No params in it | ||
/// </summary> | ||
[DataField(required: true)] | ||
public string? SuccessDescription; | ||
|
||
/// <summary> | ||
/// Description will be applied when objective is done. No params in it | ||
/// </summary> | ||
[DataField(required: true)] | ||
public string? SSDDescription; | ||
} | ||
|
||
public enum IntimidatePersonDescriptionType | ||
{ | ||
Start = 0, | ||
Success, | ||
SSD | ||
} |
140 changes: 140 additions & 0 deletions
140
Content.Server/SS220/Objectives/Systems/FramePersonConditionSystem.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,140 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
using Content.Server.Access.Systems; | ||
using Content.Server.Mind; | ||
using Content.Server.Objectives.Components; | ||
using Content.Server.Objectives.Systems; | ||
using Content.Server.SS220.Objectives.Components; | ||
using Content.Server.SS220.Trackers.Components; | ||
using Content.Shared.Mind; | ||
using Content.Shared.Objectives.Components; | ||
using Content.Shared.Roles; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server.SS220.Objectives.Systems; | ||
|
||
public sealed class FramePersonConditionSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IdCardSystem _idCard = default!; | ||
[Dependency] private readonly MindSystem _mind = default!; | ||
[Dependency] private readonly IPrototypeManager _prototype = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly SharedRoleSystem _roleSystem = default!; | ||
[Dependency] private readonly TargetObjectiveSystem _targetObjective = default!; | ||
|
||
/// <summary> | ||
/// We use this to determine which jobs have legalImmunity... Wait for MRP PR for a special flag. | ||
/// </summary> | ||
private readonly string _legalImmunitySupervisors = "job-supervisors-centcom"; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<FramePersonConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress); | ||
|
||
SubscribeLocalEvent<FramePersonConditionComponent, ObjectiveAssignedEvent>(OnPersonAssigned); | ||
} | ||
|
||
private void OnGetProgress(Entity<FramePersonConditionComponent> entity, ref ObjectiveGetProgressEvent args) | ||
{ | ||
if (!_targetObjective.GetTarget(entity.Owner, out var target)) | ||
return; | ||
|
||
if (entity.Comp.ObjectiveIsDone) | ||
{ | ||
args.Progress = 1f; | ||
return; | ||
} | ||
|
||
if (!TryComp<MindComponent>(target, out var mindComponent) | ||
|| mindComponent.OriginalOwnedEntity == null) | ||
{ | ||
Log.Error("while getting progress: target dont have a mindComponent or originalEntity is null"); | ||
args.Progress = 1f; | ||
return; | ||
} | ||
|
||
args.Progress = GetProgress(GetEntity(mindComponent.OriginalOwnedEntity.Value)); | ||
if (args.Progress >= 1f) | ||
entity.Comp.ObjectiveIsDone = true; | ||
} | ||
|
||
private void OnPersonAssigned(Entity<FramePersonConditionComponent> entity, ref ObjectiveAssignedEvent args) | ||
{ | ||
args.Cancelled = !(TryPickRandomPerson(entity.Owner, args.MindId, out var target) | ||
&& TryComp<MindComponent>(target, out var mindComponent) | ||
&& mindComponent.OriginalOwnedEntity != null | ||
&& TryTrackIdCardOwner(GetEntity(mindComponent.OriginalOwnedEntity.Value), args.MindId, entity.Comp)); | ||
} | ||
|
||
private bool TryTrackIdCardOwner(EntityUid idCardOwner, EntityUid trackedByMind, FramePersonConditionComponent objective) | ||
{ | ||
if (!_idCard.TryFindIdCard(idCardOwner, out var idCard)) | ||
return false; | ||
|
||
var criminalStatusTracker = AddComp<CriminalStatusTrackerComponent>(idCard); | ||
criminalStatusTracker.CriminalStatusSpecifier = objective.CriminalStatusSpecifier; | ||
criminalStatusTracker.TrackedByMind = trackedByMind; | ||
return true; | ||
} | ||
|
||
private bool TryPickRandomPerson(EntityUid objective, EntityUid objectiveOwnerMind, [NotNullWhen(true)] out EntityUid? picked, List<Type>? blacklist = null) | ||
{ | ||
picked = null; | ||
if (!TryComp<TargetObjectiveComponent>(objective, out var targetObjective)) | ||
return false; | ||
|
||
if (targetObjective.Target != null) | ||
return false; | ||
|
||
var whitelistedPlayers = _mind.GetAliveHumans(objectiveOwnerMind) | ||
.Where(x => CorrectJob(x) && (blacklist == null || !EntityHasAnyComponent(x, blacklist))) | ||
.ToList(); | ||
|
||
if (whitelistedPlayers.Count == 0) | ||
return false; | ||
|
||
picked = _random.Pick(whitelistedPlayers); | ||
_targetObjective.SetTarget(objective, picked.Value, targetObjective); | ||
return true; | ||
} | ||
|
||
private bool EntityHasAnyComponent(EntityUid uid, List<Type> whitelist) | ||
{ | ||
foreach (var type in whitelist) | ||
{ | ||
if (HasComp(uid, type)) | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/// <summary> | ||
/// Checks if that job can be framed. Relays on supervisor cause... no RP in code sry. | ||
/// </summary> | ||
private bool CorrectJob(EntityUid mindUid) | ||
{ | ||
|
||
if (!_roleSystem.MindHasRole<MindRoleComponent>(mindUid, out var role) | ||
|| !role.Value.Comp1.JobPrototype.HasValue) | ||
return false; | ||
|
||
if (_prototype.Index(role!.Value.Comp1.JobPrototype!.Value).Supervisors == _legalImmunitySupervisors) | ||
return false; | ||
|
||
return true; | ||
} | ||
|
||
private float GetProgress(EntityUid target) | ||
{ | ||
if (!_idCard.TryFindIdCard(target, out var idCard) | ||
|| !TryComp<CriminalStatusTrackerComponent>(idCard, out var statusTrackerComponent)) | ||
return 1f; // Uh... hmmm... fuck.... <- maybe we need to change target at that point. Anyways player have no fault of that. | ||
|
||
return statusTrackerComponent.GetProgress(); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Правильный док?