Skip to content

Commit

Permalink
В игру добавлен афродезиак. (#148)
Browse files Browse the repository at this point in the history
* базовый оверлей (без реагента и очков)

* Оно и не крашится и не работает ._.

* Оно не крашится И оно работает

* locale fix

* Бутылочка с афродезиаком
  • Loading branch information
pxc1984 authored Jun 26, 2024
1 parent 23ac842 commit c25ce2d
Show file tree
Hide file tree
Showing 16 changed files with 249 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Content.Client/_Sunrise/Overlays/LoveVisionOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Content.Shared._Sunrise.Aphrodesiac;
using System.Numerics;

namespace Content.Client._Sunrise.LoveVision;

public sealed class LoveVisionOverlay : 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 _loveVisionShader;

public LoveVisionOverlay()
{
IoCManager.InjectDependencies(this);
_loveVisionShader = _prototypeManager.Index<ShaderPrototype>("LoveVision").Instance().Duplicate();
}

protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture == null)
return;
if (_playerManager.LocalSession?.AttachedEntity is not { Valid: true } player)
return;
if (!_entityManager.HasComponent<LoveVisionComponent>(player))
return;
_loveVisionShader?.SetParameter("SCREEN_TEXTURE", ScreenTexture);
var worldHandle = args.WorldHandle;
var viewport = args.WorldBounds;
worldHandle.SetTransform(Matrix3x2.Identity);
worldHandle.UseShader(_loveVisionShader);
worldHandle.DrawRect(viewport, Color.White);
}
}
51 changes: 51 additions & 0 deletions Content.Client/_Sunrise/Overlays/Systems/LoveVisionSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Content.Shared._Sunrise.Aphrodesiac;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Player;

namespace Content.Client._Sunrise.LoveVision;
public sealed class LoveVisionSystem : EntitySystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IOverlayManager _overlayMan = default!;

private LoveVisionOverlay _overlay = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<LoveVisionComponent, ComponentInit>(OnLoveVisionInit);
SubscribeLocalEvent<LoveVisionComponent, ComponentShutdown>(OnLoveVisionShutdown);

SubscribeLocalEvent<LoveVisionComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<LoveVisionComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);

_overlay = new();
}

private void OnPlayerAttached(EntityUid uid, LoveVisionComponent component, LocalPlayerAttachedEvent args)
{
_overlayMan.AddOverlay(_overlay);
}

private void OnPlayerDetached(EntityUid uid, LoveVisionComponent component, LocalPlayerDetachedEvent args)
{
_overlayMan.RemoveOverlay(_overlay);
}

private void OnLoveVisionInit(EntityUid uid, LoveVisionComponent component, ComponentInit args)
{
if (_player.LocalSession?.AttachedEntity == uid)
_overlayMan.AddOverlay(_overlay);
}

private void OnLoveVisionShutdown(EntityUid uid, LoveVisionComponent component, ComponentShutdown args)
{
if (_player.LocalSession?.AttachedEntity == uid)
{
_overlayMan.RemoveOverlay(_overlay);
}
}
}
7 changes: 7 additions & 0 deletions Content.Server/_Sunrise/Aphrodesiac/AphrodesiacSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Content.Shared._Sunrise.Aphrodesiac;

namespace Content.Server._Sunrise.Aphrodesiac;

public sealed class AphrodesiacSystem : SharedAphrodesiacSystem
{
}
23 changes: 23 additions & 0 deletions Content.Server/_Sunrise/ReagentEffects/LoveEffect.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Content.Shared.Chemistry.Reagent;
using Content.Shared._Sunrise.Aphrodesiac;
using Robust.Shared.Prototypes;

namespace Content.Server.Chemistry.ReagentEffects;

public sealed partial class LoveEffect : ReagentEffect
{
[DataField]
public float EffectPower = 3f;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-love");

public override void Effect(ReagentEffectArgs args)
{
var effectPower = EffectPower;

effectPower *= args.Scale;

var loveVisionSys = args.EntityManager.EntitySysManager.GetEntitySystem<SharedAphrodesiacSystem>();
loveVisionSys.TryApplyLoveenness(args.SolutionEntity, effectPower);
}
}
9 changes: 9 additions & 0 deletions Content.Shared/_Sunrise/Abilities/LoveVisionComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Robust.Shared.GameStates;

namespace Content.Shared._Sunrise.Aphrodesiac;

[RegisterComponent, NetworkedComponent]
public sealed partial class LoveVisionComponent : Component
{

}
38 changes: 38 additions & 0 deletions Content.Shared/_Sunrise/Aphrodesiac/SharedAphrodesiacSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Content.Shared.Speech.EntitySystems;
using Content.Shared.StatusEffect;
using Content.Shared.Traits.Assorted;

namespace Content.Shared._Sunrise.Aphrodesiac;

