Skip to content

Commit

Permalink
Merge pull request #1 from ss14Starlight/Starlight
Browse files Browse the repository at this point in the history
Antag Weights change
  • Loading branch information
AzlasRain authored Feb 18, 2025
2 parents 1719754 + bddd648 commit db8aa9d
Show file tree
Hide file tree
Showing 93 changed files with 570,501 additions and 409,862 deletions.
1 change: 1 addition & 0 deletions Content.Client/Mech/Ui/MechMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void UpdateEquipmentView()
return;

ActiveEquipmentContainer.Children.Clear();
PassiveEquipmentContainer.Children.Clear();
foreach (var ent in mechComp.EquipmentContainer.ContainedEntities)
{
if (!_ent.TryGetComponent<MetaDataComponent>(ent, out var metaData))
Expand Down
51 changes: 37 additions & 14 deletions Content.Client/_Starlight/Overlay/Night/NightVisionSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Content.Client._Starlight.Overlay.Cyclorites;
using Content.Shared.Eye.Blinding.Components;
using Content.Shared.Mech.Components;
using Content.Shared.Mech;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
Expand All @@ -14,8 +16,6 @@ public sealed class NightVisionSystem : EntitySystem
[Dependency] private readonly IOverlayManager _overlayMan = default!;
[Dependency] private readonly TransformSystem _xformSys = default!;
private NightVisionOverlay _overlay = default!;
private EntityUid? _effect = null;
private readonly EntProtoId _effectPrototype = "EffectNightVision";

public override void Initialize()
{
Expand All @@ -26,45 +26,68 @@ public override void Initialize()

SubscribeLocalEvent<NightVisionComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<NightVisionComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);

SubscribeLocalEvent<NightVisionComponent, BeforePilotInsertEvent>(OnPlayerMechInsert);
SubscribeLocalEvent<NightVisionComponent, BeforePilotEjectEvent>(OnPlayerMechEject);

_overlay = new();
}

private void OnPlayerAttached(Entity<NightVisionComponent> ent, ref LocalPlayerAttachedEvent args)
{
if (_effect == null)
AddNightVision(ent.Owner);
if (ent.Comp.Effect == null)
AddNightVision(ent.Owner, ent.Comp);
}

private void OnPlayerDetached(Entity<NightVisionComponent> ent, ref LocalPlayerDetachedEvent args)
{
RemoveNightVision();
RemoveNightVision(ent.Comp);
}

private void OnPlayerMechInsert(Entity<NightVisionComponent> ent, ref BeforePilotInsertEvent args)
{
if (ent.Comp.Effect != null)
_xformSys.SetParent(ent.Comp.Effect.Value, args.Mech);
else
{
ent.Comp.Effect = SpawnAttachedTo(ent.Comp.EffectPrototype, Transform(args.Mech).Coordinates);
_xformSys.SetParent(ent.Comp.Effect.Value, args.Mech);
}
}

private void OnPlayerMechEject(Entity<NightVisionComponent> ent, ref BeforePilotEjectEvent args)
{
if (ent.Comp.Effect != null)
_xformSys.SetParent(ent.Comp.Effect.Value, ent.Owner);
}

private void OnVisionInit(Entity<NightVisionComponent> ent, ref ComponentInit args)
{
if (_player.LocalEntity != ent.Owner) return;

if (_effect == null)
AddNightVision(ent.Owner);
if (ent.Comp.Effect == null)
AddNightVision(ent.Owner, ent.Comp);
}

private void OnVisionShutdown(Entity<NightVisionComponent> ent, ref ComponentShutdown args)
{
if (_player.LocalEntity != ent.Owner) return;
RemoveNightVision();
RemoveNightVision(ent.Comp);
}

