Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
Rxup committed Sep 29, 2023
1 parent 27416ed commit 17620de
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ private void OnPowerUsed(MindSwapPowerActionEvent args)
if (HasComp<PsionicInsulationComponent>(args.Target))
return;

Swap(args.Performer, args.Target);

_psionics.LogPowerUsed(args.Performer, "mind swap");
if (Swap(args.Performer, args.Target))
{
GetTrapped(args.Performer);
}
args.Handled = true;
}

Expand Down Expand Up @@ -160,11 +162,6 @@ private void OnGhostAttempt(GhostAttemptHandleEvent args)
private void OnSwapInit(EntityUid uid, MindSwappedComponent component, ComponentInit args)
{
_actions.AddAction(uid, ref component.MindSwapReturn, ActionMindSwapReturn);
if (_actions.TryGetActionData(component.MindSwapReturn, out var action))
{
_actions.SetCooldown(component.MindSwapReturn, _gameTiming.CurTime,
_gameTiming.CurTime + (TimeSpan) action?.UseDelay!);
}
}

public bool Swap(EntityUid performer, EntityUid target, bool end = false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,60 @@
using Content.Server.Mind;
using Content.Shared.Actions;
using Content.Shared.Backmen.Abilities.Psionics;
using Content.Shared.Backmen.Psionics.Events;
using Content.Shared.Mind;
using Content.Shared.Mind.Components;
using Content.Shared.Mobs;
using Content.Shared.StatusEffect;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;

namespace Content.Server.Backmen.Abilities.Psionics;

public sealed class TelegnosisPowerSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly MindSwapPowerSystem _mindSwap = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
[Dependency] private readonly SharedPsionicAbilitiesSystem _psionics = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
[Dependency] private readonly MindSwapPowerSystem _mindSwapPowerSystem = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<TelegnosisPowerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<TelegnosisPowerComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<TelegnosisPowerComponent, TelegnosisPowerActionEvent>(OnPowerUsed);
SubscribeLocalEvent<TelegnosisPowerComponent, MobStateChangedEvent>(OnMobStateChanged);


SubscribeLocalEvent<TelegnosticProjectionComponent, ComponentStartup>(OnProjectionInit);
SubscribeLocalEvent<TelegnosticProjectionComponent, ComponentShutdown>(OnProjectionShutdown);
SubscribeLocalEvent<TelegnosticProjectionComponent, TelegnosisPowerReturnActionEvent>(OnPowerReturnUsed);



SubscribeLocalEvent<TelegnosticProjectionComponent, MindRemovedMessage>(OnMindRemoved);
}

private void OnProjectionShutdown(EntityUid uid, TelegnosticProjectionComponent component, ComponentShutdown args)
{
_actions.RemoveAction(uid, component.TelegnosisPowerAction);
}

private void OnProjectionInit(EntityUid uid, TelegnosticProjectionComponent component, ComponentStartup args)
{
_actions.AddAction(uid, ref component.TelegnosisPowerAction, ActionTelegnosisReturn);
}

[ValidatePrototypeId<EntityPrototype>] private const string ActionTelegnosis = "ActionTelegnosis";
[ValidatePrototypeId<EntityPrototype>] private const string ActionTelegnosisReturn = "ActionTelegnosisReturn";

private void OnInit(EntityUid uid, TelegnosisPowerComponent component, ComponentInit args)
{
_actions.AddAction(uid, ref component.TelegnosisPowerAction, ActionTelegnosis);

if (_actions.TryGetActionData(component.TelegnosisPowerAction, out var action) && action?.UseDelay != null)
_actions.SetCooldown(component.TelegnosisPowerAction, _gameTiming.CurTime,
_gameTiming.CurTime + (TimeSpan) action?.UseDelay!);

if (TryComp<PsionicComponent>(uid, out var psionic) && psionic.PsionicAbility == null)
psionic.PsionicAbility = component.TelegnosisPowerAction;
}
Expand All @@ -45,11 +64,47 @@ private void OnShutdown(EntityUid uid, TelegnosisPowerComponent component, Compo
_actions.RemoveAction(uid, component.TelegnosisPowerAction);
}

private void OnMobStateChanged(EntityUid uid, TelegnosisPowerComponent component, MobStateChangedEvent args)
{
if (args.NewMobState != MobState.Dead)
return;
if (component.TelegnosisProjection == null || TerminatingOrDeleted(component.TelegnosisProjection.Value))
return;
if (!_mindSystem.TryGetMind(uid, out var mindId, out var mind))
return;

_mindSwapPowerSystem.GetTrapped(component.TelegnosisProjection.Value);
_mindSystem.UnVisit(mindId, mind);
_mindSystem.TransferTo(mindId, component.TelegnosisProjection, true, false, mind);
}

private void OnPowerReturnUsed(EntityUid uid, TelegnosticProjectionComponent component, TelegnosisPowerReturnActionEvent args)
{
if (
!TryComp<VisitingMindComponent>(args.Performer, out var mindId) ||
mindId!.MindId == null ||
!TryComp<MindComponent>(mindId.MindId.Value, out var mind)
)
return;

_mindSystem.UnVisit(mindId.MindId.Value, mind);
QueueDel(args.Performer);
_psionics.LogPowerUsed(uid, "telegnosis");
args.Handled = true;
}

