Вернуть трейлы от пуль (#270)

* - add: Bring back bullet trails.

* - add: Cvar, thinner trails.

* - add: Add option.
This commit is contained in:
Aviu00
2024-06-04 11:00:48 +00:00
committed by GitHub
parent cfd9b19da0
commit 9d1c014938
18 changed files with 103 additions and 42 deletions

View File

@@ -40,6 +40,7 @@
<CheckBox Name="ParallaxLowQualityCheckBox" Text="{Loc 'ui-options-parallax-low-quality'}" />
<CheckBox Name="FpsCounterCheckBox" Text="{Loc 'ui-options-fps-counter'}" />
<CheckBox Name="LogInChatCheckBox" Text="Логировать действия в чат" />
<CheckBox Name="ShowTrailsCheckBox" Text="Отображать трейлы от пуль" />
</BoxContainer>
<controls:StripeBack HasBottomEdge="False" HasMargins="False">
<Button Name="ApplyButton"

View File

@@ -74,6 +74,7 @@ namespace Content.Client.Options.UI.Tabs
ParallaxLowQualityCheckBox.OnToggled += OnCheckBoxToggled;
FpsCounterCheckBox.OnToggled += OnCheckBoxToggled;
LogInChatCheckBox.OnToggled += OnCheckBoxToggled;
ShowTrailsCheckBox.OnToggled += OnCheckBoxToggled;
ApplyButton.OnPressed += OnApplyButtonPressed;
VSyncCheckBox.Pressed = _cfg.GetCVar(CVars.DisplayVSync);
FullscreenCheckBox.Pressed = ConfigIsFullscreen;
@@ -86,6 +87,7 @@ namespace Content.Client.Options.UI.Tabs
ParallaxLowQualityCheckBox.Pressed = _cfg.GetCVar(CCVars.ParallaxLowQuality);
FpsCounterCheckBox.Pressed = _cfg.GetCVar(CCVars.HudFpsCounterVisible);
LogInChatCheckBox.Pressed = _cfg.GetCVar(WhiteCVars.LogChatActions);
ShowTrailsCheckBox.Pressed = _cfg.GetCVar(WhiteCVars.ShowTrails);
ViewportWidthSlider.Value = _cfg.GetCVar(CCVars.ViewportWidth);
_cfg.OnValueChanged(CCVars.ViewportMinimumWidth, _ => UpdateViewportWidthRange());
@@ -119,6 +121,7 @@ namespace Content.Client.Options.UI.Tabs
_cfg.SetCVar(CCVars.ParallaxLowQuality, ParallaxLowQualityCheckBox.Pressed);
_cfg.SetCVar(CCVars.HudFpsCounterVisible, FpsCounterCheckBox.Pressed);
_cfg.SetCVar(WhiteCVars.LogChatActions, LogInChatCheckBox.Pressed);
_cfg.SetCVar(WhiteCVars.ShowTrails, ShowTrailsCheckBox.Pressed);
_cfg.SetCVar(CCVars.ViewportWidth, (int) ViewportWidthSlider.Value);
_cfg.SaveToFile();
@@ -149,6 +152,7 @@ namespace Content.Client.Options.UI.Tabs
var isPLQSame = ParallaxLowQualityCheckBox.Pressed == _cfg.GetCVar(CCVars.ParallaxLowQuality);
var isFpsCounterVisibleSame = FpsCounterCheckBox.Pressed == _cfg.GetCVar(CCVars.HudFpsCounterVisible);
var isLogInChatSame = LogInChatCheckBox.Pressed == _cfg.GetCVar(WhiteCVars.LogChatActions);
var isShowTrailsSame = ShowTrailsCheckBox.Pressed == _cfg.GetCVar(WhiteCVars.ShowTrails);
var isWidthSame = (int) ViewportWidthSlider.Value == _cfg.GetCVar(CCVars.ViewportWidth);
ApplyButton.Disabled = isVSyncSame &&
@@ -162,7 +166,8 @@ namespace Content.Client.Options.UI.Tabs
isPLQSame &&
isFpsCounterVisibleSame &&
isWidthSame &&
isLogInChatSame;
isLogInChatSame &&
isShowTrailsSame;
}
private bool ConfigIsFullscreen =>

View File