private void AddNightVision(EntityUid uid)
private void AddNightVision(EntityUid uid, NightVisionComponent component)
{
_overlayMan.AddOverlay(_overlay);
_effect = SpawnAttachedTo(_effectPrototype, Transform(uid).Coordinates);
_xformSys.SetParent(_effect.Value, uid);
component.Effect = SpawnAttachedTo(component.EffectPrototype, Transform(uid).Coordinates);
if (TryComp<MechPilotComponent>(uid, out var mechPilot))
_xformSys.SetParent(component.Effect.Value, mechPilot.Mech);
else
_xformSys.SetParent(component.Effect.Value, uid);
}
private void RemoveNightVision()
private void RemoveNightVision(NightVisionComponent component)
{
_overlayMan.RemoveOverlay(_overlay);
Del(_effect);
_effect = null;
Del(component.Effect);
component.Effect = null;
}
}
5 changes: 5 additions & 0 deletions Content.Server/Lathe/LatheSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ public void FinishProducing(EntityUid uid, LatheComponent? comp = null, LathePro
{
var result = Spawn(resultProto, Transform(uid).Coordinates);
_stack.TryMergeToContacts(result);
if (comp.CurrentRecipe.PrintTicket)
{
var tickets = Spawn(comp.CurrentRecipe.TicketProtoId, Transform(uid).Coordinates);
_stack.TryMergeToContacts(tickets);
}
}

if (comp.CurrentRecipe.ResultReagents is { } resultReagents &&
Expand Down
8 changes: 1 addition & 7 deletions Content.Server/Mech/Systems/MechSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,8 @@ private void OnInteractUsing(EntityUid uid, MechComponent component, InteractUsi
_actionBlocker.UpdateCanMove(uid);
return;
}

if (component.GasTankSlot.ContainedEntity == null && _tag.HasTag(args.Used, "MechAirTank"))
{
_actionBlocker.UpdateCanMove(uid);
return;
}

if (_toolSystem.HasQuality(args.Used, "Prying") && component.BatterySlot.ContainedEntity != null)
if (_toolSystem.HasQuality(args.Used, "Prying"))
{
if (component.BatterySlot.ContainedEntity != null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Content.Shared.NPC.Prototypes;
using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;

namespace Content.Server.Starlight.FactionClothingBlockerSystem;

[RegisterComponent]
public sealed partial class AccessClothingBlockerComponent : Component
{
[DataField("access", required: false)]
public string? Access = null;

[DataField("beepSound")]
public SoundSpecifier BeepSound = new SoundPathSpecifier("/Audio/Effects/beep1.ogg");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System.Threading.Tasks;
using System.Linq;
using Content.Server.Body.Systems;
using Content.Server.Explosion.EntitySystems;
using Content.Server.Popups;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Interaction.Components;
using Content.Shared.Inventory.Events;
using Content.Shared.Popups;
using Robust.Server.Audio;

namespace Content.Server.Starlight.FactionClothingBlockerSystem;

public sealed class AccessClothingBlockerSystem : EntitySystem
{
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly BodySystem _bodySystem = default!;
[Dependency] private readonly ExplosionSystem _explosionSystem = default!;
[Dependency] private readonly AudioSystem _audioSystem = default!;
[Dependency] private readonly AccessReaderSystem _accessReader = default!;

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

SubscribeLocalEvent<AccessClothingBlockerComponent, GotEquippedEvent>(OnGotEquipped);
}

private async void OnGotEquipped(EntityUid uid, AccessClothingBlockerComponent component, GotEquippedEvent args)
{
var canUse = false;
if (!TryComp<AccessReaderComponent>(uid, out var accessReader))
canUse = true;

if (component.Access != null)
{
var accesses = _accessReader.FindAccessTags(args.Equipee);
if (accesses.Any(a => a.ToString() == component.Access))
canUse = true;
}

else if (_accessReader.IsAllowed(args.Equipee, uid, accessReader) )
canUse = true;

if (canUse)
return;

EntityManager.EnsureComponent<UnremoveableComponent>(uid);
await PopupWithDelays(uid, component);
_bodySystem.GibBody(args.Equipee, true);
_explosionSystem.QueueExplosion(uid, "Default", 50, 5, 30, canCreateVacuum: false);
}

private async Task PopupWithDelays(EntityUid uid, AccessClothingBlockerComponent component)
{
var notifications = new[]
{
new { Message = Loc.GetString("access-clothing-blocker-notify-wrong-user-detected"), Delay = TimeSpan.FromSeconds(2), PopupType = PopupType.LargeCaution },
new { Message = Loc.GetString("access-clothing-blocker-notify-inclusion-bolts"), Delay = TimeSpan.FromSeconds(2), PopupType = PopupType.LargeCaution },
new { Message = Loc.GetString("access-clothing-blocker-notify-activate-self-destruction"), Delay = TimeSpan.FromSeconds(2), PopupType = PopupType.LargeCaution }
};

foreach (var notification in notifications)
{

_audioSystem.PlayPvs(component.BeepSound, uid);
await PopupWithDelay(notification.Message, uid, notification.PopupType);
await Task.Delay(notification.Delay);
}

for (int i = 10; i > 0; i--)
{
_audioSystem.PlayPvs(component.BeepSound, uid);
await PopupWithDelay(i.ToString(), uid, PopupType.LargeCaution);
await Task.Delay(TimeSpan.FromSeconds(1));
}
}

private async Task PopupWithDelay(string message, EntityUid uid, PopupType popupType)
{
_popup.PopupEntity(message, uid, popupType);
}
}
53 changes: 46 additions & 7 deletions Content.Shared/Mech/EntitySystems/SharedMechSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,17 @@ private void SetupUser(EntityUid mech, EntityUid pilot, MechComponent? component
else
_audioSystem.PlayEntity(component.CriticalDamageSound, pilot, mech);

UpdateActions(mech, pilot, component);
}

private void UpdateActions(EntityUid mech, EntityUid pilot, MechComponent? component = null)
{
if (!Resolve(mech, ref component))
return;

if (_net.IsClient)
return;

_actions.AddAction(pilot, ref component.MechCycleActionEntity, component.MechCycleAction, mech);
_actions.AddAction(pilot, ref component.MechUiActionEntity, component.MechUiAction, mech);
_actions.AddAction(pilot, ref component.MechEjectActionEntity, component.MechEjectAction, mech);
Expand All @@ -174,6 +182,10 @@ private void SetupUser(EntityUid mech, EntityUid pilot, MechComponent? component
_actions.AddAction(pilot, ref component.MechToggleSirenActionEntity, component.MechToggleSirenAction, mech);
if (HasComp<MechThrustersComponent>(mech))
_actions.AddAction(pilot, ref component.MechToggleThrustersActionEntity, component.MechToggleThrustersAction, mech);
var equipment = new List<EntityUid>(component.EquipmentContainer.ContainedEntities);
foreach (var ent in equipment)
if (TryComp<MechEquipmentActionComponent>(ent, out var actionComp))
_actions.AddAction(pilot, ref actionComp.EquipmentActionEntity, actionComp.EquipmentAction, ent);
}

private void RemoveUser(EntityUid mech, EntityUid pilot)
Expand All @@ -184,6 +196,12 @@ private void RemoveUser(EntityUid mech, EntityUid pilot)
RemComp<InteractionRelayComponent>(pilot);

_actions.RemoveProvidedActions(pilot, mech);
if (!TryComp<MechComponent>(mech, out var mechComp))
return;
var equipment = new List<EntityUid>(mechComp.EquipmentContainer.ContainedEntities);
foreach (var ent in equipment)
if (TryComp<MechEquipmentActionComponent>(ent, out var actionComp))
_actions.RemoveProvidedActions(pilot, ent);
}

/// <summary>
Expand Down Expand Up @@ -244,10 +262,10 @@ public void CycleEquipment(EntityUid uid, MechComponent? component = null)
/// <summary>
/// Inserts an equipment item into the mech.
/// </summary>
/// <param name="uid"></param>
/// <param name="toInsert"></param>
/// <param name="component"></param>
/// <param name="equipmentComponent"></param>
/// <param name="uid"> Mech </param>
/// <param name="toInsert"> Equipment what inserted </param>
/// <param name="component"> Mech Component </param>
/// <param name="equipmentComponent"> Equipment Component </param>
public void InsertEquipment(EntityUid uid, EntityUid toInsert, MechComponent? component = null,
MechEquipmentComponent? equipmentComponent = null)
{
Expand All @@ -262,12 +280,22 @@ public void InsertEquipment(EntityUid uid, EntityUid toInsert, MechComponent? co

if (_whitelistSystem.IsWhitelistFail(component.EquipmentWhitelist, toInsert))
return;

if (!TryComp<MetaDataComponent>(toInsert, out var toInsertMeta))
return;

var equipment = new List<EntityUid>(component.EquipmentContainer.ContainedEntities);
foreach (var ent in equipment)
if (TryComp<MetaDataComponent>(ent, out var entMeta) && entMeta.EntityPrototype == toInsertMeta.EntityPrototype)
return;

equipmentComponent.EquipmentOwner = uid;
_container.Insert(toInsert, component.EquipmentContainer);
var ev = new MechEquipmentInsertedEvent(uid);
RaiseLocalEvent(toInsert, ref ev);
UpdateUserInterface(uid, component);
if (component.PilotSlot.ContainedEntity != null)
UpdateActions(uid, component.PilotSlot.ContainedEntity.Value, component);
}

/// <summary>
Expand Down Expand Up @@ -419,6 +447,12 @@ public bool TryInsert(EntityUid uid, EntityUid? toInsert, MechComponent? compone
return false;

SetupUser(uid, toInsert.Value);

var ev = new BeforePilotInsertEvent(uid, toInsert.Value);
RaiseLocalEvent(uid, ref ev);

RaiseLocalEvent(toInsert.Value, ref ev);

_container.Insert(toInsert.Value, component.PilotSlot);
UpdateAppearance(uid, component);
return true;
Expand All @@ -427,8 +461,8 @@ public bool TryInsert(EntityUid uid, EntityUid? toInsert, MechComponent? compone
/// <summary>
/// Attempts to eject the current pilot from the mech
/// </summary>
/// <param name="uid"></param>
/// <param name="component"></param>
/// <param name="uid"> mech </param>
/// <param name="component"> mech component </param>
/// <returns>Whether or not the pilot was ejected.</returns>
public bool TryEject(EntityUid uid, MechComponent? component = null)
{
Expand All @@ -444,6 +478,11 @@ public bool TryEject(EntityUid uid, MechComponent? component = null)
}

var pilot = component.PilotSlot.ContainedEntity.Value;

var ev = new BeforePilotEjectEvent(uid, pilot);
RaiseLocalEvent(uid, ref ev);

RaiseLocalEvent(pilot, ref ev);

_container.RemoveEntity(uid, pilot);
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Content.Shared.DoAfter;
using Content.Shared.Mech.Components;
using Content.Shared.Mech;
using Robust.Shared.Prototypes;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;

namespace Content.Shared.Mech.Equipment.Components;
Expand All @@ -21,9 +23,27 @@ public sealed partial class MechEquipmentComponent : Component
/// </summary>
[ViewVariables] public EntityUid? EquipmentOwner;

[ViewVariables] public EquipmentType EquipmentType = EquipmentType.Active;
[DataField("equipmentType")] public EquipmentType EquipmentType = EquipmentType.Active;
}

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class MechEquipmentActionComponent : Component
{
[DataField]
[AutoNetworkedField]
public bool EquipmentToggled = false;

[DataField]
[AutoNetworkedField]
public bool EquipmentComponentAdded = false;

[DataField("actionId")]
public EntProtoId EquipmentAction = "";

[DataField] public EntityUid? EquipmentActionEntity;
}


/// <summary>
/// Raised on the equipment when the installation is finished successfully
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Content.Shared.Mech.Equipment.Components;

[RegisterComponent]
public sealed partial class MechNightVisionComponent : Component
{
}
Loading

0 comments on commit db8aa9d

Please sign in to comment.