private void OnPowerUsed(EntityUid uid, TelegnosisPowerComponent component, TelegnosisPowerActionEvent args)
{
var projection = Spawn(component.Prototype, Transform(uid).Coordinates);
Transform(projection).AttachToGridOrMap();
_mindSwap.Swap(uid, projection);
if (!_mindSystem.TryGetMind(args.Performer, out var mindId, out var mind))
return;

var projection = Spawn(component.Prototype, Transform(args.Performer).Coordinates);
_transformSystem.AttachToGridOrMap(projection);

_mindSystem.Visit(mindId, projection, mind);
//_actions.GrantActions(projection, new []{ component.TelegnosisPowerAction!.Value }, uid);

component.TelegnosisProjection = projection;

_psionics.LogPowerUsed(uid, "telegnosis");
args.Handled = true;
Expand Down
6 changes: 1 addition & 5 deletions Content.Shared/Actions/SharedActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public abstract class SharedActionsSystem : EntitySystem
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
[Dependency] private readonly INetManager _netMan = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -212,10 +211,7 @@ private void OnActionRequest(RequestPerformActionEvent ev, EntitySessionEventArg
if (!TryGetActionData(actionEnt, out var action))
return;

if ((_netMan.IsClient && action.AttachedEntity != null) || _netMan.IsServer)
{
DebugTools.Assert(action.AttachedEntity == user);
}
DebugTools.Assert(action.AttachedEntity == user);


if (!action.Enabled)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Shared.Backmen.Abilities.Psionics;

[RegisterComponent]
public sealed partial class TelegnosisPowerComponent : Component
{
[DataField("prototype")]
[DataField("prototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string Prototype = "MobObserverTelegnostic";
public EntityUid? TelegnosisPowerAction = null;
public EntityUid? TelegnosisPowerAction;
public EntityUid? TelegnosisProjection;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ namespace Content.Shared.Backmen.Abilities.Psionics;

[RegisterComponent]
public sealed partial class TelegnosticProjectionComponent : Component
{}
{
public EntityUid? TelegnosisPowerAction;
}
1 change: 1 addition & 0 deletions Content.Shared/Backmen/Psionics/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public sealed partial class PsionicInvisibilityPowerOffActionEvent : InstantActi
public sealed partial class HairballActionEvent : InstantActionEvent {}
public sealed partial class EatMouseActionEvent : InstantActionEvent {}
public sealed partial class MetapsionicPowerActionEvent : InstantActionEvent {}
public sealed partial class TelegnosisPowerReturnActionEvent : InstantActionEvent {}
public sealed partial class TelegnosisPowerActionEvent : InstantActionEvent {}
public sealed partial class PsionicRegenerationPowerActionEvent : InstantActionEvent {}
public sealed partial class NoosphericZapPowerActionEvent : EntityTargetActionEvent {}
Expand Down
12 changes: 12 additions & 0 deletions Resources/Prototypes/Backmen/Actions/types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@
useDelay: 150
event: !type:TelegnosisPowerActionEvent

- type: entity
id: ActionTelegnosisReturn
name: action-name-telegnosis
description: action-description-telegnosis
noSpawn: true
components:
- type: InstantAction
icon: Backmen/Interface/VerbIcons/psionic_invisibility_off.png
event: !type:TelegnosisPowerReturnActionEvent
checkCanInteract: false
useDelay: 20

- type: entity
id: ActionPsionicRegeneration
name: action-name-psionic-regeneration
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/Backmen/Entities/Mobs/NPC/special.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
- type: ShipwreckedNPCHecate
- type: NPCConversation
tree: ShipwreckedPsychopompHecate
- type: TTS
voice: Npc1
# aliases:
# - hekate
# - katey
Expand Down
7 changes: 5 additions & 2 deletions Resources/Prototypes/Backmen/Entities/Mobs/Player/special.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
layers:
- state: eyeball
shader: unshaded
- type: Dispellable
- type: Psionic
- type: MindContainer
- type: Clickable
Expand All @@ -39,13 +40,15 @@
- type: Appearance
- type: Eye
drawFov: false
visMask: PsionicInvisibility
visMask:
- Normal
- PsionicInvisibility
- type: Input
context: "ghost"
- type: Examiner
- type: TelegnosticProjection
- type: Stealth
lastVisibility: 0.66
lastVisibility: 0.33
- type: Visibility
layer: 4
- type: NoNormalInteraction
2 changes: 1 addition & 1 deletion Resources/Prototypes/Backmen/Psionics/psionicsPowers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
weights:
MetapsionicPower: 1
DispelPower: 1
#TelegnosisPower: 1
TelegnosisPower: 1
PsionicRegenerationPower: 1
MassSleepPower: 0.3
PsionicInvisibilityPower: 0.15
Expand Down

0 comments on commit 17620de

Please sign in to comment.