@@ -1,6 +1,8 @@
using Content.Client._White.Trail.Line.Manager;
using Content.Shared._White;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
@@ -11,6 +13,9 @@ public sealed class TrailOverlay : Overlay
private readonly IPrototypeManager _protoManager;
private readonly IResourceCache _cache;
private readonly ITrailLineManager _lineManager;
private readonly IConfigurationManager _cfg;
private bool _showTrails;
private readonly Dictionary<string, ShaderInstance?> _shaderDict;
private readonly Dictionary<string, Texture?> _textureDict;
@@ -20,13 +25,17 @@ public sealed class TrailOverlay : Overlay
public TrailOverlay(
IPrototypeManager protoManager,
IResourceCache cache,
IConfigurationManager cfg,
ITrailLineManager lineManager
)
{
_protoManager = protoManager;
_cache = cache;
_cfg = cfg;
_lineManager = lineManager;
_cfg.OnValueChanged(WhiteCVars.ShowTrails, val => _showTrails = val, true);
_shaderDict = new Dictionary<string, ShaderInstance?>();
_textureDict = new Dictionary<string, Texture?>();
@@ -38,6 +47,9 @@ public sealed class TrailOverlay : Overlay
var handle = args.WorldHandle;
foreach (var item in _lineManager.Lines)
{
if (!_showTrails && item.Settings.OptionsConcealable)
continue;
item.Render(handle, GetCachedTexture(item.Settings.TexurePath ?? ""));
}
}

View File

@@ -2,6 +2,7 @@ using Content.Client._White.Trail.Line.Manager;
using Content.Shared._White.Trail;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared.Configuration;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
@@ -23,6 +24,7 @@ public sealed class TrailSystem : EntitySystem
new TrailOverlay(
IoCManager.Resolve<IPrototypeManager>(),
IoCManager.Resolve<IResourceCache>(),
IoCManager.Resolve<IConfigurationManager>(),
_lineManager
));

View File

@@ -21,6 +21,7 @@ public sealed partial class TrailComponent : SharedTrailComponent
TexurePath = defaultTrail.TexurePath;
Gradient = defaultTrail.Gradient;
GradientIteratorType = defaultTrail.GradientIteratorType;
OptionsConcealable = defaultTrail.OptionsConcealable;
}
public override Vector2 Gravity { get; set; }
@@ -48,4 +49,6 @@ public sealed partial class TrailComponent : SharedTrailComponent
public override TrailSplineRendererType SplineRendererType { get; set; }
public override Spline4DType GradientIteratorType { get; set; }
public override bool OptionsConcealable { get; set; }
}

View File

@@ -60,6 +60,9 @@ public abstract partial class SharedTrailComponent : Component, ITrailSettings
[DataField("splineRendererType")]
[ViewVariables(VVAccess.ReadWrite)]
public virtual TrailSplineRendererType SplineRendererType { get; set; }
[DataField, ViewVariables(VVAccess.ReadWrite)]
public virtual bool OptionsConcealable { get; set; }
}
[Serializable, NetSerializable]

View File

@@ -37,6 +37,8 @@ public sealed partial class TrailSettings : ITrailSettings
public TrailSplineRendererType SplineRendererType { get; set; }
public bool OptionsConcealable { get; set; }
public static void Inject(ITrailSettings into, ITrailSettings from)
{
into.Scale = from.Scale;
@@ -51,6 +53,7 @@ public sealed partial class TrailSettings : ITrailSettings
into.Gradient = from.Gradient;
into.SplineIteratorType = from.SplineIteratorType;
into.SplineRendererType = from.SplineRendererType;
into.OptionsConcealable = from.OptionsConcealable;
}
}
@@ -81,6 +84,8 @@ public interface ITrailSettings
Spline2DType SplineIteratorType { get; set; }
TrailSplineRendererType SplineRendererType { get; set; }
bool OptionsConcealable { get; set; }
}
public enum SegmentCreationMethod : byte

View File

