Skip to content

Commit

Permalink
Merge pull request #66 from Mnemotechnician/misc/floof-psykers-em-0727
Browse files Browse the repository at this point in the history
Early-Merge Psionic Refactor Changes
  • Loading branch information
FoxxoTrystan authored Jul 29, 2024
2 parents 158d782 + ce39480 commit 1e8d953
Show file tree
Hide file tree
Showing 28 changed files with 264 additions and 152 deletions.
13 changes: 13 additions & 0 deletions Content.Server/Cloning/CloningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Content.Shared.Mind.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Roles.Jobs;
using Content.Shared.Psionics.Abilities;
using Robust.Server.Containers;
using Robust.Server.GameObjects;
using Robust.Server.Player;
Expand Down Expand Up @@ -201,6 +202,18 @@ public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity<MindComponen
if (_configManager.GetCVar(CCVars.BiomassEasyMode))
cloningCost = (int) Math.Round(cloningCost * EasyModeCloningCost);

if (TryComp<PsionicInsulationComponent>(bodyToClone, out var insul))
{
if (clonePod.ConnectedConsole != null)
{
_chatSystem.TrySendInGameICMessage(clonePod.ConnectedConsole.Value,
Loc.GetString("cloning-console-insulation-error"),
InGameICChatType.Speak, false);
}

return false;
}

// Check if they have the uncloneable trait
if (TryComp<UncloneableComponent>(bodyToClone, out _))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ protected override void Started(EntityUid uid, MassMindSwapRuleComponent compone

// Do the swap.
_mindSwap.Swap(actor, other);
if (!component.IsTemporary)
{
_mindSwap.GetTrapped(actor);
_mindSwap.GetTrapped(other);
}
//if (!component.IsTemporary)
//{
// _mindSwap.GetTrapped(actor);
// _mindSwap.GetTrapped(other);
//}
} while (true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected override void Started(EntityUid uid, NoosphericFryRuleComponent compon
while (queryReactive.MoveNext(out var reactive, out _, out var xform, out var physics))
{
// shoot out three bolts of lighting...
_glimmerReactiveSystem.BeamRandomNearProber(reactive, 3, 12);
//_glimmerReactiveSystem.BeamRandomNearProber(reactive, 3, 12);

// try to anchor if we can
if (!xform.Anchored)
Expand Down
32 changes: 16 additions & 16 deletions Content.Server/Psionics/Abilities/DispelPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<DispelPowerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<DispelPowerComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<DispelPowerActionEvent>(OnPowerUsed);
SubscribeLocalEvent<DispelPowerComponent, DispelPowerActionEvent>(OnPowerUsed);

SubscribeLocalEvent<DispellableComponent, DispelledEvent>(OnDispelled);
SubscribeLocalEvent<DamageOnDispelComponent, DispelledEvent>(OnDmgDispelled);
Expand All @@ -44,18 +44,17 @@ public override void Initialize()

private void OnInit(EntityUid uid, DispelPowerComponent component, ComponentInit args)
{
_actions.AddAction(uid, ref component.DispelActionEntity, component.DispelActionId );
_actions.TryGetActionData( component.DispelActionEntity, out var actionData );
EnsureComp<PsionicComponent>(uid, out var psionic);
_actions.AddAction(uid, ref component.DispelActionEntity, component.DispelActionId);
_actions.TryGetActionData(component.DispelActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.StartUseDelay(component.DispelActionEntity);
if (TryComp<PsionicComponent>(uid, out var psionic))
{
psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.DispelFeedback);
//It's fully intended that Dispel doesn't increase Amplification, and instead heavily spikes Dampening
//Antimage archetype.
psionic.Dampening += 1f;
}
_actions.SetCooldown(component.DispelActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));

psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.DispelFeedback);
//It's fully intended that Dispel doesn't increase Amplification, and instead heavily spikes Dampening
//Antimage archetype.
psionic.Dampening += 1f;
}

private void OnShutdown(EntityUid uid, DispelPowerComponent component, ComponentShutdown args)
Expand All @@ -70,18 +69,19 @@ private void OnShutdown(EntityUid uid, DispelPowerComponent component, Component
}
}

