Skip to content

Commit

Permalink
Merge pull request #100 from dvir001/EMP-Guns
Browse files Browse the repository at this point in the history
EMP Update
  • Loading branch information
Cheackraze authored Jul 29, 2023
2 parents 6c59b7c + d65042d commit 55dbe38
Show file tree
Hide file tree
Showing 62 changed files with 1,097 additions and 33 deletions.
8 changes: 8 additions & 0 deletions Content.Client/_NF/M_Emp/M_EmpComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Content.Shared._NF.M_Emp;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

[NetworkedComponent, RegisterComponent]
public sealed class M_EmpGeneratorComponent : SharedM_EmpGeneratorComponent
{
}
1 change: 1 addition & 0 deletions Content.Server/Emp/EmpSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Server.Entry;
using Content.Server.Explosion.EntitySystems;
using Content.Server.Power.EntitySystems;
using Content.Server.Radio;
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Light/EntitySystems/PoweredLightSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ private void OnDoAfter(EntityUid uid, PoweredLightComponent component, DoAfterEv

private void OnEmpPulse(EntityUid uid, PoweredLightComponent component, ref EmpPulseEvent args)
{
if (TryDestroyBulb(uid, component))
args.Affected = true;
// if (TryDestroyBulb(uid, component)) // Make it so EMP isnt exploding lights
// args.Affected = true; // Make it so EMP isnt exploding lights
}
}
}
3 changes: 3 additions & 0 deletions Content.Server/Power/Components/ApcComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public sealed class ApcComponent : BaseApcNetComponent
[DataField("onReceiveMessageSound")]
public SoundSpecifier OnReceiveMessageSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");

[DataField("apcIgnoreEmp")]
public bool ApcIgnoreEmp = false;

[ViewVariables]
public ApcChargeState LastChargeState;
public TimeSpan LastChargeStateTime;
Expand Down
16 changes: 12 additions & 4 deletions Content.Server/Power/EntitySystems/ApcSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,19 @@ private ApcExternalPowerState CalcExtPowerState(EntityUid uid, PowerState.Batter

private void OnEmpPulse(EntityUid uid, ApcComponent component, ref EmpPulseEvent args)
{
if (component.MainBreakerEnabled)
if (component.ApcIgnoreEmp)
{
args.Affected = true;
args.Disabled = true;
ApcToggleBreaker(uid, component);
args.Affected = false;
args.Disabled = false;
}
else
{
if (component.MainBreakerEnabled)
{
args.Affected = true;
args.Disabled = true;
ApcToggleBreaker(uid, component);
}
}
}
}
Expand Down
116 changes: 116 additions & 0 deletions Content.Server/_NF/M_Emp/M_EmpGeneratorComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
using Content.Shared.Radio;
using Content.Shared._NF.M_Emp;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server._NF.M_Emp
{
/// <summary>
/// A M_Emp generator.
/// </summary>
[NetworkedComponent, RegisterComponent]
[Access(typeof(M_EmpSystem))]
public sealed class M_EmpGeneratorComponent : SharedM_EmpGeneratorComponent
{
/// <summary>
/// Current state of this generator
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("generatorState")]
public GeneratorState GeneratorState = GeneratorState.Inactive;

/// <summary>
/// How long it takes for the generator to EMP
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("baseActivatingTime")]
public TimeSpan BaseActivatingTime = TimeSpan.FromSeconds(3.5);

/// <summary>
/// How long it actually takes for the generator to EMP
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("activatingTime")]
public TimeSpan ActivatingTime = TimeSpan.FromSeconds(3.5);

/// <summary>
/// How long the generator EMP is working
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("engagedTime")]
public TimeSpan EngagedTime = TimeSpan.FromSeconds(60);

/// <summary>
/// How long the generator Cooling Down
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("baseCoolingDownTime")]
public TimeSpan BaseCoolingDownTime = TimeSpan.FromSeconds(60);

/// <summary>
/// How long the generator actually has to cooldown after use
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("coolingDownTime")]
public TimeSpan CoolingDownTime = TimeSpan.FromSeconds(60);

/// <summary>
/// How long the generator has to recharge after use
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("baseRecharging")]
public TimeSpan BaseRecharging = TimeSpan.FromSeconds(60);

/// <summary>
/// How long the generator actually has to recharge after use
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("Recharging")]
public TimeSpan Recharging = TimeSpan.FromSeconds(60);

[DataField("M_EmpChannel", customTypeSerializer: typeof(PrototypeIdSerializer<RadioChannelPrototype>))]
public string M_EmpChannel = "Security";

/// <summary>
/// Current how much charge the generator currently has
/// </summary>
[DataField("chargeRemaining")]
public int ChargeRemaining = 5;

/// <summary>
/// How much capacity the generator can hold
/// </summary>
[DataField("chargeCapacity")]
public int ChargeCapacity = 5;

/// <summary>
/// Used as a guard to prevent spamming the appearance system
/// </summary>
[DataField("previousCharge")]
public int PreviousCharge = 5;
}

[CopyByRef, DataRecord]
public record struct GeneratorState(GeneratorStateType StateType, TimeSpan Until)
{
public static readonly GeneratorState Inactive = new (GeneratorStateType.Inactive, TimeSpan.Zero);
};

public sealed class M_EmpGeneratorActivatedEvent : EntityEventArgs
{
public EntityUid Generator;

public M_EmpGeneratorActivatedEvent(EntityUid generator)
{
Generator = generator;
}
}
public enum GeneratorStateType
{
Inactive,
Activating,
Engaged,
CoolingDown,
Recharging,
}
}
Loading

0 comments on commit 55dbe38

Please sign in to comment.