-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
1,207 additions
and
10 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
Content.Client/_Sunrise/Overlays/SaturationScaleOverlay.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,52 @@ | ||
using System.Numerics; | ||
using Content.Shared._Sunrise.Mood; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client._Sunrise.Overlays; | ||
|
||
public sealed class SaturationScaleOverlay : Overlay | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
[Dependency] IEntityManager _entityManager = default!; | ||
|
||
public override bool RequestScreenTexture => true; | ||
public override OverlaySpace Space => OverlaySpace.WorldSpace; | ||
private readonly ShaderInstance _shader; | ||
private const float Saturation = 0.5f; | ||
|
||
|
||
public SaturationScaleOverlay() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
|
||
_shader = _prototypeManager.Index<ShaderPrototype>("SaturationScale").Instance().Duplicate(); | ||
} | ||
|
||
protected override bool BeforeDraw(in OverlayDrawArgs args) | ||
{ | ||
if (_playerManager.LocalEntity is not { Valid: true } player | ||
|| !_entityManager.HasComponent<SaturationScaleOverlayComponent>(player)) | ||
return false; | ||
|
||
return base.BeforeDraw(in args); | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
if (ScreenTexture is null) | ||
return; | ||
|
||
_shader.SetParameter("SCREEN_TEXTURE", ScreenTexture); | ||
_shader.SetParameter("saturation", Saturation); | ||
|
||
var handle = args.WorldHandle; | ||
handle.SetTransform(Matrix3x2.Identity); | ||
handle.UseShader(_shader); | ||
handle.DrawRect(args.WorldBounds, Color.White); | ||
handle.UseShader(null); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
Content.Client/_Sunrise/Overlays/Systems/SaturationScaleSystem.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,62 @@ | ||
using Content.Shared._Sunrise.Mood; | ||
using Content.Shared.GameTicking; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Player; | ||
|
||
namespace Content.Client._Sunrise.Overlays.Systems; | ||
|
||
public sealed class SaturationScaleSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IOverlayManager _overlayMan = default!; | ||
[Dependency] private readonly ISharedPlayerManager _playerMan = default!; | ||
|
||
private SaturationScaleOverlay _overlay = default!; | ||
|
||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
_overlay = new(); | ||
|
||
SubscribeLocalEvent<SaturationScaleOverlayComponent, ComponentInit>(OnInit); | ||
SubscribeLocalEvent<SaturationScaleOverlayComponent, ComponentShutdown>(OnShutdown); | ||
|
||
SubscribeLocalEvent<SaturationScaleOverlayComponent, PlayerAttachedEvent>(OnPlayerAttached); | ||
SubscribeLocalEvent<SaturationScaleOverlayComponent, PlayerDetachedEvent>(OnPlayerDetached); | ||
|
||
SubscribeNetworkEvent<RoundRestartCleanupEvent>(RoundRestartCleanup); | ||
} | ||
|
||
|
||
private void RoundRestartCleanup(RoundRestartCleanupEvent ev) | ||
{ | ||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
|
||
private void OnPlayerDetached(EntityUid uid, SaturationScaleOverlayComponent component, PlayerDetachedEvent args) | ||
{ | ||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
|
||
private void OnPlayerAttached(EntityUid uid, SaturationScaleOverlayComponent component, PlayerAttachedEvent args) | ||
{ | ||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
|
||
private void OnShutdown(EntityUid uid, SaturationScaleOverlayComponent component, ComponentShutdown args) | ||
{ | ||
if (uid != _playerMan.LocalEntity) | ||
return; | ||
|
||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
|
||
private void OnInit(EntityUid uid, SaturationScaleOverlayComponent component, ComponentInit args) | ||
{ | ||
if (uid != _playerMan.LocalEntity) | ||
return; | ||
|
||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
} |
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
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,112 @@ | ||
using Content.Shared.Alert; | ||
using Content.Shared.FixedPoint; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Generic; | ||
|
||
namespace Content.Server._Sunrise.Mood; | ||
|
||
[RegisterComponent] | ||
public sealed partial class MoodComponent : Component | ||
{ | ||
[DataField] | ||
public float CurrentMoodLevel; | ||
|
||
[DataField] | ||
public MoodThreshold CurrentMoodThreshold; | ||
|
||
[DataField] | ||
public MoodThreshold LastThreshold; | ||
|
||
[ViewVariables(VVAccess.ReadOnly)] | ||
public readonly Dictionary<string, string> CategorisedEffects = new(); | ||
|
||
[ViewVariables(VVAccess.ReadOnly)] | ||
public readonly Dictionary<string, float> UncategorisedEffects = new(); | ||
|
||
/// <summary> | ||
/// The formula for the movement speed modifier is SpeedBonusGrowth ^ (MoodLevel - MoodThreshold.Neutral). | ||
/// Change this ONLY BY 0.001 AT A TIME. | ||
/// </summary> | ||
[DataField] | ||
public float SpeedBonusGrowth = 1.003f; | ||
|
||
/// <summary> | ||
/// The lowest point that low morale can multiply our movement speed by. Lowering speed follows a linear curve, rather than geometric. | ||
/// </summary> | ||
[DataField] | ||
public float MinimumSpeedModifier = 0.75f; | ||
|
||
/// <summary> | ||
/// The maximum amount that high morale can multiply our movement speed by. This follows a significantly slower geometric sequence. | ||
/// </summary> | ||
[DataField] | ||
public float MaximumSpeedModifier = 1.15f; | ||
|
||
[DataField] | ||
public float IncreaseCritThreshold = 1.2f; | ||
|
||
[DataField] | ||
public float DecreaseCritThreshold = 0.9f; | ||
|
||
[ViewVariables(VVAccess.ReadOnly)] | ||
public FixedPoint2 CritThresholdBeforeModify; | ||
|
||
[DataField(customTypeSerializer: typeof(DictionarySerializer<MoodThreshold, float>))] | ||
public Dictionary<MoodThreshold, float> MoodThresholds = new() | ||
{ | ||
{ MoodThreshold.Perfect, 100f }, | ||
{ MoodThreshold.Exceptional, 80f }, | ||
{ MoodThreshold.Great, 70f }, | ||
{ MoodThreshold.Good, 60f }, | ||
{ MoodThreshold.Neutral, 50f }, | ||
{ MoodThreshold.Meh, 40f }, | ||
{ MoodThreshold.Bad, 30f }, | ||
{ MoodThreshold.Terrible, 20f }, | ||
{ MoodThreshold.Horrible, 10f }, | ||
{ MoodThreshold.Dead, 0f } | ||
}; | ||
|
||
[DataField(customTypeSerializer: typeof(DictionarySerializer<MoodThreshold, ProtoId<AlertPrototype>>))] | ||
public Dictionary<MoodThreshold, ProtoId<AlertPrototype>> MoodThresholdsAlerts = new() | ||
{ | ||
{ MoodThreshold.Dead, "MoodDead" }, | ||
{ MoodThreshold.Horrible, "Horrible" }, | ||
{ MoodThreshold.Terrible, "Terrible" }, | ||
{ MoodThreshold.Bad, "Bad" }, | ||
{ MoodThreshold.Meh, "Meh" }, | ||
{ MoodThreshold.Neutral, "Neutral" }, | ||
{ MoodThreshold.Good, "Good" }, | ||
{ MoodThreshold.Great, "Great" }, | ||
{ MoodThreshold.Exceptional, "Exceptional" }, | ||
{ MoodThreshold.Perfect, "Perfect" }, | ||
{ MoodThreshold.Insane, "Insane" } | ||
}; | ||
|
||
/// <summary> | ||
/// These thresholds represent a percentage of Crit-Threshold, 0.8 corresponding with 80%. | ||
/// </summary> | ||
[DataField(customTypeSerializer: typeof(DictionarySerializer<string, float>))] | ||
public Dictionary<string, float> HealthMoodEffectsThresholds = new() | ||
{ | ||
{ "HealthHeavyDamage", 0.8f }, | ||
{ "HealthSevereDamage", 0.5f }, | ||
{ "HealthLightDamage", 0.1f }, | ||
{ "HealthNoDamage", 0.05f } | ||
}; | ||
} | ||
|
||
[Serializable] | ||
public enum MoodThreshold : ushort | ||
{ | ||
Insane = 1, | ||
Horrible = 2, | ||
Terrible = 3, | ||
Bad = 4, | ||
Meh = 5, | ||
Neutral = 6, | ||
Good = 7, | ||
Great = 8, | ||
Exceptional = 9, | ||
Perfect = 10, | ||
Dead = 0 | ||
} |
Oops, something went wrong.