public abstract class SharedAphrodesiacSystem : EntitySystem
{
[ValidatePrototypeId<StatusEffectPrototype>]
public const string LoveKey = "LoveEffect";

[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;

public void TryApplyLoveenness(EntityUid uid, float effectPower, StatusEffectsComponent? status = null)
{
if (!Resolve(uid, ref status, false))
return;

if (!_statusEffectsSystem.HasStatusEffect(uid, LoveKey, status))
{
_statusEffectsSystem.TryAddStatusEffect<LoveVisionComponent>(uid, LoveKey, TimeSpan.FromSeconds(effectPower), true, status);
}
else
{
_statusEffectsSystem.TryAddTime(uid, LoveKey, TimeSpan.FromSeconds(effectPower), status);
}
}

public void TryRemoveLovenness(EntityUid uid)
{
_statusEffectsSystem.TryRemoveStatusEffect(uid, LoveKey);
}
public void TryRemoveLovenessTime(EntityUid uid, double timeRemoved)
{
_statusEffectsSystem.TryRemoveTime(uid, LoveKey, TimeSpan.FromSeconds(timeRemoved));
}

}
10 changes: 10 additions & 0 deletions Resources/Locale/en-US/_sunrise/aphrodesiac/aphrodesiac.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
reagent-name-aphrodesiac = Aphrodesiac
reagent-desc-aphrodesiac = A substance that increases arousal or pleasure.
reagent-physical-desc-aphrodesiac = Shimmering, ruby-red liquid that glows softly in the light.
aphrodesiac-effect1 = Your skin tingles warmly.
aphrodesiac-effect2 = Your heart is racing fast.
reagent-effect-guidebook-love =
{ $chance ->
[1] Causes
*[other] cause
} subject to fall in love.
12 changes: 12 additions & 0 deletions Resources/Locale/ru-RU/_sunrise/aphrodesiac/aphrodesiac.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
reagent-name-aphrodesiac = Афродезиак
reagent-desc-aphrodesiac = Вещество, которое усиливает возбуждение или удовольствие.
reagent-physical-desc-aphrodesiac = Мерцающая, рубиново-красная жидкость, мягко светящаяся на свету.
aphrodesiac-effect1 = Ваша кожа приятно покалывает.
aphrodesiac-effect2 = Ваше сердце быстро бьется.
reagent-effect-guidebook-love =
{ $chance ->
[1] Вызывает
*[other] вызывают
} измененное состояние сознания.
ent-AphrodesiacChemistryBottle = бутылочка афродезиака
.desc = { ent-BaseChemistryBottleFilled.desc }
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
- Pacified
- StaminaModifier
- Flashed
- LoveEffect # Sunrise-Aphrodesiac
- type: Reflect
enabled: false
reflectProb: 0
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Shaders/lovevision.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- type: shader
id: LoveVision
kind: source
path: "/Textures/Shaders/lovevision.swsl"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- type: entity
id: AphrodesiacChemistryBottle
name: aphrodesiac bottle
parent: BaseChemistryBottleFilled
components:
- type: SolutionContainerManager
solutions:
drink:
maxVol: 30
reagents:
- ReagentId: Aphrodesiac
Quantity: 30
17 changes: 17 additions & 0 deletions Resources/Prototypes/_Sunrise/Reagents/fun.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- type: reagent
id: Aphrodesiac
name: reagent-name-aphrodesiac
group: Special
desc: reagent-desc-aphrodesiac
physicalDesc: reagent-physical-desc-aphrodesiac
flavor: funny
color: "#FF00E8"
metabolisms:
Poison:
effects:
- !type:PopupMessage
type: Local
messages: [ "aphrodesiac-effect1", "aphrodesiac-effect2" ]
probability: 0.1
- !type:LoveEffect
effectPower: 2
9 changes: 9 additions & 0 deletions Resources/Prototypes/_Sunrise/Recipes/Reactions/fun.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- type: reaction
id: Aphrodesiac
reactants:
Omnizine:
amount: 2
Leporazine:
amount: 3
products:
Aphrodesiac: 5
2 changes: 2 additions & 0 deletions Resources/Prototypes/_Sunrise/status_effects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- type: statusEffect
id: LoveEffect
14 changes: 14 additions & 0 deletions Resources/Textures/Shaders/lovevision.swsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uniform sampler2D SCREEN_TEXTURE;

void fragment() {
highp vec4 color = zTextureSpec(SCREEN_TEXTURE, UV);

highp mat3 m = mat3(
vec3(1.0, 0.3, 0.3),
vec3(0.6, 0.3, 0.3),
vec3(0.6, 0.3, 1.0)
);
highp vec3 result = color.rgb * m;

COLOR = vec4(result, 1.0);
}

0 comments on commit c25ce2d

Please sign in to comment.