Skip to content

Commit

Permalink
Adds the thingy yeah
Browse files Browse the repository at this point in the history
  • Loading branch information
Ermucat committed Dec 11, 2024
1 parent 434bd54 commit ccdcfc7
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Content.Server/Objectives/Components/TeachAlessonComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Content.Server.Objectives.Systems;

namespace Content.Server.Objectives.Components;

/// <summary>
/// Requires that a target dies once and only once.
/// Depends on <see cref="TargetObjectiveComponent"/> to function.
/// </summary>
[RegisterComponent, Access(typeof(TeachLessonConditionSystem))]
public sealed partial class TeachLessonConditionComponent : Component;
48 changes: 48 additions & 0 deletions Content.Server/Objectives/Systems/Teachalessonconditionststem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Content.Server.Objectives.Components;
using Content.Shared.GameTicking;
using Content.Shared.Mind;
using Content.Shared.Objectives.Components;

namespace Content.Server.Objectives.Systems;

/// <summary>
/// Handles teach a lesson condition logic, does not assign target.
/// </summary>
public sealed class TeachLessonConditionSystem : EntitySystem
{
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly TargetObjectiveSystem _target = default!;

private readonly List<EntityUid> _wasKilled = [];

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<TeachLessonConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress);
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundEnd);
}

private void OnGetProgress(Entity<TeachLessonConditionComponent> ent, ref ObjectiveGetProgressEvent args)
{
if (!_target.GetTarget(ent, out var target))
return;

args.Progress = GetProgress(target.Value);
}

private float GetProgress(EntityUid target)
{
if (TryComp<MindComponent>(target, out var mind) && mind.OwnedEntity != null && !_mind.IsCharacterDeadIc(mind))
return _wasKilled.Contains(target) ? 1f : 0f;

_wasKilled.Add(target);
return 1f;
}

// Clear the wasKilled list on round end
private void OnRoundEnd(RoundRestartCleanupEvent ev)
{
_wasKilled.Clear();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
objective-condition-teach-person-title = Teach {$targetName}, {CAPITALIZE($job)} a lesson
16 changes: 16 additions & 0 deletions Resources/Prototypes/Objectives/base_objectives.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,19 @@
id: BaseCodeObjective
components:
- type: CodeCondition

#Harmony Base Objective
- type: entity
abstract: true
parent: BaseTargetObjective
id: BaseTeachLessonObjective
components:
- type: Objective
unique: false
icon:
sprite: Objects/Weapons/Melee/fireaxe.rsi
state: icon
- type: ObjectiveBlacklistRequirement
blacklist:
components:
- SocialObjective
1 change: 1 addition & 0 deletions Resources/Prototypes/Objectives/objectiveGroups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
weights:
KillRandomPersonObjective: 1
KillRandomHeadObjective: 0.25
TeachLessonRandomPersonObjective: 1 #Harmony objective

- type: weightedRandom
id: TraitorObjectiveGroupState
Expand Down
14 changes: 14 additions & 0 deletions Resources/Prototypes/Objectives/traitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@
title: objective-condition-kill-person-title
- type: PickRandomPerson

# Harmony Objective
- type: entity
parent: [BaseTraitorObjective, BaseTeachLessonObjective]
id: TeachLessonRandomPersonObjective
description: Kill them, and show everyone we mean business. They only need to die once.
components:
- type: Objective
difficulty: 1.75
unique: false
- type: TargetObjective
title: objective-condition-teach-person-title
- type: PickRandomPerson
- type: TeachLessonCondition

- type: entity
parent: [BaseTraitorObjective, BaseKillObjective]
id: KillRandomHeadObjective
Expand Down

0 comments on commit ccdcfc7

Please sign in to comment.