Skip to content

Commit

Permalink
Merge pull request #31 from Corvax-Frontier/elzuosa
Browse files Browse the repository at this point in the history
elzuosa upgrade
  • Loading branch information
Sh1ntra committed Sep 2, 2024
2 parents 4962f0f + e56cb35 commit 167c979
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 9 deletions.
17 changes: 11 additions & 6 deletions Content.Server/Corvax/Elzuosa/ElzuosaColorComponent.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Robust.Shared.Audio;
using Robust.Shared.Serialization;

namespace Content.Server.Corvax.Elzuosa
{
Expand All @@ -16,5 +11,15 @@ public sealed partial class ElzuosaColorComponent : Component

[DataField("cycleRate")]
public float CycleRate = 1f;

[DataField("stannedByEMP")]
public bool StannedByEmp = false;
}

/*[Serializable, NetSerializable]
public enum ElzuosaState : byte
{
Normal,
Emagged
}*/
}
106 changes: 104 additions & 2 deletions Content.Server/Corvax/Elzuosa/ElzuosaColorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,121 @@
using Content.Shared.Preferences;
using Robust.Server.GameObjects;
using Content.Server.GameTicking;
using Content.Shared.Damage.Components;
using Content.Shared.Damage.Systems;
using Content.Shared.Emag.Systems;
using Content.Shared.IdentityManagement;
using Content.Shared.Light;
using Content.Shared.Light.Components;
using Content.Shared.Nutrition.Components;
using Content.Shared.Popups;

namespace Content.Server.Corvax.Elzuosa
{
public sealed class ElzuosaColorSystem : EntitySystem
{
[Dependency] private readonly PointLightSystem _pointLightSystem = default!;
[Dependency] private readonly SharedRgbLightControllerSystem _rgbSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly StaminaSystem _stamina = default!;

public bool SelfEmagged;

public StaminaComponent? StaminaComponent;
public HungerComponent? HungerComponent;
private PointLightComponent? _pointLightComponent;

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

SubscribeLocalEvent<ElzuosaColorComponent, GotEmaggedEvent>(OnEmagged);
SubscribeLocalEvent<ElzuosaColorComponent, PlayerSpawnCompleteEvent>(OnPlayerSpawn);
}

public override void Update(float frameTime)
{
base.Update(frameTime);
var query = EntityQueryEnumerator<ElzuosaColorComponent>();
while (query.MoveNext(out var uid, out var elzuosaColorComponent))
{

var hunger = EntityManager.EnsureComponent<HungerComponent>(uid).CurrentHunger;
if (TryComp(uid, out _pointLightComponent))
//Да простит меня боженька...
if(hunger <= 50)
_pointLightSystem.SetRadius(uid,(float)0.5);
else if(hunger <= 55)
_pointLightSystem.SetRadius(uid,(float)1.05);
else if(hunger <= 60)
_pointLightSystem.SetRadius(uid,(float)1.1);
else if(hunger <= 65)
_pointLightSystem.SetRadius(uid,(float)1.2);
else if(hunger <= 70)
_pointLightSystem.SetRadius(uid,(float)1.4);
else if(hunger <= 75)
_pointLightSystem.SetRadius(uid,(float)1.6);
else if(hunger <= 80)
_pointLightSystem.SetRadius(uid,(float)1.8);
else if(hunger <= 85)
_pointLightSystem.SetRadius(uid,(float)2);
else if(hunger > 90)
_pointLightSystem.SetRadius(uid,(float)2.3);

if (elzuosaColorComponent.StannedByEmp)
{
_stamina.TakeStaminaDamage(uid,120,StaminaComponent);
elzuosaColorComponent.StannedByEmp = false;
}
}
}

private void OnEmagged(EntityUid uid, ElzuosaColorComponent comp, ref GotEmaggedEvent args)
{
if ((args.UserUid == uid))
SelfEmagged = true;
else
SelfEmagged = false;

comp.Hacked = !comp.Hacked;



if (SelfEmagged)
{
if (comp.Hacked)
{
_popupSystem.PopupEntity(Loc.GetString("elzuosa-selfemag-success"),uid);
var rgb = EnsureComp<RgbLightControllerComponent>(uid);
_rgbSystem.SetCycleRate(uid, comp.CycleRate, rgb);
}
else
{
_popupSystem.PopupEntity(Loc.GetString("elzuosa-selfdeemag-success"),uid);
RemComp<RgbLightControllerComponent>(uid);
}
}
else
{
if (comp.Hacked)
{
_popupSystem.PopupEntity(Loc.GetString("elzuosa-emag-success",("target", Identity.Entity(uid, EntityManager))),uid,
args.UserUid);
_popupSystem.PopupEntity(Loc.GetString("elzuosa-emagged-success",("user", Identity.Entity(args.UserUid, EntityManager))),args.UserUid,
uid);
var rgb = EnsureComp<RgbLightControllerComponent>(uid);
_rgbSystem.SetCycleRate(uid, comp.CycleRate, rgb);
}
else
{
_popupSystem.PopupEntity(Loc.GetString("elzuosa-deemag-success",("target", Identity.Entity(uid, EntityManager))),uid,
args.UserUid);
_popupSystem.PopupEntity(Loc.GetString("elzuosa-deemagged-success",("user", Identity.Entity(args.UserUid, EntityManager))),args.UserUid,
uid);
RemComp<RgbLightControllerComponent>(uid);
}
}
}

private void OnPlayerSpawn(EntityUid uid, ElzuosaColorComponent comp, PlayerSpawnCompleteEvent args)
{
if (!HasComp<HumanoidAppearanceComponent>(uid))
Expand All @@ -31,7 +134,6 @@ public void SetEntityPointLightColor(EntityUid uid, HumanoidCharacterProfile? pr

var color = profile.Appearance.SkinColor;
_pointLightSystem.SetColor(uid,color);

}
}
}
8 changes: 8 additions & 0 deletions Content.Server/Emp/EmpSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Server.Corvax.Elzuosa; //Corvax-Frontier
using Content.Server.Entry;
using Content.Server.Explosion.EntitySystems;
using Content.Server.Power.EntitySystems;
Expand Down Expand Up @@ -51,6 +52,13 @@ public void EmpPulse(MapCoordinates coordinates, float range, float energyConsum
if (HasComp<StationEmpImmuneComponent>(gridUid))
continue;

//Corvax-Frontier start
if (HasComp<ElzuosaColorComponent>(uid))
if (TryComp(uid, out ElzuosaColorComponent? elzuosaColorComponent))
elzuosaColorComponent.StannedByEmp = true;

//Corvax-Frontier end

TryEmpEffects(uid, energyConsumption, duration);
}
Spawn(EmpPulseEffectPrototype, coordinates);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@

pat-success-elzuosa = вы обнимаете { $target }, чувствуя, как по вам проходит высоковольтный ток.
pat-success-elzuosa-others = { CAPITALIZE($user) } обнимает { $target }, наэлектризовываясь.
pat-success-elzuosa-target = { CAPITALIZE($user) } обнимает вас.
pat-success-elzuosa-target = { CAPITALIZE($user) } обнимает вас.
elzuosa-selfemag-success = Вы успешно себя взломали!
elzuosa-selfdeemag-success = Вы успешно вернули свой цвет!
elzuosa-emag-success = Вы успешно взломали { $target }!
elzuosa-deemag-success = Вы успешно вернули цвет { $target }!
elzuosa-emagged-success = Вас взломал { CAPITALIZE($user) }!
elzuosa-deemagged-success = { CAPITALIZE($user) } вернул ваш цвет!

0 comments on commit 167c979

Please sign in to comment.