2021-03-21 09:12:03 -07:00
|
|
|
using System;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Weapon.Ranged.Ammunition.Components;
|
2021-07-10 17:35:33 +02:00
|
|
|
using Content.Shared.Sound;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Weapons.Ranged.Barrels.Components;
|
2022-01-30 17:39:46 +11:00
|
|
|
using Robust.Shared.Analyzers;
|
2021-03-01 15:24:46 -08:00
|
|
|
using Robust.Shared.Containers;
|
2020-06-22 05:47:15 +10:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-07-12 01:32:10 -07:00
|
|
|
using Robust.Shared.GameStates;
|
2020-06-24 20:00:31 +02:00
|
|
|
using Robust.Shared.Map;
|
2021-12-30 00:48:18 +11:00
|
|
|
using Robust.Shared.Prototypes;
|
2020-06-22 05:47:15 +10:00
|
|
|
using Robust.Shared.Serialization;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2021-12-30 00:48:18 +11:00
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
2020-09-08 13:30:22 +02:00
|
|
|
using Robust.Shared.ViewVariables;
|
2020-06-22 05:47:15 +10:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Weapon.Ranged.Barrels.Components
|
2020-06-22 05:47:15 +10:00
|
|
|
{
|
2022-02-08 00:42:49 -08:00
|
|
|
[RegisterComponent, NetworkedComponent, ComponentReference(typeof(ServerRangedBarrelComponent))]
|
2022-01-30 17:39:46 +11:00
|
|
|
public sealed class RevolverBarrelComponent : ServerRangedBarrelComponent, ISerializationHooks
|
2020-06-22 05:47:15 +10:00
|
|
|
{
|
2020-09-08 13:30:22 +02:00
|
|
|
[ViewVariables]
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("caliber")]
|
2022-01-30 17:39:46 +11:00
|
|
|
public BallisticCaliber Caliber = BallisticCaliber.Unspecified;
|
2021-03-05 01:08:38 +01:00
|
|
|
|
2022-01-30 17:39:46 +11:00
|
|
|
public Container AmmoContainer = default!;
|
2021-03-05 01:08:38 +01:00
|
|
|
|
2020-09-08 13:30:22 +02:00
|
|
|
[ViewVariables]
|
2022-01-30 17:39:46 +11:00
|
|
|
public int CurrentSlot;
|
2021-03-05 01:08:38 +01:00
|
|
|
|
2022-01-30 17:39:46 +11:00
|
|
|
public override int Capacity => AmmoSlots.Length;
|
2021-03-05 01:08:38 +01:00
|
|
|
|
|
|
|
|
[DataField("capacity")]
|
|
|
|
|
private int _serializedCapacity = 6;
|
|
|
|
|
|
|
|
|
|
[DataField("ammoSlots", readOnly: true)]
|
2022-01-30 17:39:46 +11:00
|
|
|
public EntityUid?[] AmmoSlots = Array.Empty<EntityUid?>();
|
2020-06-22 05:47:15 +10:00
|
|
|
|
2022-01-30 17:39:46 +11:00
|
|
|
public override int ShotsLeft => AmmoContainer.ContainedEntities.Count;
|
2020-06-22 05:47:15 +10:00
|
|
|
|
2020-09-08 13:30:22 +02:00
|
|
|
[ViewVariables]
|
2021-12-30 00:48:18 +11:00
|
|
|
[DataField("fillPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
|
2022-01-30 17:39:46 +11:00
|
|
|
public string? FillPrototype;
|
2021-03-05 01:08:38 +01:00
|
|
|
|
2020-09-14 00:04:00 +12:00
|
|
|
[ViewVariables]
|
2022-01-30 17:39:46 +11:00
|
|
|
public int UnspawnedCount;
|
2020-06-22 05:47:15 +10:00
|
|
|
|
|
|
|
|
// Sounds
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("soundEject")]
|
2022-01-30 17:39:46 +11:00
|
|
|
public SoundSpecifier SoundEject = new SoundPathSpecifier("/Audio/Weapons/Guns/MagOut/revolver_magout.ogg");
|
2021-03-05 01:08:38 +01:00
|
|
|
|
|
|
|
|
[DataField("soundInsert")]
|
2022-01-30 17:39:46 +11:00
|
|
|
public SoundSpecifier SoundInsert = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/revolver_magin.ogg");
|
2020-06-22 05:47:15 +10:00
|
|
|
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("soundSpin")]
|
2022-01-30 17:39:46 +11:00
|
|
|
public SoundSpecifier SoundSpin = new SoundPathSpecifier("/Audio/Weapons/Guns/Misc/revolver_spin.ogg");
|
2021-03-05 01:08:38 +01:00
|
|
|
|
|
|
|
|
void ISerializationHooks.BeforeSerialization()
|
2020-06-22 05:47:15 +10:00
|
|
|
{
|
2022-01-30 17:39:46 +11:00
|
|
|
_serializedCapacity = AmmoSlots.Length;
|
2021-03-05 01:08:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ISerializationHooks.AfterDeserialization()
|
|
|
|
|
{
|
2022-01-30 17:39:46 +11:00
|
|
|
AmmoSlots = new EntityUid?[_serializedCapacity];
|
2020-06-22 05:47:15 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|