-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
98 changed files
with
1,001 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; | ||
using Content.Server.Weapons.Ranged.Systems; | ||
|
||
namespace Content.Server.Weapons.Ranged.Components; | ||
|
||
/// <summary> | ||
/// Allows for energy gun to switch between three modes. This also changes the sprite accordingly. | ||
/// </summary> | ||
/// <remarks>This is BatteryWeaponFireModesSystem with additional changes to allow for different sprites.</remarks> | ||
[RegisterComponent] | ||
[Access(typeof(EnergyGunSystem))] | ||
[AutoGenerateComponentState] | ||
public sealed partial class EnergyGunComponent : Component | ||
{ | ||
/// <summary> | ||
/// A list of the different firing modes the energy gun can switch between | ||
/// </summary> | ||
[DataField("fireModes", required: true)] | ||
[AutoNetworkedField] | ||
public List<EnergyWeaponFireMode> FireModes = new(); | ||
|
||
/// <summary> | ||
/// The currently selected firing mode | ||
/// </summary> | ||
[DataField("currentFireMode")] | ||
[AutoNetworkedField] | ||
public EnergyWeaponFireMode? CurrentFireMode = default!; | ||
} | ||
|
||
[DataDefinition] | ||
public sealed partial class EnergyWeaponFireMode | ||
{ | ||
/// <summary> | ||
/// The projectile prototype associated with this firing mode | ||
/// </summary> | ||
[DataField("proto", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] | ||
public string Prototype = default!; | ||
|
||
/// <summary> | ||
/// The battery cost to fire the projectile associated with this firing mode | ||
/// </summary> | ||
[DataField("fireCost")] | ||
public float FireCost = 100; | ||
|
||
/// <summary> | ||
/// The name of the selected firemode | ||
/// </summary> | ||
[DataField("name")] | ||
public string Name = string.Empty; | ||
|
||
/// <summary> | ||
/// What RsiState we use for that firemode if it needs to change. | ||
/// </summary> | ||
[DataField("state")] | ||
public string State = string.Empty; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,159 @@ | ||
using Content.Server.Popups; | ||
using Content.Server.Weapons.Ranged.Components; | ||
using Content.Shared.Database; | ||
using Content.Shared.Examine; | ||
using Content.Shared.Interaction; | ||
using Content.Shared.Verbs; | ||
using Content.Shared.Item; | ||
using Content.Shared._Sunrise.Weapons.Ranged; | ||
using Content.Shared.Weapons.Ranged.Components; | ||
using Robust.Shared.Prototypes; | ||
using System.Linq; | ||
using System; | ||
|
||
namespace Content.Server.Weapons.Ranged.Systems; | ||
public sealed class EnergyGunSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
[Dependency] private readonly PopupSystem _popupSystem = default!; | ||
[Dependency] private readonly SharedItemSystem _item = default!; | ||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<EnergyGunComponent, ActivateInWorldEvent>(OnInteractHandEvent); | ||
SubscribeLocalEvent<EnergyGunComponent, GetVerbsEvent<Verb>>(OnGetVerb); | ||
SubscribeLocalEvent<EnergyGunComponent, ExaminedEvent>(OnExamined); | ||
} | ||
|
||
private void OnExamined(EntityUid uid, EnergyGunComponent component, ExaminedEvent args) | ||
{ | ||
if (component.FireModes == null || component.FireModes.Count < 2) | ||
return; | ||
|
||
if (component.CurrentFireMode == null) | ||
{ | ||
SetFireMode(uid, component, component.FireModes.First()); | ||
} | ||
|
||
if (component.CurrentFireMode?.Prototype == null) | ||
return; | ||
|
||
if (!_prototypeManager.TryIndex<EntityPrototype>(component.CurrentFireMode.Prototype, out var proto)) | ||
return; | ||
|
||
args.PushMarkup(Loc.GetString("energygun-examine-fire-mode", ("mode", Loc.GetString(component.CurrentFireMode.Name)))); | ||
} | ||
|
||
private void OnGetVerb(EntityUid uid, EnergyGunComponent component, GetVerbsEvent<Verb> args) | ||
{ | ||
if (!args.CanAccess || !args.CanInteract || args.Hands == null) | ||
return; | ||
|
||
if (component.FireModes == null || component.FireModes.Count < 2) | ||
return; | ||
|
||
if (component.CurrentFireMode == null) | ||
{ | ||
SetFireMode(uid, component, component.FireModes.First()); | ||
} | ||
|
||
foreach (var fireMode in component.FireModes) | ||
{ | ||
var entProto = _prototypeManager.Index<EntityPrototype>(fireMode.Prototype); | ||
|
||
var v = new Verb | ||
{ | ||
Priority = 1, | ||
Category = VerbCategory.SelectType, | ||
Text = entProto.Name, | ||
Disabled = fireMode == component.CurrentFireMode, | ||
Impact = LogImpact.Low, | ||
DoContactInteraction = true, | ||
Act = () => | ||
{ | ||
SetFireMode(uid, component, fireMode, args.User); | ||
} | ||
}; | ||
|
||
args.Verbs.Add(v); | ||
} | ||
} | ||
|
||
private void OnInteractHandEvent(EntityUid uid, EnergyGunComponent component, ActivateInWorldEvent args) | ||
{ | ||
if (component.FireModes == null || component.FireModes.Count < 2) | ||
return; | ||
|
||
CycleFireMode(uid, component, args.User); | ||
} | ||
|
||
private void CycleFireMode(EntityUid uid, EnergyGunComponent component, EntityUid user) | ||
{ | ||
int index = (component.CurrentFireMode != null) ? | ||
Math.Max(component.FireModes.IndexOf(component.CurrentFireMode), 0) + 1 : 1; | ||
|
||
EnergyWeaponFireMode? fireMode; | ||
|
||
if (index >= component.FireModes.Count) | ||
{ | ||
fireMode = component.FireModes.FirstOrDefault(); | ||
} | ||
|
||
else | ||
{ | ||
fireMode = component.FireModes[index]; | ||
} | ||
|
||
SetFireMode(uid, component, fireMode, user); | ||
} | ||
|
||
private void SetFireMode(EntityUid uid, EnergyGunComponent component, EnergyWeaponFireMode? fireMode, EntityUid? user = null) | ||
{ | ||
if (fireMode?.Prototype == null) | ||
return; | ||
|
||
component.CurrentFireMode = fireMode; | ||
|
||
if (TryComp(uid, out ProjectileBatteryAmmoProviderComponent? projectileBatteryAmmoProvider)) | ||
{ | ||
if (!_prototypeManager.TryIndex<EntityPrototype>(fireMode.Prototype, out var prototype)) | ||
return; | ||
|
||
projectileBatteryAmmoProvider.Prototype = fireMode.Prototype; | ||
projectileBatteryAmmoProvider.FireCost = fireMode.FireCost; | ||
|
||
if (user != null) | ||
{ | ||
_popupSystem.PopupEntity(Loc.GetString("gun-set-fire-mode", ("mode", Loc.GetString(component.CurrentFireMode.Name))), uid, user.Value); | ||
} | ||
|
||
if (component.CurrentFireMode.State == string.Empty) | ||
return; | ||
|
||
if (TryComp<AppearanceComponent>(uid, out var _) && TryComp<ItemComponent>(uid, out var item)) | ||
{ | ||
_item.SetHeldPrefix(uid, component.CurrentFireMode.State, false, item); | ||
switch (component.CurrentFireMode.State) | ||
{ | ||
case "disabler": | ||
UpdateAppearance(uid, EnergyGunFireModeState.Disabler); | ||
break; | ||
case "lethal": | ||
UpdateAppearance(uid, EnergyGunFireModeState.Lethal); | ||
break; | ||
case "special": | ||
UpdateAppearance(uid, EnergyGunFireModeState.Special); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void UpdateAppearance(EntityUid uid, EnergyGunFireModeState state) | ||
{ | ||
_appearance.SetData(uid, EnergyGunFireModeVisuals.State, state); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Content.Shared/_Sunrise/Weapons/EnergyGunFireModeVisuals.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared._Sunrise.Weapons.Ranged; | ||
|
||
[Serializable, NetSerializable] | ||
public enum EnergyGunFireModeVisuals : byte | ||
{ | ||
State | ||
} | ||
|
||
[Serializable, NetSerializable] | ||
public enum EnergyGunFireModeState : byte | ||
{ | ||
Disabler, | ||
Lethal, | ||
Special | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
energygun-examine-fire-mode = The firemode is set to {$mode} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
energygun-examine-fire-mode = Режим огня установлен на {$mode} | ||
ent-WeaponEnergyGun = Энергетическая пушка | ||
.desc = Базовая гибридная энергетическая с двумя режимами работы: обезоруживание и летал. | ||
ent-WeaponEnergyGunMultiphase = X-01 Мультифазный энергетический карабин | ||
.desc = Это дорогая современная реконструкция старинного лазерного пистолета. Пистолет имеет несколько уникальных режимов стрельбы, но лишен возможности перезаряжаться со временем. | ||
ent-WeaponEnergyGunMini = миниатюрная энергетическая пушка | ||
.desc = Облегченная версия энергетического пистолета с меньшей емкостью. | ||
ent-WeaponEnergyGunPistol = Энергетический пистолет PDW-9 | ||
.desc = Военное оружие, используемое многими ополченцами в местном секторе. | ||
ent-WeaponGunLaserCarbineAutomatic = Лазерный карабин ИК-60 | ||
.desc = Лазерный полуавтоматический карабин на 20 патронов. | ||
energy-gun-lethal = летал | ||
energy-gun-disable = обезоруживание |
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
Oops, something went wrong.