Skip to content

Commit

Permalink
Partial Glimmer Refactor & Pyromancy Full Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed Jun 28, 2024
1 parent afff078 commit d0cb65a
Show file tree
Hide file tree
Showing 32 changed files with 317 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public override void Effect(ReagentEffectArgs args)
{
var glimmersys = args.EntityManager.EntitySysManager.GetEntitySystem<GlimmerSystem>();

glimmersys.Glimmer += Count;
glimmersys.DeltaGlimmerInput(Count);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace Content.Server.Objectives.Systems
{
public sealed class RaiseGlimmerConditionSystem : EntitySystem
{
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly GlimmerSystem _glimmer = default!;
public override void Initialize()
{
base.Initialize();
Expand All @@ -32,8 +32,7 @@ private void OnGetProgress(EntityUid uid, RaiseGlimmerConditionComponent comp, r

private float GetProgress(int target)
{
var glimmer = _sysMan.GetEntitySystem<GlimmerSystem>().Glimmer;
var progress = Math.Min((float) glimmer / (float) target, 1f);
var progress = Math.Min((float) _glimmer.GlimmerOutput / (float) target, 1f);
return progress;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Nyanotrasen/Research/Oracle/OracleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private void DispenseLiquidReward(EntityUid uid, OracleComponent component)
.Where(x => !x.Abstract)
.Select(x => x.ID).ToList();

var amount = 20 + _random.Next(1, 30) + _glimmerSystem.Glimmer / 10f;
var amount = 20 + _random.Next(1, 30) + _glimmerSystem.GlimmerOutput / 10f;
amount = (float) Math.Round(amount);

var sol = new Solution();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public override void Update(float frameTime)
{
base.Update(frameTime);

if (_glimmerSystem.Glimmer == 0)
if (_glimmerSystem.GlimmerOutput == 0)
return; // yes, return. Glimmer value is global.

var curTime = _timing.CurTime;
Expand All @@ -37,7 +37,7 @@ public override void Update(float frameTime)
if (!TryComp<IntrinsicRadioTransmitterComponent>(scribe, out var radio))
continue;

var message = Loc.GetString("glimmer-report", ("level", _glimmerSystem.Glimmer));
var message = Loc.GetString("glimmer-report", ("level", (int) Math.Round(_glimmerSystem.GlimmerOutput)));
var channel = _prototypeManager.Index<RadioChannelPrototype>("Science");
_radioSystem.SendRadioMessage(scribe, message, channel, scribe);

Expand All @@ -61,7 +61,7 @@ private void OnInteractHand(EntityUid uid, SophicScribeComponent component, Inte

component.StateTime = _timing.CurTime + component.StateCD;

_chat.TrySendInGameICMessage(uid, Loc.GetString("glimmer-report", ("level", _glimmerSystem.Glimmer)), InGameICChatType.Speak, true);
_chat.TrySendInGameICMessage(uid, Loc.GetString("glimmer-report", ("level", (int) Math.Round(_glimmerSystem.GlimmerOutput))), InGameICChatType.Speak, true);
}

private void OnGlimmerEventEnded(GlimmerEventEndedEvent args)
Expand All @@ -78,7 +78,7 @@ private void OnGlimmerEventEnded(GlimmerEventEndedEvent args)
speaker = swapped.OriginalEntity;
}

var message = Loc.GetString(args.Message, ("decrease", args.GlimmerBurned), ("level", _glimmerSystem.Glimmer));
var message = Loc.GetString(args.Message, ("decrease", args.GlimmerBurned), ("level", (int) Math.Round(_glimmerSystem.GlimmerOutput)));
var channel = _prototypeManager.Index<RadioChannelPrototype>("Common");
_radioSystem.SendRadioMessage(speaker, message, channel, speaker);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected override void Started(EntityUid uid, FreeProberRuleComponent component
}
}

if (PossibleSpawns.Count == 0 || _glimmerSystem.Glimmer >= 500 || _robustRandom.Prob(0.25f))
if (PossibleSpawns.Count == 0 || _glimmerSystem.GlimmerOutput >= 500 || _robustRandom.Prob(0.25f))
{
var queryBattery = EntityQueryEnumerator<PowerNetworkBatteryComponent>();
while (query.MoveNext(out var battery, out var _))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protected override void Ended(EntityUid uid, GlimmerEventComponent component, Ga
base.Ended(uid, component, gameRule, args);

var glimmerBurned = RobustRandom.Next(component.GlimmerBurnLower, component.GlimmerBurnUpper);
_glimmerSystem.Glimmer -= glimmerBurned;
_glimmerSystem.DeltaGlimmerInput(-glimmerBurned);

var reportEv = new GlimmerEventEndedEvent(component.SophicReport, glimmerBurned);
RaiseLocalEvent(reportEv);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ protected override void Started(EntityUid uid, NoosphericFryRuleComponent compon
damage.DamageDict.Add("Heat", 2.5);
damage.DamageDict.Add("Shock", 2.5);

if (_glimmerSystem.Glimmer > 500 && _glimmerSystem.Glimmer < 750)
if (_glimmerSystem.GlimmerOutput > 500 && _glimmerSystem.GlimmerOutput < 750)
{
damage *= 2;
if (TryComp<FlammableComponent>(pair.wearer, out var flammableComponent))
{
flammableComponent.FireStacks += 1;
_flammableSystem.Ignite(pair.wearer, pair.wearer, flammableComponent);
}
} else if (_glimmerSystem.Glimmer > 750)
} else if (_glimmerSystem.GlimmerOutput > 750)
{
damage *= 3;
if (TryComp<FlammableComponent>(pair.wearer, out var flammableComponent))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ protected override void Started(EntityUid uid, NoosphericStormRuleComponent comp
//var glimmerSeverityMod = 1 + (component.GlimmerSeverityCoefficient * (GetSeverityModifier() - 1f));
var glimmerAdded = (int) baseGlimmerAdd; // Math.Round(baseGlimmerAdd * glimmerSeverityMod);

_glimmerSystem.Glimmer += glimmerAdded;
_glimmerSystem.DeltaGlimmerInput(glimmerAdded);
}
}
2 changes: 1 addition & 1 deletion Content.Server/Psionics/Abilities/DispelPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void OnPowerUsed(DispelPowerActionEvent args)
{
args.Handled = true;
_psionics.LogPowerUsed(args.Performer, "dispel", psionic, 1, 1, true);
_glimmerSystem.Glimmer -= _random.Next((int) Math.Round(2 * psionic.Dampening), (int) Math.Round(4 - psionic.Amplification));
_glimmerSystem.DeltaGlimmerInput(-_random.NextFloat(2 * psionic.Dampening - psionic.Amplification, 4 * psionic.Dampening - psionic.Amplification));
}
}

Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Psionics/Abilities/PsionicAbilitiesSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void AddRandomPsionicPower(EntityUid uid)

EntityManager.AddComponent(uid, newComponent);

_glimmerSystem.Glimmer += _random.Next((int) MathF.Round(psionic.Amplification * psionic.Dampening * 1), (int) MathF.Round(psionic.Amplification * psionic.Dampening * 5));
_glimmerSystem.DeltaGlimmerInput(_random.NextFloat(psionic.Amplification * psionic.Dampening, psionic.Amplification * psionic.Dampening * 5));
}

public void RemovePsionics(EntityUid uid)
Expand Down Expand Up @@ -96,7 +96,7 @@ public void RemovePsionics(EntityUid uid)

_statusEffectsSystem.TryAddStatusEffect(uid, "Stutter", TimeSpan.FromMinutes(5), false, "StutteringAccent");

_glimmerSystem.Glimmer += _random.Next((int) MathF.Round(psionic.Amplification * psionic.Dampening * -10), (int) MathF.Round(psionic.Amplification * psionic.Dampening * -5));
_glimmerSystem.DeltaGlimmerOutput(-_random.NextFloat((int) MathF.Round(psionic.Amplification * psionic.Dampening * 5), (int) MathF.Round(psionic.Amplification * psionic.Dampening * 10)));
RemComp<PsionicComponent>(uid);
RemComp<PotentialPsionicComponent>(uid);
}
Expand Down
87 changes: 78 additions & 9 deletions Content.Server/Psionics/Abilities/PyrokinesisPowerSystem.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
using Content.Shared.Actions;
using Content.Shared.DoAfter;
using Content.Shared.Psionics.Abilities;
using Content.Shared.Psionics.Glimmer;
using Content.Server.Atmos.Components;
using Content.Server.Weapons.Ranged.Systems;
using Robust.Server.GameObjects;
using Content.Shared.Actions.Events;
using Content.Server.Explosion.Components;
using Robust.Server.Audio;
using Robust.Shared.Map;
using Robust.Shared.Timing;
using Content.Shared.Popups;
using Content.Shared.Mobs;
using Linguini.Syntax.Ast;
using Content.Shared.Psionics.Events;

namespace Content.Server.Psionics.Abilities
{
Expand All @@ -17,20 +24,26 @@ public sealed class PyrokinesisPowerSystem : EntitySystem
[Dependency] private readonly SharedPsionicAbilitiesSystem _psionics = default!;
[Dependency] private readonly GunSystem _gunSystem = default!;
[Dependency] private readonly GlimmerSystem _glimmerSystem = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly AudioSystem _audioSystem = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PyrokinesisPowerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<PyrokinesisPowerComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<PyrokinesisPowerActionEvent>(OnPowerUsed);
SubscribeLocalEvent<PyrokinesisPrechargeActionEvent>(OnPrecharge);
SubscribeLocalEvent<PyrokinesisPowerComponent, PyrokinesisPrechargeDoAfterEvent>(OnDoAfter);
}

private void OnInit(EntityUid uid, PyrokinesisPowerComponent component, ComponentInit args)
{
_actions.AddAction(uid, ref component.PyrokinesisActionEntity, component.PyrokinesisActionId);
_actions.TryGetActionData( component.PyrokinesisActionEntity, out var actionData);
_actions.AddAction(uid, ref component.PyrokinesisPrechargeActionEntity, component.PyrokinesisPrechargeActionId);
_actions.TryGetActionData( component.PyrokinesisPrechargeActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.StartUseDelay(component.PyrokinesisActionEntity);
_actions.StartUseDelay(component.PyrokinesisPrechargeActionEntity);
if (TryComp<PsionicComponent>(uid, out var psionic))
{
psionic.ActivePowers.Add(component);
Expand All @@ -39,9 +52,46 @@ private void OnInit(EntityUid uid, PyrokinesisPowerComponent component, Componen
}
}

private void OnPrecharge(PyrokinesisPrechargeActionEvent args)
{
if (!HasComp<PsionicInsulationComponent>(args.Performer)
&& TryComp<PsionicComponent>(args.Performer, out var psionic)
&& TryComp<PyrokinesisPowerComponent>(args.Performer, out var pyroComp))
{
_actions.AddAction(args.Performer, ref pyroComp.PyrokinesisActionEntity, pyroComp.PyrokinesisActionId);
_actions.TryGetActionData(pyroComp.PyrokinesisActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.StartUseDelay(pyroComp.PyrokinesisActionEntity);
_actions.TryGetActionData(pyroComp.PyrokinesisPrechargeActionEntity, out var prechargeData);
if (prechargeData is { UseDelay: not null })
_actions.StartUseDelay(pyroComp.PyrokinesisPrechargeActionEntity);

if (_glimmerSystem.GlimmerOutput >= 100 * psionic.Dampening)
{
_popup.PopupEntity(Loc.GetString(pyroComp.PyrokinesisObviousPopup, ("entity", args.Performer)), args.Performer, PopupType.Medium);
_audioSystem.PlayPvs(pyroComp.SoundUse, args.Performer);
}
else
_popup.PopupEntity(Loc.GetString(pyroComp.PyrokinesisSubtlePopup), args.Performer, args.Performer, PopupType.Medium);

pyroComp.FireballThrown = false;

var ev = new PyrokinesisPrechargeDoAfterEvent(_gameTiming.CurTime);
var duration = TimeSpan.FromSeconds(pyroComp.ResetDuration.Seconds + psionic.Dampening);

_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.Performer, duration, ev, args.Performer, args.Performer, args.Performer)
{
BlockDuplicate = true,
Hidden = true,
}, out var doAfterId);

pyroComp.ResetDoAfter = doAfterId;
}
}

private void OnShutdown(EntityUid uid, PyrokinesisPowerComponent component, ComponentShutdown args)
{
_actions.RemoveAction(uid, component.PyrokinesisActionEntity);
_actions.RemoveAction(uid, component.PyrokinesisPrechargeActionEntity);
if (TryComp<PsionicComponent>(uid, out var psionic))
{
psionic.ActivePowers.Remove(component);
Expand All @@ -53,19 +103,20 @@ private void OnShutdown(EntityUid uid, PyrokinesisPowerComponent component, Comp
private void OnPowerUsed(PyrokinesisPowerActionEvent args)
{
if (!HasComp<PsionicInsulationComponent>(args.Performer)
&& TryComp<PsionicComponent>(args.Performer, out var psionic))
&& TryComp<PsionicComponent>(args.Performer, out var psionic)
&& TryComp<PyrokinesisPowerComponent>(args.Performer, out var pyroComp))
{
var spawnCoords = Transform(args.Performer).Coordinates;

var ent = Spawn("ProjectileAnomalyFireball", spawnCoords);

if (TryComp<ExplosiveComponent>(ent, out var fireball))
{
fireball.MaxIntensity = (int) MathF.Round(5 * psionic.Amplification);
fireball.MaxIntensity = (int) MathF.Round(2 * psionic.Amplification);
fireball.IntensitySlope = (int) MathF.Round(1 * psionic.Amplification);
fireball.TotalIntensity = (int) MathF.Round(10 * psionic.Amplification);
fireball.TotalIntensity = (int) MathF.Round(25 * psionic.Amplification);

if (_glimmerSystem.Glimmer >= 500)
if (_glimmerSystem.GlimmerOutput >= 500)
fireball.CanCreateVacuum = true;
else fireball.CanCreateVacuum = false;

Expand All @@ -77,10 +128,28 @@ private void OnPowerUsed(PyrokinesisPowerActionEvent args)
var direction = args.Target.ToMapPos(EntityManager, _xform) - spawnCoords.ToMapPos(EntityManager, _xform);

_gunSystem.ShootProjectile(ent, direction, new System.Numerics.Vector2(0, 0), args.Performer, args.Performer, 20f);

_actions.RemoveAction(args.Performer, pyroComp.PyrokinesisActionEntity);
_doAfterSystem.Cancel(pyroComp.ResetDoAfter);
_psionics.LogPowerUsed(args.Performer, "pyrokinesis", psionic, 6, 8);
pyroComp.FireballThrown = true;
args.Handled = true;
}
}

private void OnDoAfter(EntityUid uid, PyrokinesisPowerComponent component, PyrokinesisPrechargeDoAfterEvent args)
{
if (!args.Cancelled && TryComp<PsionicComponent>(uid, out var psionic))
{
if (!component.FireballThrown)
{
_actions.TryGetActionData(component.PyrokinesisPrechargeActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.SetCooldown(component.PyrokinesisPrechargeActionEntity, TimeSpan.FromSeconds(15 - psionic.Dampening));

_popup.PopupEntity(Loc.GetString(component.PyrokinesisRefundCooldown), uid, uid, PopupType.Medium);
}
_actions.RemoveAction(uid, component.PyrokinesisActionEntity);
}
}
}
}
4 changes: 2 additions & 2 deletions Content.Server/Psionics/Glimmer/GlimmerCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class GlimmerShowCommand : IConsoleCommand
public async void Execute(IConsoleShell shell, string argStr, string[] args)
{
var entMan = IoCManager.Resolve<IEntityManager>();
shell.WriteLine(entMan.EntitySysManager.GetEntitySystem<GlimmerSystem>().Glimmer.ToString());
shell.WriteLine(entMan.EntitySysManager.GetEntitySystem<GlimmerSystem>().GlimmerOutput.ToString());
}
}

Expand All @@ -34,6 +34,6 @@ public async void Execute(IConsoleShell shell, string argStr, string[] args)
return;

var entMan = IoCManager.Resolve<IEntityManager>();
entMan.EntitySysManager.GetEntitySystem<GlimmerSystem>().Glimmer = glimmerValue;
entMan.EntitySysManager.GetEntitySystem<GlimmerSystem>().SetGlimmerOutput(glimmerValue);
}
}
18 changes: 9 additions & 9 deletions Content.Server/Psionics/Glimmer/GlimmerReactiveSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private void AddShockVerb(EntityUid uid, SharedGlimmerReactiveComponent componen
Act = () =>
{
_sharedAudioSystem.PlayPvs(component.ShockNoises, args.User);
_electrocutionSystem.TryDoElectrocution(args.User, null, _glimmerSystem.Glimmer / 200, TimeSpan.FromSeconds((float) _glimmerSystem.Glimmer / 100), false);
_electrocutionSystem.TryDoElectrocution(args.User, null, (int) Math.Round(_glimmerSystem.GlimmerOutput / 200), TimeSpan.FromSeconds((float) _glimmerSystem.GlimmerOutput / 100), false);
},
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/Spare/poweronoff.svg.192dpi.png")),
Text = Loc.GetString("power-switch-component-toggle-verb"),
Expand All @@ -190,7 +190,7 @@ private void OnDamageChanged(EntityUid uid, SharedGlimmerReactiveComponent compo
if (args.Origin == null)
return;

if (!_random.Prob((float) _glimmerSystem.Glimmer / 1000))
if (!_random.Prob(_glimmerSystem.GlimmerOutput / 1000))
return;

var tier = _glimmerSystem.GetGlimmerTier();
Expand All @@ -207,13 +207,13 @@ private void OnDestroyed(EntityUid uid, SharedGlimmerReactiveComponent component
if (tier < GlimmerTier.High)
return;

var totalIntensity = (float) (_glimmerSystem.Glimmer * 2);
var slope = (float) (11 - _glimmerSystem.Glimmer / 100);
var totalIntensity = (float) (_glimmerSystem.GlimmerOutput * 2);
var slope = (float) (11 - _glimmerSystem.GlimmerOutput / 100);
var maxIntensity = 20;

var removed = (float) _glimmerSystem.Glimmer * _random.NextFloat(0.1f, 0.15f);
_glimmerSystem.Glimmer -= (int) removed;
BeamRandomNearProber(uid, _glimmerSystem.Glimmer / 350, _glimmerSystem.Glimmer / 50);
var removed = (float) _glimmerSystem.GlimmerOutput * _random.NextFloat(0.1f, 0.15f);
_glimmerSystem.DeltaGlimmerOutput(-removed);
BeamRandomNearProber(uid, (int) Math.Round(_glimmerSystem.GlimmerOutput / 350), _glimmerSystem.GlimmerOutput / 50);
_explosionSystem.QueueExplosion(uid, "Default", totalIntensity, slope, maxIntensity);
}

Expand All @@ -222,7 +222,7 @@ private void OnUnanchorAttempt(EntityUid uid, SharedGlimmerReactiveComponent com
if (_glimmerSystem.GetGlimmerTier() >= GlimmerTier.Dangerous)
{
_sharedAudioSystem.PlayPvs(component.ShockNoises, args.User);
_electrocutionSystem.TryDoElectrocution(args.User, null, _glimmerSystem.Glimmer / 200, TimeSpan.FromSeconds((float) _glimmerSystem.Glimmer / 100), false);
_electrocutionSystem.TryDoElectrocution(args.User, null, (int) Math.Round(_glimmerSystem.GlimmerOutput / 200), TimeSpan.FromSeconds((float) _glimmerSystem.GlimmerOutput / 100), false);
args.Cancel();
}
}
Expand Down Expand Up @@ -265,7 +265,7 @@ private void Beam(EntityUid prober, EntityUid target, GlimmerTier tier, bool obe

if (!lxform.Coordinates.TryDistance(EntityManager, txform.Coordinates, out var distance))
return;
if (distance > (float) (_glimmerSystem.Glimmer / 100))
if (distance > (float) (_glimmerSystem.GlimmerOutput / 100))
return;

string beamproto;
Expand Down
Loading

0 comments on commit d0cb65a

Please sign in to comment.