-
-
Notifications
You must be signed in to change notification settings - Fork 87
Добавления для спящего агента и обычного. #1123
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
base: master
Are you sure you want to change the base?
Changes from 6 commits
38c0bdd
eb1c35e
ef37fde
6e0e8d1
66274a4
311a80c
7eb2939
b582ddc
cf8ad8f
7328ea1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| using Robust.Shared.Utility; | ||
| using Content.Shared.Roles.Components; | ||
| using Content.Server._Scp.GameTicking.Rules.Components; // Fire edit | ||
| using Content.Shared.Mind; // Fire edit | ||
|
|
||
| namespace Content.Server.Administration.Systems; | ||
|
|
||
|
|
@@ -355,6 +356,20 @@ private void AddAntagVerbs(GetVerbsEvent<Verb> args) | |
| Act = () => | ||
| { | ||
| _antag.ForceMakeAntag<ChaosSleepSpyRuleComponent>(targetPlayer, DefaultScpSleepChaosSpyRule); | ||
| if (!TryComp<ActorComponent>(args.User, out var actor)) | ||
| return; | ||
|
|
||
| if (!_mindSystem.TryGetMind(args.Target, out var targetMindId, out _)) | ||
| return; | ||
|
EngineerLND marked this conversation as resolved.
|
||
|
|
||
| TryComp<MindComponent>(targetMindId, out var targetMind); | ||
| if (targetMind == null) | ||
| return; | ||
|
Comment on lines
+291
to
+292
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. У тебя функция выше ( |
||
|
|
||
| var targetName = targetMind.CharacterName ?? Name(args.Target); | ||
| _chatManager.DispatchServerMessage(actor.PlayerSession, | ||
| Loc.GetString("admin-verb-result-make-chaos-sleep-spy", | ||
| ("targetName", targetName))); | ||
| }, | ||
| Impact = LogImpact.High, | ||
| Message = Loc.GetString("admin-verb-make-chaos-sleep-spy"), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| using Content.Server._Scp.Objectives.Systems; | ||
|
|
||
| namespace Content.Server._Scp.Objectives.Components; | ||
|
|
||
| [RegisterComponent, Access(typeof(ScpActivateSleepSpyConditionSystem))] | ||
| public sealed partial class ScpActivateSleepSpyConditionComponent : Component | ||
| { | ||
| /// <summary>The sleep spy target that an active Chaos Spy must activate.</summary> | ||
| [ViewVariables] | ||
| public EntityUid? Target; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| using Content.Server._Scp.Objectives.Components; | ||
| using Content.Server.Mind; | ||
| using Content.Server.Objectives.Components; | ||
| using Content.Server.Objectives.Systems; | ||
| using Content.Shared._Scp.Chaos; | ||
| using Content.Shared.Mobs.Systems; | ||
| using Content.Shared.Objectives.Components; | ||
| using Content.Shared.Roles.Jobs; | ||
| using Robust.Shared.Random; | ||
|
|
||
| namespace Content.Server._Scp.Objectives.Systems; | ||
|
|
||
| public sealed class ScpActivateSleepSpyConditionSystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly CodeConditionSystem _condition = default!; | ||
| [Dependency] private readonly MindSystem _mind = default!; | ||
| [Dependency] private readonly MobStateSystem _mobState = default!; | ||
| [Dependency] private readonly SharedJobSystem _job = default!; | ||
| [Dependency] private readonly MetaDataSystem _metaData = default!; | ||
| [Dependency] private readonly IRobustRandom _random = default!; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
|
|
||
| SubscribeLocalEvent<ScpActivateSleepSpyConditionComponent, ObjectiveAssignedEvent>(OnAssigned); | ||
| SubscribeLocalEvent<ScpActivateSleepSpyConditionComponent, ObjectiveAfterAssignEvent>(OnAfterAssign); | ||
| SubscribeLocalEvent<ScpActivateSleepSpyConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress, after: [typeof(CodeConditionSystem)]); | ||
| } | ||
|
|
||
| private void OnAssigned(Entity<ScpActivateSleepSpyConditionComponent> ent, ref ObjectiveAssignedEvent args) | ||
| { | ||
| var candidates = new HashSet<EntityUid>(); | ||
|
|
||
| var query = EntityQueryEnumerator<ChaosSleepSpyMobComponent>(); | ||
| while (query.MoveNext(out var uid, out var comp)) | ||
| { | ||
| if (comp.IsAssigned) | ||
| continue; | ||
|
|
||
| if (!_mobState.IsAlive(uid)) | ||
| continue; | ||
|
|
||
| candidates.Add(uid); | ||
| } | ||
|
|
||
|
|
||
| if (candidates.Count >= 1) | ||
| { | ||
| ent.Comp.Target = _random.Pick(candidates); | ||
|
EngineerLND marked this conversation as resolved.
|
||
| TryComp<ChaosSleepSpyMobComponent>(ent.Comp.Target.Value, out var sleepSpyComp); | ||
| if(sleepSpyComp != null) | ||
| sleepSpyComp.IsAssigned = true; | ||
| } | ||
| else | ||
| args.Cancelled = true; | ||
|
|
||
| } | ||
|
|
||
| private void OnAfterAssign(Entity<ScpActivateSleepSpyConditionComponent> ent, ref ObjectiveAfterAssignEvent args) | ||
| { | ||
|
|
||
| if (ent.Comp.Target is not { } target || Deleted(target)) | ||
| return; | ||
|
Comment on lines
+63
to
+64
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Бессмысленная проверка |
||
|
|
||
| if (!_mind.TryGetMind(target, out var mindId, out _)) | ||
| return; | ||
|
|
||
| if (!_job.MindTryGetJob(mindId, out var jobPrototype)) | ||
| return; | ||
|
|
||
| if (!_job.TryGetDepartment(jobPrototype.ID, out var departmentPrototype)) | ||
| return; | ||
|
|
||
| _metaData.SetEntityName(ent, Loc.GetString("objective-condition-chaos-spy-activate-sleep-spy-title"), args.Meta); | ||
| _metaData.SetEntityDescription(ent, Loc.GetString("objective-condition-chaos-spy-activate-sleep-spy-description", ("department", Loc.GetString(departmentPrototype.Name))), args.Meta); | ||
|
EngineerLND marked this conversation as resolved.
|
||
| } | ||
|
|
||
| private void OnGetProgress(Entity<ScpActivateSleepSpyConditionComponent> ent, ref ObjectiveGetProgressEvent args) | ||
| { | ||
| if (TryComp<CodeConditionComponent>(ent, out var code) && code.Completed) | ||
| { | ||
| args.Progress = 1f; | ||
| return; | ||
| } | ||
|
|
||
| if (HasComp<ChaosSpyMobComponent>(ent.Comp.Target)) | ||
| { | ||
| _condition.SetCompleted((ent.Owner, code), true); | ||
| args.Progress = 1f; | ||
| return; | ||
| } | ||
|
|
||
| args.Progress = 0f; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| using Robust.Shared.GameStates; | ||
|
|
||
| namespace Content.Shared._Scp.Chaos; | ||
|
|
||
| [RegisterComponent, NetworkedComponent] | ||
| public sealed partial class ChaosSpyMobComponent : Component; | ||
|
EngineerLND marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| admin-verb-make-chaos-raider = Make the target into a Chaos Raider | ||
| admin-verb-make-chaos-spy = Make the target into a Chaos Spy | ||
|
|
||
| admin-verb-make-chaos-sleep-spy = Make the target into a Chaos Sleep Spy | ||
| admin-verb-text-make-chaos-raider = Make Chaos Raider | ||
|
|
||
| admin-verb-text-make-chaos-spy = Make Chaos Spy | ||
| admin-verb-text-make-chaos-sleep-spy = Make Chaos Sleep Spy | ||
| admin-verb-text-make-chaos-sleep-spy = Make Chaos Sleep Spy | ||
| admin-verb-result-make-chaos-sleep-spy = Player "{$targetName}" is now a sleeper agent of the Chaos Insurgency. An objective to activate them will be given to a random active spy. | ||
|
EngineerLND marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| objective-condition-chaos-spy-activate-sleep-spy-title = Activate the sleeper agent. | ||
| objective-condition-chaos-spy-activate-sleep-spy-description = Find and activate the sleeper agent in the "{$department}" department. Do this as discreetly as possible. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| objective-condition-chaos-spy-activate-sleep-spy-title = Активируйте cпящего агента. | ||
|
EngineerLND marked this conversation as resolved.
|
||
| objective-condition-chaos-spy-activate-sleep-spy-description = Найдите и активируйте спящего агента из отдела "{$department}". Сделайте это как можно незаметнее. | ||
Uh oh!
There was an error while loading. Please reload this page.