private void OnPowerUsed(DispelPowerActionEvent args)
private void OnPowerUsed(EntityUid uid, DispelPowerComponent component, DispelPowerActionEvent args)
{
if (HasComp<PsionicInsulationComponent>(args.Target) || HasComp<PsionicInsulationComponent>(args.Performer))
return;
if (!TryComp<PsionicComponent>(args.Performer, out var psionic) || !HasComp<PsionicComponent>(args.Target))
if (!_psionics.CheckCanTargetCast(uid, args.Target, out var psionic))
return;

var ev = new DispelledEvent();
RaiseLocalEvent(args.Target, ev, false);

if (ev.Handled)
{
_actions.TryGetActionData(component.DispelActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.SetCooldown(component.DispelActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));
args.Handled = true;
_psionics.LogPowerUsed(args.Performer, "dispel", psionic, 1, 1, true);

Expand Down
36 changes: 17 additions & 19 deletions Content.Server/Psionics/Abilities/MetapsionicPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,30 @@ public override void Initialize()

private void OnInit(EntityUid uid, MetapsionicPowerComponent component, ComponentInit args)
{
EnsureComp<PsionicComponent>(uid, out var psionic);
if (!TryComp(uid, out ActionsComponent? comp))
return;
_actions.AddAction(uid, ref component.ActionWideMetapsionicEntity, component.ActionWideMetapsionic, component: comp);
_actions.AddAction(uid, ref component.ActionFocusedMetapsionicEntity, component.ActionFocusedMetapsionic, component: comp);
_actions.TryGetActionData(component.ActionWideMetapsionicEntity, out var actionData);
if (actionData is { UseDelay: not null })
{
_actions.StartUseDelay(component.ActionWideMetapsionicEntity);
_actions.StartUseDelay(component.ActionFocusedMetapsionicEntity);
}
if (TryComp<PsionicComponent>(uid, out var psionic))
{
psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.MetapsionicFeedback);
psionic.Amplification += 0.1f;
psionic.Dampening += 0.5f;
}
UpdateActions(uid, component, psionic);

psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.MetapsionicFeedback);
psionic.Amplification += 0.1f;
psionic.Dampening += 0.5f;
}

private void UpdateActions(EntityUid uid, MetapsionicPowerComponent? component = null)
private void UpdateActions(EntityUid uid, MetapsionicPowerComponent? component = null, PsionicComponent? psionic = null)
{
if (!Resolve(uid, ref component))
if (!Resolve(uid, ref component) || !Resolve(uid, ref psionic)
|| !_actions.TryGetActionData(component.ActionWideMetapsionicEntity, out var actionData))
return;
_actions.StartUseDelay(component.ActionWideMetapsionicEntity);
_actions.StartUseDelay(component.ActionFocusedMetapsionicEntity);

if (actionData is { UseDelay: not null })
{
_actions.SetCooldown(component.ActionWideMetapsionicEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));
_actions.SetCooldown(component.ActionFocusedMetapsionicEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));
}
}

private void OnShutdown(EntityUid uid, MetapsionicPowerComponent component, ComponentShutdown args)
Expand Down Expand Up @@ -95,7 +93,7 @@ private void OnWidePowerUsed(EntityUid uid, MetapsionicPowerComponent component,
}
_popups.PopupEntity(Loc.GetString("metapsionic-pulse-failure"), uid, uid, PopupType.Large);
_psionics.LogPowerUsed(uid, "metapsionic pulse", psionic, 2, 4);
UpdateActions(uid, component);
UpdateActions(uid, component, psionic);
args.Handled = true;
}

Expand Down Expand Up @@ -128,7 +126,7 @@ private void OnFocusedPowerUsed(FocusedMetapsionicPowerActionEvent args)
_psionics.LogPowerUsed(args.Performer, "focused metapsionic pulse", psionic, 3, 6);
args.Handled = true;

UpdateActions(args.Performer, component);
UpdateActions(args.Performer, component, psionic);
}

private void OnDoAfter(EntityUid uid, MetapsionicPowerComponent component, FocusedMetapsionicDoAfterEvent args)
Expand Down
32 changes: 16 additions & 16 deletions Content.Server/Psionics/Abilities/MindSwapPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<MindSwapPowerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<MindSwapPowerComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<MindSwapPowerActionEvent>(OnPowerUsed);
SubscribeLocalEvent<MindSwapPowerComponent, MindSwapPowerActionEvent>(OnPowerUsed);
SubscribeLocalEvent<MindSwappedComponent, MindSwapPowerReturnActionEvent>(OnPowerReturned);
SubscribeLocalEvent<MindSwappedComponent, DispelledEvent>(OnDispelled);
SubscribeLocalEvent<MindSwappedComponent, MobStateChangedEvent>(OnMobStateChanged);
Expand All @@ -41,16 +41,15 @@ public override void Initialize()

private void OnInit(EntityUid uid, MindSwapPowerComponent component, ComponentInit args)
{
EnsureComp<PsionicComponent>(uid, out var psionic);
_actions.AddAction(uid, ref component.MindSwapActionEntity, component.MindSwapActionId);
_actions.TryGetActionData( component.MindSwapActionEntity, out var actionData);
_actions.TryGetActionData(component.MindSwapActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.StartUseDelay(component.MindSwapActionEntity);
if (TryComp<PsionicComponent>(uid, out var psionic))
{
psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.MindSwapFeedback);
psionic.Amplification += 1f;
}
_actions.SetCooldown(component.MindSwapActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));

psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.MindSwapFeedback);
psionic.Amplification += 1f;
}

private void OnShutdown(EntityUid uid, MindSwapPowerComponent component, ComponentShutdown args)
Expand All @@ -64,17 +63,16 @@ private void OnShutdown(EntityUid uid, MindSwapPowerComponent component, Compone
}
}