@@ -12,6 +12,13 @@ namespace Content.Shared._White;
[CVarDefs]
public sealed class WhiteCVars
{
/*
* Bullet trails
*/
public static readonly CVarDef<bool> ShowTrails =
CVarDef.Create("white.show_trails", true, CVar.CLIENTONLY | CVar.ARCHIVE);
/*
* Wiki rules
*/

View File

@@ -1,6 +1,6 @@
- type: entity
noSpawn: true
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
id: BulletAntiMateriel
name: bullet (.60 anti-materiel)
components:

View File

@@ -1,7 +1,7 @@
- type: entity
id: BulletCaselessRifle
name: bullet (.25 caseless)
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -12,7 +12,7 @@
- type: entity
id: BulletCaselessRiflePractice
name: bullet (.25 caseless practice)
parent: BaseBulletPractice
parent: [BaseBulletPractice, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -23,7 +23,7 @@
- type: entity
id: BulletCaselessRifleRubber
name: bullet (.25 caseless rubber)
parent: BaseBulletRubber
parent: [BaseBulletRubber, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile

View File

@@ -2,7 +2,7 @@
id: PelletClusterRubber
name: pellet (ball, Rubber)
noSpawn: true
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
components:
- type: Sprite
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
@@ -23,7 +23,7 @@
id: PelletClusterLethal
name: pellet (ball, Lethal)
noSpawn: true
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
components:
- type: Sprite
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
@@ -41,7 +41,7 @@
id: PelletClusterIncendiary
name: pellet (ball, incendiary)
noSpawn: true
parent: BaseBulletIncendiary
parent: [BaseBulletIncendiary, BaseBulletTrail]
components:
- type: Sprite
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi

View File

@@ -1,7 +1,7 @@
- type: entity
id: BulletHeavyRifle
name: bullet (.20 rifle)
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -12,7 +12,7 @@
- type: entity
id: BulletMinigun
name: minigun bullet (.10 rifle)
parent: BulletHeavyRifle
parent: [BulletHeavyRifle, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile

View File

@@ -1,7 +1,7 @@
- type: entity
id: BulletLightRifle
name: bullet (.20 rifle)
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -12,7 +12,7 @@
- type: entity
id: BulletLightRiflePractice
name: bullet (.20 rifle practice)
parent: BaseBulletPractice
parent: [BaseBulletPractice, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -23,7 +23,7 @@
- type: entity
id: BulletLightRifleRubber
name: bullet (.20 rifle rubber)
parent: BaseBulletRubber
parent: [BaseBulletRubber, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -33,7 +33,7 @@
- type: entity
id: BulletLightRifleIncendiary
parent: BaseBulletIncendiary
parent: [BaseBulletIncendiary, BaseBulletTrail]
name: bullet (.20 rifle incendiary)
noSpawn: true
components:
@@ -45,7 +45,7 @@
- type: entity
id: BulletLightRifleUranium
parent: BaseBulletUranium
parent: [BaseBulletUranium, BaseBulletTrail]
name: bullet (.20 rifle uranium)
noSpawn: true
components:

View File

@@ -1,7 +1,7 @@
- type: entity
id: BulletMagnum
name: bullet (.45 magnum)
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -12,7 +12,7 @@
- type: entity
id: BulletMagnumPractice
name: bullet (.45 magnum practice)
parent: BaseBulletPractice
parent: [BaseBulletPractice, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -23,7 +23,7 @@
- type: entity
id: BulletMagnumRubber
name: bullet (.45 magnum rubber)
parent: BaseBulletRubber
parent: [BaseBulletRubber, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -36,7 +36,7 @@
- type: entity
id: BulletMagnumIncendiary
parent: BaseBulletIncendiary
parent: [BaseBulletIncendiary, BaseBulletTrail]
name: bullet (.45 magnum incendiary)
noSpawn: true
components:
@@ -49,7 +49,7 @@
- type: entity
id: BulletMagnumAP
name: bullet (.45 magnum armor-piercing)
parent: BaseBulletAP
parent: [BaseBulletAP, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -61,7 +61,7 @@
- type: entity
id: BulletMagnumUranium
name: bullet (.45 magnum uranium)
parent: BaseBulletUranium
parent: [BaseBulletUranium, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile

View File

@@ -1,7 +1,7 @@
- type: entity
id: BulletPistol
name: bullet (.35 auto)
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -12,7 +12,7 @@
- type: entity
id: BulletPistolPractice
name: bullet (.35 auto practice)
parent: BaseBulletPractice
parent: [BaseBulletPractice, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -23,7 +23,7 @@
- type: entity
id: BulletPistolRubber
name: bullet (.35 auto rubber)
parent: BaseBulletRubber
parent: [BaseBulletRubber, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -33,7 +33,7 @@
- type: entity
id: BulletPistolIncendiary
parent: BaseBulletIncendiary
parent: [BaseBulletIncendiary, BaseBulletTrail]
name: bullet (.35 auto incendiary)
noSpawn: true
components:
@@ -45,7 +45,7 @@
- type: entity
id: BulletPistolUranium
parent: BaseBulletUranium
parent: [BaseBulletUranium, BaseBulletTrail]
name: bullet (.35 auto uranium)
noSpawn: true
components:

View File

@@ -1,7 +1,7 @@
- type: entity
id: BulletRifle
name: bullet (0.20 rifle)
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -12,7 +12,7 @@
- type: entity
id: BulletRiflePractice
name: bullet (0.20 rifle practice)
parent: BaseBulletPractice
parent: [BaseBulletPractice, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -23,7 +23,7 @@
- type: entity
id: BulletRifleRubber
name: bullet (0.20 rifle rubber)
parent: BaseBulletRubber
parent: [BaseBulletRubber, BaseBulletTrail]
noSpawn: true
components:
- type: Projectile
@@ -33,7 +33,7 @@
- type: entity
id: BulletRifleIncendiary
parent: BaseBulletIncendiary
parent: [BaseBulletIncendiary, BaseBulletTrail]
name: bullet (0.20 rifle incendiary)
noSpawn: true
components:
@@ -42,10 +42,10 @@
types:
Blunt: 2
Heat: 15
- type: entity
id: BulletRifleUranium
parent: BaseBulletUranium
parent: [BaseBulletUranium, BaseBulletTrail]
name: bullet (0.20 rifle uranium)
noSpawn: true
components:
@@ -54,4 +54,4 @@
types:
Radiation: 7
Piercing: 8

View File

@@ -2,7 +2,7 @@
id: PelletShotgunSlug
name: pellet (.50 slug)
noSpawn: true
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
components:
- type: Sprite
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
@@ -16,7 +16,7 @@
id: PelletShotgunBeanbag
name: beanbag (.50)
noSpawn: true
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
components:
- type: Sprite
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
@@ -33,7 +33,7 @@
id: PelletShotgun
name: pellet (.50)
noSpawn: true
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
components:
- type: Sprite
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
@@ -47,7 +47,7 @@
id: PelletShotgunIncendiary
name: pellet (.50 incendiary)
noSpawn: true
parent: BaseBulletIncendiary
parent: [BaseBulletIncendiary, BaseBulletTrail]
components:
- type: Sprite
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
@@ -64,7 +64,7 @@
id: PelletShotgunPractice
name: pellet (.50 practice)
noSpawn: true
parent: BaseBulletPractice
parent: [BaseBulletPractice, BaseBulletTrail]
components:
- type: Sprite
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
@@ -78,7 +78,7 @@
id: PelletShotgunImprovised
name: improvised pellet
noSpawn: true
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
components:
- type: Sprite
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
@@ -93,7 +93,7 @@
id: PelletShotgunTranquilizer
name: pellet (.50 tranquilizer)
noSpawn: true
parent: BaseBulletPractice
parent: [BaseBulletPractice, BaseBulletTrail]
components:
- type: Sprite
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
@@ -167,7 +167,7 @@
id: PelletShotgunUranium
name: pellet (.50 uranium)
noSpawn: true
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
components:
- type: Sprite
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
@@ -182,7 +182,7 @@
id: PelletGrapeshot #tally fucking ho
name: grapeshot pellet
noSpawn: true
parent: BaseBullet
parent: [BaseBullet, BaseBulletTrail]
components:
- type: Sprite
noRot: false

View File

@@ -0,0 +1,23 @@
- type: entity
noSpawn: true
abstract: true
id: BaseBulletTrail
name: BaseBulletTrail
components:
- type: Trail
splineIteratorType: CatmullRom
splineRendererType: Continuous
creationMethod: OnMove
lengthStep: 0.1
scale: 0.03, 0.0
lifetime: 1
randomWalk: 0.03, 0.001
gravity: 0.001, 0.005
texturePath: /Textures/White/Effects/Trails/Continuous/trail.png
gradientIteratorType: Bezier
gradient:
- 1, 1, 1, 0
- 1, 1, 1, 2
- 1, 1, 1, 0
- 1, 1, 1, 0
optionsConcealable: true