forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'upstream-merge' into 'arumoon-server'
Upstream fix + minor TG Maps update
Closes #10
See merge request Workbench-Team/space-station-14!122
- Loading branch information
Showing
28 changed files
with
266 additions
and
156 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
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
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
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
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
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
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
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
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
43 changes: 22 additions & 21 deletions
43
Content.Server/Objectives/Conditions/KillRandomPersonCondition.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,34 +1,35 @@ | ||
using System.Linq; | ||
using Content.Server.Mind.Components; | ||
using Content.Server.Objectives.Interfaces; | ||
using Content.Shared.Humanoid; | ||
using Content.Shared.Mobs.Components; | ||
using JetBrains.Annotations; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server.Objectives.Conditions | ||
namespace Content.Server.Objectives.Conditions; | ||
|
||
[DataDefinition] | ||
public sealed class KillRandomPersonCondition : KillPersonCondition | ||
{ | ||
[UsedImplicitly] | ||
[DataDefinition] | ||
public sealed class KillRandomPersonCondition : KillPersonCondition | ||
public override IObjectiveCondition GetAssigned(Mind.Mind mind) | ||
{ | ||
public override IObjectiveCondition GetAssigned(Mind.Mind mind) | ||
var allHumans = new List<Mind.Mind>(); | ||
var query = EntityManager.EntityQuery<MindContainerComponent, HumanoidAppearanceComponent>(true); | ||
foreach (var (mc, _) in query) | ||
{ | ||
var allHumans = EntityManager.EntityQuery<MindContainerComponent>(true).Where(mc => | ||
{ | ||
var entity = mc.Mind?.OwnedEntity; | ||
if (entity == default) | ||
return false; | ||
var entity = mc.Mind?.OwnedEntity; | ||
if (entity == default) | ||
continue; | ||
|
||
return EntityManager.TryGetComponent(entity, out MobStateComponent? mobState) && | ||
MobStateSystem.IsAlive(entity.Value, mobState) && | ||
mc.Mind != mind; | ||
}).Select(mc => mc.Mind).ToList(); | ||
if (EntityManager.TryGetComponent(entity, out MobStateComponent? mobState) && | ||
MobStateSystem.IsAlive(entity.Value, mobState) && | ||
mc.Mind != mind && mc.Mind != null) | ||
{ | ||
allHumans.Add(mc.Mind); | ||
} | ||
} | ||
|
||
if (allHumans.Count == 0) | ||
return new DieCondition(); // I guess I'll die | ||
if (allHumans.Count == 0) | ||
return new DieCondition(); // I guess I'll die | ||
|
||
return new KillRandomPersonCondition {Target = IoCManager.Resolve<IRobustRandom>().Pick(allHumans)}; | ||
} | ||
return new KillRandomPersonCondition {Target = IoCManager.Resolve<IRobustRandom>().Pick(allHumans)}; | ||
} | ||
} |
Oops, something went wrong.