Refactor minds to be entities with components, make roles components (#19591)
Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
@@ -16,14 +16,12 @@ using Content.Shared.Roles;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Maps;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.GameTicking.Rules;
|
||||
|
||||
@@ -68,15 +66,14 @@ public sealed class PiratesRuleSystem : GameRuleSystem<PiratesRuleComponent>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
List<(double, EntityUid)> mostValuableThefts = new();
|
||||
|
||||
var comp1 = pirates;
|
||||
var finalValue = _pricingSystem.AppraiseGrid(pirates.PirateShip, uid =>
|
||||
{
|
||||
foreach (var mind in comp1.Pirates)
|
||||
foreach (var mindId in comp1.Pirates)
|
||||
{
|
||||
if (mind.CurrentEntity == uid)
|
||||
if (TryComp(mindId, out MindComponent? mind) && mind.CurrentEntity == uid)
|
||||
return false; // Don't appraise the pirates twice, we count them in separately.
|
||||
}
|
||||
|
||||
@@ -92,9 +89,9 @@ public sealed class PiratesRuleSystem : GameRuleSystem<PiratesRuleComponent>
|
||||
mostValuableThefts.Pop();
|
||||
});
|
||||
|
||||
foreach (var mind in pirates.Pirates)
|
||||
foreach (var mindId in pirates.Pirates)
|
||||
{
|
||||
if (mind.CurrentEntity is not null)
|
||||
if (TryComp(mindId, out MindComponent? mind) && mind.CurrentEntity is not null)
|
||||
finalValue += _pricingSystem.GetPrice(mind.CurrentEntity.Value);
|
||||
}
|
||||
|
||||
@@ -119,7 +116,10 @@ public sealed class PiratesRuleSystem : GameRuleSystem<PiratesRuleComponent>
|
||||
ev.AddLine(Loc.GetString("pirates-list-start"));
|
||||
foreach (var pirate in pirates.Pirates)
|
||||
{
|
||||
ev.AddLine($"- {pirate.CharacterName} ({pirate.Session?.Name})");
|
||||
if (TryComp(pirate, out MindComponent? mind))
|
||||
{
|
||||
ev.AddLine($"- {mind.CharacterName} ({mind.Session?.Name})");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -239,7 +239,7 @@ public sealed class PiratesRuleSystem : GameRuleSystem<PiratesRuleComponent>
|
||||
}
|
||||
|
||||
//Forcing one player to be a pirate.
|
||||
public void MakePirate(Mind.Mind mind)
|
||||
public void MakePirate(EntityUid mindId, MindComponent mind)
|
||||
{
|
||||
if (!mind.OwnedEntity.HasValue)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user