private void OnPowerUsed(MindSwapPowerActionEvent args)
private void OnPowerUsed(EntityUid uid, MindSwapPowerComponent component, MindSwapPowerActionEvent args)
{

if (!(TryComp<DamageableComponent>(args.Target, out var damageable) && damageable.DamageContainerID == "Biological"))
if (!(TryComp<DamageableComponent>(args.Target, out var damageable) && damageable.DamageContainerID == "Biological")
|| !_psionics.CheckCanTargetCast(uid, args.Target, out var psionic))
return;

if (HasComp<PsionicInsulationComponent>(args.Target))
return;

if (!TryComp<PsionicComponent>(args.Performer, out var psionic))
return;
_actions.TryGetActionData(component.MindSwapActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.SetCooldown(component.MindSwapActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));

Swap(args.Performer, args.Target);

Expand Down Expand Up @@ -159,6 +157,8 @@ private void OnSwapInit(EntityUid uid, MindSwappedComponent component, Component
{
psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.MindSwappedFeedback);
if (actionData is { UseDelay: not null })
_actions.SetCooldown(component.MindSwapReturnActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));
}
}

Expand Down
28 changes: 14 additions & 14 deletions Content.Server/Psionics/Abilities/NoosphericZapPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,20 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<NoosphericZapPowerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<NoosphericZapPowerComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<NoosphericZapPowerActionEvent>(OnPowerUsed);
SubscribeLocalEvent<NoosphericZapPowerComponent, NoosphericZapPowerActionEvent>(OnPowerUsed);
}

private void OnInit(EntityUid uid, NoosphericZapPowerComponent component, ComponentInit args)
{
EnsureComp<PsionicComponent>(uid, out var psionic);
_actions.AddAction(uid, ref component.NoosphericZapActionEntity, component.NoosphericZapActionId );
_actions.TryGetActionData( component.NoosphericZapActionEntity, out var actionData );
_actions.TryGetActionData(component.NoosphericZapActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.StartUseDelay(component.NoosphericZapActionEntity);
if (TryComp<PsionicComponent>(uid, out var psionic))
{
psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.NoosphericZapFeedback);
psionic.Amplification += 1f;
}
_actions.SetCooldown(component.NoosphericZapActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));

psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.NoosphericZapFeedback);
psionic.Amplification += 1f;
}

private void OnShutdown(EntityUid uid, NoosphericZapPowerComponent component, ComponentShutdown args)
Expand All @@ -51,13 +50,14 @@ private void OnShutdown(EntityUid uid, NoosphericZapPowerComponent component, Co
}
}

private void OnPowerUsed(NoosphericZapPowerActionEvent args)
private void OnPowerUsed(EntityUid uid, NoosphericZapPowerComponent component, NoosphericZapPowerActionEvent args)
{
if (!TryComp<PsionicComponent>(args.Performer, out var psionic))
return;

if (!HasComp<PsionicInsulationComponent>(args.Performer))
if (_psionics.CheckCanTargetCast(uid, args.Target, out var psionic))
{

_actions.TryGetActionData(component.NoosphericZapActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.SetCooldown(component.NoosphericZapActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));
_beam.TryCreateBeam(args.Performer, args.Target, "LightningNoospheric");
_stunSystem.TryParalyze(args.Target, TimeSpan.FromSeconds(1 * psionic.Amplification), false);

Expand Down
6 changes: 5 additions & 1 deletion Content.Server/Psionics/Abilities/PsionicAbilitiesSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Robust.Shared.Random;
using Robust.Shared.Prototypes;
using Content.Shared.Popups;
using Robust.Shared.Serialization.Manager;

namespace Content.Server.Psionics.Abilities
{
Expand All @@ -19,6 +20,7 @@ public sealed class PsionicAbilitiesSystem : EntitySystem
[Dependency] private readonly GlimmerSystem _glimmerSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedPopupSystem _popups = default!;
[Dependency] private readonly ISerializationManager _serialization = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -50,7 +52,7 @@ public void AddRandomPsionicPower(EntityUid uid)
return;
}

var newPool = pool;
var newPool = _serialization.CreateCopy(pool, null, false, true);
foreach (var component in pool.Weights.Keys)
{
var checkedComponent = _componentFactory.GetComponent(component);
Expand All @@ -73,6 +75,8 @@ public void RemovePsionics(EntityUid uid)
if (RemComp<PotentialPsionicComponent>(uid))
{
_popups.PopupEntity(Loc.GetString("mindbreaking-feedback", ("entity", uid)), uid, PopupType.Medium);
EnsureComp<PsionicInsulationComponent>(uid, out var insul);
insul.MindBroken = true;
}

if (!TryComp<PsionicComponent>(uid, out var psionic))
Expand Down
Loading

0 comments on commit 1e8d953

Please sign in to comment.