Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shadowkin fixes (real) #189

Merged
merged 9 commits into from
Jul 29, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.CombatMode.Pacification;
using Content.Shared.Cuffs.Components;
using Content.Shared.Damage.Systems;
using Content.Shared.SimpleStation14.Species.Shadowkin.Components;
using Content.Shared.SimpleStation14.Species.Shadowkin.Events;
Expand All @@ -30,14 +31,10 @@ public sealed class ShadowkinDarkSwapSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly MagicSystem _magic = default!;

private InstantAction _action = default!;

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

_action = new InstantAction(_prototype.Index<InstantActionPrototype>("ShadowkinDarkSwap"));

SubscribeLocalEvent<ShadowkinDarkSwapPowerComponent, ComponentStartup>(Startup);
SubscribeLocalEvent<ShadowkinDarkSwapPowerComponent, ComponentShutdown>(Shutdown);

Expand All @@ -50,17 +47,27 @@ public override void Initialize()

private void Startup(EntityUid uid, ShadowkinDarkSwapPowerComponent component, ComponentStartup args)
{
_actions.AddAction(uid, _action, uid);
_actions.AddAction(uid, new InstantAction(_prototype.Index<InstantActionPrototype>("ShadowkinDarkSwap")), null);
}

private void Shutdown(EntityUid uid, ShadowkinDarkSwapPowerComponent component, ComponentShutdown args)
{
_actions.RemoveAction(uid, _action);
_actions.RemoveAction(uid, new InstantAction(_prototype.Index<InstantActionPrototype>("ShadowkinDarkSwap")));
}


