Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into death-squad-v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
EstKemran committed Nov 24, 2024
2 parents cfd68e9 + 0f0ea4c commit dae6e59
Show file tree
Hide file tree
Showing 175 changed files with 2,950 additions and 2,950 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/labeler-approve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ on:
jobs:
remove_label:
permissions:
contents: write
pull-requests: write
statuses: write
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Random;
using Content.Shared.Storage;
using Content.Shared.Whitelist;
using Robust.Shared.Prototypes;

namespace Content.Server.GameTicking.Rules.VariationPass.Components;
Expand All @@ -24,4 +25,12 @@ public sealed partial class EntitySpawnVariationPassComponent : Component
/// </summary>
[DataField(required: true)]
public List<EntitySpawnEntry> Entities = default!;

// SS220 Fix SM begin
/// <summary>
/// A blacklis of entities that will block spawn of garbage in their vicinity
/// </summary>
[DataField]
public EntityWhitelist? Blacklist = new();
// SS220 Fix SM end
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
using Content.Server.GameTicking.Rules.VariationPass.Components;
using Content.Shared.Storage;
using Robust.Shared.Random;
using Content.Shared.Whitelist;

namespace Content.Server.GameTicking.Rules.VariationPass;

/// <inheritdoc cref="EntitySpawnVariationPassComponent"/>
public sealed class EntitySpawnVariationPassSystem : VariationPassSystem<EntitySpawnVariationPassComponent>
{
// SS220 SM garbage fix begin
[Dependency] private readonly EntityLookupSystem _lookupSystem = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
private const float Range = 3f; // Range to check SM nearby
// SS220 SM garbage fix end
protected override void ApplyVariation(Entity<EntitySpawnVariationPassComponent> ent, ref StationVariationPassEvent args)
{
var totalTiles = Stations.GetTileCount(args.Station);
Expand All @@ -19,6 +25,19 @@ protected override void ApplyVariation(Entity<EntitySpawnVariationPassComponent>
if (!TryFindRandomTileOnStation(args.Station, out _, out _, out var coords))
continue;

// SS220 SM garbage fix begin
var listTakedEntites = _lookupSystem.GetEntitiesInRange(coords, Range);
bool isCanSpawn = true;

foreach (var checkedTakedEntities in listTakedEntites)
{
if (_whitelistSystem.IsBlacklistPass(ent.Comp.Blacklist, checkedTakedEntities))
isCanSpawn = false;
}
if (!isCanSpawn)
continue;
// SS220 SM garbage fix end

var ents = EntitySpawnCollection.GetSpawns(ent.Comp.Entities, Random);
foreach (var spawn in ents)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ private void OnInteract(EntityUid uid, MechGrabberComponent component, UserActiv

if (TryComp<PhysicsComponent>(target, out var physics) && physics.BodyType == BodyType.Static ||
HasComp<WallMountComponent>(target) ||
HasComp<MobStateComponent>(target))
HasComp<MobStateComponent>(target) ||
HasComp<MechComponent>(target)) //SS220 Ripley in ripley fix (AddMechToClothing)
{
return;
}
Expand Down
7 changes: 5 additions & 2 deletions Content.Server/Mech/Systems/MechEquipmentSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ private void OnUsed(EntityUid uid, MechEquipmentComponent component, AfterIntera
if (mechComp.Broken)
return;

if (args.User == mechComp.PilotSlot.ContainedEntity)
return;
//SS220-AddMechToClothing-start
//Why does this check exist if it cannot be called?
// if (args.User == mechComp.PilotSlot.ContainedEntity)
// return;
//SS220-AddMechToClothing-end

if (mechComp.EquipmentContainer.ContainedEntities.Count >= mechComp.MaxEquipmentAmount)
return;
Expand Down
41 changes: 40 additions & 1 deletion Content.Server/Mech/Systems/MechSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Robust.Shared.Containers;
using Robust.Shared.Player;
using Content.Shared.Whitelist;
using Content.Shared.SS220.MechRobot; //SS220-AddMechToClothing

namespace Content.Server.Mech.Systems;

Expand Down Expand Up @@ -50,6 +51,7 @@ public override void Initialize()
SubscribeLocalEvent<MechComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<MechComponent, GetVerbsEvent<AlternativeVerb>>(OnAlternativeVerb);
SubscribeLocalEvent<MechComponent, MechOpenUiEvent>(OnOpenUi);
SubscribeLocalEvent<MechComponent, MechClothingOpenUiEvent>(OnOpenClothingUi); //SS220-AddMechToClothing
SubscribeLocalEvent<MechComponent, RemoveBatteryEvent>(OnRemoveBattery);
SubscribeLocalEvent<MechComponent, MechEntryEvent>(OnMechEntry);
SubscribeLocalEvent<MechComponent, MechExitEvent>(OnMechExit);
Expand Down Expand Up @@ -163,6 +165,14 @@ private void OnOpenUi(EntityUid uid, MechComponent component, MechOpenUiEvent ar
ToggleMechUi(uid, component);
}

//SS220-AddMechToClothing-start
private void OnOpenClothingUi(Entity<MechComponent> ent, ref MechClothingOpenUiEvent args)
{
args.Handled = true;
ToggleMechClothingUi(ent.Owner, args.Performer, ent.Comp);
}
//SS220-AddMechToClothing-end

private void OnToolUseAttempt(EntityUid uid, MechPilotComponent component, ref ToolUserAttemptUseEvent args)
{
if (args.Target == component.Mech)
Expand All @@ -174,6 +184,11 @@ private void OnAlternativeVerb(EntityUid uid, MechComponent component, GetVerbsE
if (!args.CanAccess || !args.CanInteract || component.Broken)
return;

//SS220-AddMechToClothing-start
if (!TryComp<MechRobotComponent>(uid, out var _))
return;
//SS220-AddMechToClothing-end

if (CanInsert(uid, args.User, component))
{
var enterVerb = new AlternativeVerb
Expand All @@ -197,8 +212,13 @@ private void OnAlternativeVerb(EntityUid uid, MechComponent component, GetVerbsE
args.Verbs.Add(enterVerb);
args.Verbs.Add(openUiVerb);
}
else if (!IsEmpty(component))
else if (!IsEmpty(component, uid)) //SS220-AddMechToClothing
{
//SS220-AddMechToClothing-start
if (!TryComp<MechRobotComponent>(uid, out var _))
return;
//SS220-AddMechToClothing-end

var ejectVerb = new AlternativeVerb
{
Text = Loc.GetString("mech-verb-exit"),
Expand Down Expand Up @@ -229,6 +249,11 @@ private void OnMechEntry(EntityUid uid, MechComponent component, MechEntryEvent
if (args.Cancelled || args.Handled)
return;

//SS220-AddMechToClothing-start
if (!TryComp<MechRobotComponent>(uid, out var _))
return;
//SS220-AddMechToClothing-end

if (_whitelistSystem.IsWhitelistFail(component.PilotWhitelist, args.User))
{
_popup.PopupEntity(Loc.GetString("mech-no-enter", ("item", uid)), args.User);
Expand Down Expand Up @@ -280,6 +305,20 @@ private void ToggleMechUi(EntityUid uid, MechComponent? component = null, Entity
UpdateUserInterface(uid, component);
}

//SS220-AddMechToClothing-start
private void ToggleMechClothingUi(EntityUid entOwner, EntityUid argsPerformer, MechComponent? entComp = null)
{
if (!Resolve(entOwner, ref entComp))
return;

if (!TryComp<ActorComponent>(argsPerformer, out var actor))
return;

_ui.TryToggleUi(entOwner, MechUiKey.Key, actor.PlayerSession);
UpdateUserInterface(entOwner, entComp);
}
//SS220-AddMechToClothing-end

private void ReceiveEquipmentUiMesssages<T>(EntityUid uid, MechComponent component, T args) where T : MechEquipmentUiMessage
{
var ev = new MechEquipmentUiMessageRelayEvent(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using Robust.Shared.Utility;
using Robust.Shared.Map.Components;
using Content.Shared.Whitelist;
using Content.Server.NPC.HTN;

namespace Content.Server.Revenant.EntitySystems;

Expand Down Expand Up @@ -73,7 +74,8 @@ private void OnInteract(EntityUid uid, RevenantComponent component, UserActivate
return;
}

if (!HasComp<MobStateComponent>(target) || !HasComp<HumanoidAppearanceComponent>(target) || HasComp<RevenantComponent>(target))
if (!HasComp<MobStateComponent>(target) || !HasComp<HumanoidAppearanceComponent>(target) || HasComp<RevenantComponent>(target)
|| HasComp<HTNComponent>(target)) // ss220 rev cant harvest NPC
return;

args.Handled = true;
Expand Down
123 changes: 123 additions & 0 deletions Content.Server/SS220/Commands/AdminRandomMakeAntagSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using System.Linq;
using Content.Server.Administration;
using Content.Server.Antag;
using Content.Server.GameTicking;
using Content.Server.GameTicking.Rules.Components;
using Content.Shared.Administration;
using Content.Shared.GameTicking;
using Content.Shared.IdentityManagement;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Random;
using Content.Shared.Ghost;
using Content.Server.Administration.Managers;
using Content.Server.Roles;
using Content.Shared.Mind;
using Content.Shared.Mindshield.Components;
using Content.Shared.Preferences;
using Content.Server.Preferences.Managers;

namespace Content.Server.SS220.Commands
{
[AdminCommand(AdminFlags.VarEdit)] // Only for admins
public sealed class MakeAntagCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IServerPreferencesManager _pref = default!;

public string Command => "makerandomantag";
public string Description => Loc.GetString("command-makerandomantag-description");
public string Help => $"Usage: {Command}";

private readonly List<string> _antagTypes = new() // TODO: When will add a cult add a cultist there
{
"Traitor",
"Thief",
"InitialInfected",
};

public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length == 0 || !_antagTypes.Contains(args[0]))
{
shell.WriteLine(Loc.GetString("command-makerandomantag-objective"));
return;
}

var successEntityUid = AdminMakeRandomAntagCommand(args[0]);

if (successEntityUid != null)
{
shell.WriteLine(Loc.GetString("command-makerandomantag-sucess",
("Entityname", Identity.Name(successEntityUid.Value, _entityManager)), ("antag", args[0])));
}
else
shell.WriteLine(Loc.GetString("command-makerandomantag-negative"));
}

private EntityUid? AdminMakeRandomAntagCommand(string defaultRule)
{
var antag = _entityManager.System<AntagSelectionSystem>();
var playerManager = IoCManager.Resolve<IPlayerManager>();
var gameTicker = _entityManager.System<GameTicker>();
var random = IoCManager.Resolve<IRobustRandom>();
var mindSystem = _entityManager.System<SharedMindSystem>();
var roleSystem = _entityManager.System<RoleSystem>();
var banSystem = IoCManager.Resolve<IBanManager>();

var players = playerManager.Sessions
.Where(x => gameTicker.PlayerGameStatuses[x.UserId] == PlayerGameStatus.JoinedGame)
.ToList();

random.Shuffle(players); // Shuffle player list to be more randomly

foreach (var player in players)
{

var pref = (HumanoidCharacterProfile)_pref.GetPreferences(player.UserId).SelectedCharacter;

if (!mindSystem.TryGetMind(player.UserId, out var mindId)) // Is it player or a cow?
continue;

if (banSystem.GetRoleBans(player.UserId) is { } roleBans &&
roleBans.Contains("Job:" + defaultRule)) // Do he have a roleban on THIS antag?
continue;

if (roleSystem.MindIsAntagonist(mindId) ||
_entityManager.HasComponent<GhostComponent>(player.AttachedEntity) ||
_entityManager.HasComponent<MindShieldComponent>(player.AttachedEntity)) // Is he already lucky boy or he is ghost or he is CAPTIAN?
continue;

if (!pref.AntagPreferences.Contains(defaultRule)) // Do he want to be a chosen antag or no?
continue;

switch (defaultRule) // TODO: When will add a cult add a cultist there too. U can add more for fun if u want.
{
case "Traitor":
antag.ForceMakeAntag<TraitorRuleComponent>(player, defaultRule);
break;
case "Thief":
antag.ForceMakeAntag<ThiefRuleComponent>(player, defaultRule);
break;
case "InitialInfected":
antag.ForceMakeAntag<ZombieRuleComponent>(player, defaultRule);
break;
}
if (roleSystem.MindIsAntagonist(mindId)) // If he sucessfuly passed all checks and get his antag?
return player.AttachedEntity;
}
return null;
}


public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
{
return CompletionResult.FromOptions(_antagTypes);
}
return CompletionResult.Empty;
}
}
}
Loading

0 comments on commit dae6e59

Please sign in to comment.