[feat] Egun
This commit is contained in:
@@ -30,4 +30,6 @@ public enum GunVisualLayers : byte
|
||||
BaseUnshaded,
|
||||
Mag,
|
||||
MagUnshaded,
|
||||
TwoModeFirst,
|
||||
TwoModeSecond
|
||||
}
|
||||
|
||||
@@ -251,14 +251,19 @@ public sealed partial class GunSystem
|
||||
_ammoCount.Visible = true;
|
||||
|
||||
_ammoCount.Text = $"x{count:00}";
|
||||
max = Math.Min(max, 8);
|
||||
FillBulletRow(_bulletsList, count, max);
|
||||
float step = 1;
|
||||
if (max > 8)
|
||||
{
|
||||
step = ((float)max / 8);
|
||||
}
|
||||
FillBulletRow(_bulletsList, count, max, step);
|
||||
}
|
||||
|
||||
private static void FillBulletRow(Control container, int count, int capacity)
|
||||
private static void FillBulletRow(Control container, int count, int capacity, float step = 1)
|
||||
{
|
||||
var colorGone = Color.FromHex("#000000");
|
||||
var color = Color.FromHex("#E00000");
|
||||
int emptyNumber = 0;
|
||||
|
||||
// Draw the empty ones
|
||||
for (var i = count; i < capacity; i++)
|
||||
|
||||
@@ -14,6 +14,10 @@ public sealed partial class GunSystem
|
||||
// Projectile
|
||||
SubscribeLocalEvent<ProjectileBatteryAmmoProviderComponent, AmmoCounterControlEvent>(OnControl);
|
||||
SubscribeLocalEvent<ProjectileBatteryAmmoProviderComponent, UpdateAmmoCounterEvent>(OnAmmoCountUpdate);
|
||||
|
||||
// TwoModeEnergy
|
||||
SubscribeLocalEvent<TwoModeEnergyAmmoProviderComponent, AmmoCounterControlEvent>(OnControl);
|
||||
SubscribeLocalEvent<TwoModeEnergyAmmoProviderComponent, UpdateAmmoCounterEvent>(OnAmmoCountUpdate);
|
||||
}
|
||||
|
||||
private void OnAmmoCountUpdate(EntityUid uid, BatteryAmmoProviderComponent component, UpdateAmmoCounterEvent args)
|
||||
|
||||
@@ -28,6 +28,18 @@ public sealed partial class GunSystem
|
||||
sprite.LayerSetState(GunVisualLayers.MagUnshaded, $"{component.MagState}-unshaded-{component.MagSteps - 1}");
|
||||
sprite.LayerSetVisible(GunVisualLayers.MagUnshaded, false);
|
||||
}
|
||||
|
||||
if (sprite.LayerMapTryGet(GunVisualLayers.TwoModeFirst, out _))
|
||||
{
|
||||
sprite.LayerSetState(GunVisualLayers.TwoModeFirst, $"{component.MagState}-twomode1-{component.MagSteps - 1}");
|
||||
sprite.LayerSetVisible(GunVisualLayers.TwoModeFirst, false);
|
||||
}
|
||||
|
||||
if (sprite.LayerMapTryGet(GunVisualLayers.TwoModeSecond, out _))
|
||||
{
|
||||
sprite.LayerSetState(GunVisualLayers.TwoModeSecond, $"{component.MagState}-twomode2-{component.MagSteps - 1}");
|
||||
sprite.LayerSetVisible(GunVisualLayers.TwoModeSecond, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMagazineVisualsChange(EntityUid uid, MagazineVisualsComponent component, ref AppearanceChangeEvent args)
|
||||
@@ -67,6 +79,16 @@ public sealed partial class GunSystem
|
||||
sprite.LayerSetVisible(GunVisualLayers.MagUnshaded, false);
|
||||
}
|
||||
|
||||
if (sprite.LayerMapTryGet(GunVisualLayers.TwoModeFirst, out _))
|
||||
{
|
||||
sprite.LayerSetVisible(GunVisualLayers.TwoModeFirst, false);
|
||||
}
|
||||
|
||||
if (sprite.LayerMapTryGet(GunVisualLayers.TwoModeSecond, out _))
|
||||
{
|
||||
sprite.LayerSetVisible(GunVisualLayers.TwoModeSecond, false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,6 +103,27 @@ public sealed partial class GunSystem
|
||||
sprite.LayerSetVisible(GunVisualLayers.MagUnshaded, true);
|
||||
sprite.LayerSetState(GunVisualLayers.MagUnshaded, $"{component.MagState}-unshaded-{step}");
|
||||
}
|
||||
|
||||
if (!args.AppearanceData.TryGetValue(AmmoVisuals.InStun, out var inStun) || inStun is true)
|
||||
{
|
||||
if (sprite.LayerMapTryGet(GunVisualLayers.TwoModeFirst, out var _))
|
||||
{
|
||||
sprite.LayerSetVisible(GunVisualLayers.TwoModeSecond, false);
|
||||
sprite.LayerSetVisible(GunVisualLayers.TwoModeFirst, true);
|
||||
sprite.LayerSetState(GunVisualLayers.TwoModeFirst, $"{component.MagState}-twomode1-{step}");
|
||||
}
|
||||
}
|
||||
|
||||
else if (inStun is false)
|
||||
{
|
||||
if (sprite.LayerMapTryGet(GunVisualLayers.TwoModeSecond, out var _))
|
||||
{
|
||||
sprite.LayerSetVisible(GunVisualLayers.TwoModeFirst, false);
|
||||
sprite.LayerSetVisible(GunVisualLayers.TwoModeSecond, true);
|
||||
sprite.LayerSetState(GunVisualLayers.TwoModeSecond, $"{component.MagState}-twomode2-{step}");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -93,6 +136,16 @@ public sealed partial class GunSystem
|
||||
{
|
||||
sprite.LayerSetVisible(GunVisualLayers.MagUnshaded, false);
|
||||
}
|
||||
|
||||
if (sprite.LayerMapTryGet(GunVisualLayers.TwoModeFirst, out _))
|
||||
{
|
||||
sprite.LayerSetVisible(GunVisualLayers.TwoModeFirst, false);
|
||||
}
|
||||
|
||||
if (sprite.LayerMapTryGet(GunVisualLayers.TwoModeSecond, out _))
|
||||
{
|
||||
sprite.LayerSetVisible(GunVisualLayers.TwoModeSecond, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user