private void DarkSwap(EntityUid uid, ShadowkinDarkSwapPowerComponent component, ShadowkinDarkSwapEvent args)
{
// Need power to drain power
if (!_entity.HasComponent<ShadowkinComponent>(args.Performer))
return;

// Don't activate abilities if handcuffed
// TODO: Something like the Psionic Headcage to disable powers for Shadowkin
if (_entity.HasComponent<HandcuffComponent>(args.Performer))
return;


var hasComp = _entity.HasComponent<ShadowkinDarkSwappedComponent>(args.Performer);

SetDarkened(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public override void Update(float frameTime)
if (!_entity.TryGetComponent(light, out ShadowkinLightComponent? shadowkinLight))
continue;
// Not powered, undo changes
if (!_entity.TryGetComponent(light, out PoweredLightComponent? powered) || !powered.On)
if (_entity.TryGetComponent(light, out PoweredLightComponent? powered) && !powered.On)
{
ResetLight(pointLight, shadowkinLight);
continue;
Expand All @@ -98,10 +98,10 @@ public override void Update(float frameTime)
shadowkin.DarkenedLights.Remove(light);
continue;
}
// 10% chance to remove the attached entity so it can become another Shadowkin's light
// 3% chance to remove the attached entity so it can become another Shadowkin's light
if (shadowkinLight.AttachedEntity == uid)
{
if (_random.Prob(0.1f))
if (_random.Prob(0.03f))
shadowkinLight.AttachedEntity = EntityUid.Invalid;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Bed.Sleep;
using Content.Shared.Cuffs.Components;
using Content.Shared.SimpleStation14.Species.Shadowkin.Components;
using Robust.Shared.Prototypes;

Expand All @@ -15,14 +16,10 @@ public sealed class ShadowkinRestSystem : EntitySystem
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly ShadowkinPowerSystem _power = default!;

private InstantAction _action = default!;

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

_action = new InstantAction(_prototype.Index<InstantActionPrototype>("ShadowkinRest"));

SubscribeLocalEvent<ShadowkinRestPowerComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<ShadowkinRestPowerComponent, ComponentShutdown>(OnShutdown);

Expand All @@ -32,19 +29,26 @@ public override void Initialize()

private void OnStartup(EntityUid uid, ShadowkinRestPowerComponent component, ComponentStartup args)
{
_actions.AddAction(uid, _action, uid);
_actions.AddAction(uid, new InstantAction(_prototype.Index<InstantActionPrototype>("ShadowkinRest")), null);
}

private void OnShutdown(EntityUid uid, ShadowkinRestPowerComponent component, ComponentShutdown args)
{
_actions.RemoveAction(uid, _action);
_actions.RemoveAction(uid, new InstantAction(_prototype.Index<InstantActionPrototype>("ShadowkinRest")));
}

private void Rest(EntityUid uid, ShadowkinRestPowerComponent component, ShadowkinRestEvent args)
{
// Need power to modify power
if (!_entity.HasComponent<ShadowkinComponent>(args.Performer))
return;

// Rest is a funny ability, keep it :)
// // Don't activate abilities if handcuffed
// if (_entity.HasComponent<HandcuffComponent>(args.Performer))
// return;


// Now doing what you weren't before
component.IsResting = !component.IsResting;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Server.SimpleStation14.Species.Shadowkin.Events;
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Cuffs.Components;
using Content.Shared.Damage.Systems;
using Content.Shared.Pulling.Components;
using Content.Shared.SimpleStation14.Species.Shadowkin.Components;
Expand All @@ -24,14 +25,10 @@ public sealed class ShadowkinTeleportSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly MagicSystem _magic = default!;

private WorldTargetAction _action = default!;

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

_action = new WorldTargetAction(_prototype.Index<WorldTargetActionPrototype>("ShadowkinTeleport"));

SubscribeLocalEvent<ShadowkinTeleportPowerComponent, ComponentStartup>(Startup);
SubscribeLocalEvent<ShadowkinTeleportPowerComponent, ComponentShutdown>(Shutdown);

Expand All @@ -41,19 +38,24 @@ public override void Initialize()

private void Startup(EntityUid uid, ShadowkinTeleportPowerComponent component, ComponentStartup args)
{
_actions.AddAction(uid, _action, uid);
_actions.AddAction(uid, new WorldTargetAction(_prototype.Index<WorldTargetActionPrototype>("ShadowkinTeleport")), null);
}

private void Shutdown(EntityUid uid, ShadowkinTeleportPowerComponent component, ComponentShutdown args)
{
_actions.RemoveAction(uid, _action);
_actions.RemoveAction(uid, new WorldTargetAction(_prototype.Index<WorldTargetActionPrototype>("ShadowkinTeleport")));
}


private void Teleport(EntityUid uid, ShadowkinTeleportPowerComponent component, ShadowkinTeleportEvent args)
{
if (args.Handled ||
!_entity.TryGetComponent<ShadowkinComponent>(args.Performer, out var comp))
// Need power to drain power
if (!_entity.TryGetComponent<ShadowkinComponent>(args.Performer, out var comp))
return;

// Don't activate abilities if handcuffed
// TODO: Something like the Psionic Headcage to disable powers for Shadowkin
if (_entity.HasComponent<HandcuffComponent>(args.Performer))
return;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Content.Server.Mind;
using Content.Server.Mind.Components;
using Content.Server.SimpleStation14.Species.Shadowkin.Events;
using Content.Shared.Bed.Sleep;
using Content.Shared.Cuffs.Components;
using Content.Shared.Examine;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
Expand Down Expand Up @@ -89,14 +91,21 @@ public override void Update(float frameTime)
// Update power level for all shadowkin
while (query.MoveNext(out var uid, out var shadowkin))
{
// Skip if the shadowkin is dead or catatonic
// Ensure dead or critical shadowkin aren't swapped, skip them
if (_mobState.IsDead(uid) ||
!_entity.System<MindSystem>().TryGetMind(uid, out var mind) ||
_mobState.IsCritical(uid))
{
_entity.RemoveComponent<ShadowkinDarkSwappedComponent>(uid);
continue;
}

// Don't update things for ssd shadowkin
if (!_entity.System<MindSystem>().TryGetMind(uid, out var mind) ||
mind.Session == null)
continue;

var oldPowerLevel = _power.GetLevelName(shadowkin.PowerLevel);

var oldPowerLevel = _power.GetLevelName(shadowkin.PowerLevel);
_power.TryUpdatePowerLevel(uid, frameTime);

if (oldPowerLevel != _power.GetLevelName(shadowkin.PowerLevel))
Expand All @@ -107,6 +116,12 @@ public override void Update(float frameTime)
// I can't figure out how to get this to go to the 100% filled state in the above if statement 😢
_power.UpdateAlert(uid, true, shadowkin.PowerLevel);


// Don't randomly activate abilities if handcuffed
// TODO: Something like the Psionic Headcage to disable powers for Shadowkin
if (_entity.HasComponent<HandcuffComponent>(uid))
continue;

#region MaxPower
// Check if they're at max power
if (shadowkin.PowerLevel >= ShadowkinComponent.PowerThresholds[ShadowkinPowerThreshold.Max])
Expand Down Expand Up @@ -149,7 +164,9 @@ public override void Update(float frameTime)
(
ShadowkinComponent.PowerThresholds[ShadowkinPowerThreshold.Tired] +
ShadowkinComponent.PowerThresholds[ShadowkinPowerThreshold.Okay]
) / 2f
) / 2f &&
// Don't sleep if asleep
!_entity.HasComponent<SleepingComponent>(uid)
)
{
// If so, start the timer
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Objects/Devices/pda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
icon: { sprite: Objects/Tools/flashlight.rsi, state: flashlight }
iconOn: Objects/Tools/flashlight.rsi/flashlight-on.png
event: !type:ToggleActionEvent
- type: ShadowkinLight
- type: PointLight
enabled: false
radius: 1.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
sprite: Objects/Misc/Lights/lights.rsi
size: 20
heldPrefix: off
- type: ShadowkinLight
- type: PointLight
enabled: false
radius: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
map: [ "light" ]
- type: Item
sprite: Objects/Tools/flashlight.rsi
- type: ShadowkinLight
- type: PointLight
enabled: false
mask: /Textures/Effects/LightMasks/cone.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- state: on
map: ["enum.PoweredLightLayers.Base"]
state: on
- type: ShadowkinLight
- type: PointLight
radius: 10
energy: 0.8
Expand Down Expand Up @@ -107,7 +108,6 @@
components:
- type: Sprite
state: off
- type: ShadowkinLight
- type: PointLight
enabled: true
- type: PoweredLight
Expand Down
Loading