Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mood #545

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

mood #545

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions Content.Client/_Sunrise/Overlays/SaturationScaleOverlay.cs
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);
}
}
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);
}
}
4 changes: 4 additions & 0 deletions Content.Server/Arcade/BlockGame/BlockGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Robust.Server.GameObjects;
using Robust.Shared.Random;
using System.Linq;
using Content.Shared._Sunrise.Mood;

namespace Content.Server.Arcade.BlockGame;

Expand Down Expand Up @@ -82,6 +83,9 @@ private void InvokeGameover()
{
_highScorePlacement = _arcadeSystem.RegisterHighScore(meta.EntityName, Points);
SendHighscoreUpdate();

var ev = new MoodEffectEvent("ArcadePlay"); // Sunrise Edit
_entityManager.EventBus.RaiseLocalEvent(meta.Owner, ev); // Sunrise Edit
}
SendMessage(new BlockGameMessages.BlockGameGameOverScreenMessage(Points, _highScorePlacement?.LocalPlacement, _highScorePlacement?.GlobalPlacement));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Shared.UserInterface;
using Content.Server.Advertise;
using Content.Server.Advertise.Components;
using Content.Shared._Sunrise.Mood;
using Content.Shared.Power;
using static Content.Shared.Arcade.SharedSpaceVillainArcadeComponent;
using Robust.Server.GameObjects;
Expand Down Expand Up @@ -77,6 +78,8 @@ private void OnSVPlayerAction(EntityUid uid, SpaceVillainArcadeComponent compone
if (!TryComp<ApcPowerReceiverComponent>(uid, out var power) || !power.Powered)
return;

RaiseLocalEvent(msg.Actor, new MoodEffectEvent("ArcadePlay"));

switch (msg.PlayerAction)
{
case PlayerAction.Attack:
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.Administration.Logs;
using Content.Server.Atmos.Components;
using Content.Shared._Sunrise.Mood;
using Content.Shared.Alert;
using Content.Shared.Atmos;
using Content.Shared.Damage;
Expand Down Expand Up @@ -245,6 +246,7 @@ public override void Update(float frameTime)
_adminLogger.Add(LogType.Barotrauma, $"{ToPrettyString(uid):entity} started taking low pressure damage");
}

RaiseLocalEvent(uid, new MoodEffectEvent("MobLowPressure")); // Sunrise Edit
_alertsSystem.ShowAlert(uid, barotrauma.LowPressureAlert, 2);
}
else if (pressure >= Atmospherics.HazardHighPressure)
Expand All @@ -260,6 +262,7 @@ public override void Update(float frameTime)
_adminLogger.Add(LogType.Barotrauma, $"{ToPrettyString(uid):entity} started taking high pressure damage");
}

RaiseLocalEvent(uid, new MoodEffectEvent("MobHighPressure")); // Sunrise Edit
_alertsSystem.ShowAlert(uid, barotrauma.HighPressureAlert, 2);
}
else
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Atmos/EntitySystems/FlammableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Server.Temperature.Components;
using Content.Server.Temperature.Systems;
using Content.Server.Damage.Components;
using Content.Shared._Sunrise.Mood;
using Content.Shared.ActionBlocker;
using Content.Shared.Alert;
using Content.Shared.Atmos;
Expand Down Expand Up @@ -425,10 +426,12 @@ public override void Update(float frameTime)

if (!flammable.OnFire)
{
RaiseLocalEvent(uid, new MoodRemoveEffectEvent("OnFire")); // Sunrise Edit
_alertsSystem.ClearAlert(uid, flammable.FireAlert);
continue;
}

RaiseLocalEvent(uid, new MoodEffectEvent("OnFire")); // Sunrise Edit
_alertsSystem.ShowAlert(uid, flammable.FireAlert);

if (flammable.FireStacks > 0)
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Bible/BibleSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Server.Bible.Components;
using Content.Server.Ghost.Roles.Events;
using Content.Server.Popups;
using Content.Shared._Sunrise.Mood;
using Content.Shared.ActionBlocker;
using Content.Shared.Actions;
using Content.Shared.Bible;
Expand Down Expand Up @@ -153,6 +154,8 @@ private void OnAfterInteract(EntityUid uid, BibleComponent component, AfterInter
_audio.PlayPvs(component.HealSoundPath, args.User);
_delay.TryResetDelay((uid, useDelay));
}

RaiseLocalEvent(args.Target.Value, new MoodEffectEvent("GotBlessed")); // Sunrise Edit
}

private void AddSummonVerb(EntityUid uid, SummonableComponent component, GetVerbsEvent<AlternativeVerb> args)
Expand Down
2 changes: 2 additions & 0 deletions Content.Server/Body/Systems/RespiratorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Server.Chat.Systems;
using Content.Server.EntityEffects.EffectConditions;
using Content.Server.EntityEffects.Effects;
using Content.Shared._Sunrise.Mood;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Alert;
using Content.Shared.Atmos;
Expand Down Expand Up @@ -315,6 +316,7 @@ private void TakeSuffocationDamage(Entity<RespiratorComponent> ent)
{
_alertsSystem.ShowAlert(ent, entity.Comp1.Alert);
}
RaiseLocalEvent(ent, new MoodEffectEvent("Suffocating"));
}

_damageableSys.TryChangeDamage(ent, ent.Comp.Damage, interruptsDoAfters: false);
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Medical/VomitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Server.Forensics;
using Content.Server.Popups;
using Content.Server.Stunnable;
using Content.Shared._Sunrise.Mood;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
Expand Down Expand Up @@ -96,6 +97,8 @@ public void Vomit(EntityUid uid, float thirstAdded = -40f, float hungerAdded = -
// Force sound to play as spill doesn't work if solution is empty.
_audio.PlayPvs("/Audio/Effects/Fluids/splat.ogg", uid, AudioParams.Default.WithVariation(0.2f).WithVolume(-4f));
_popup.PopupEntity(Loc.GetString("disease-vomit", ("person", Identity.Entity(uid, EntityManager))), uid);

RaiseLocalEvent(uid, new MoodEffectEvent("MobVomit"));
}
}
}
112 changes: 112 additions & 0 deletions Content.Server/_Sunrise/Mood/MoodComponent.cs
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
}
Loading
Loading