Skip to content

Commit

Permalink
DELETE
Browse files Browse the repository at this point in the history
  • Loading branch information
lzk228 committed Feb 9, 2025
1 parent bf6fd4d commit 5b58a18
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 2 deletions.
23 changes: 23 additions & 0 deletions Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Shared.Damage;
using Content.Shared.Revenant;
using Robust.Shared.Random;
using Content.Server.Chat.Systems;
using Content.Shared.Tag;
using Content.Server.Storage.Components;
using Content.Server.Light.Components;
Expand Down Expand Up @@ -43,6 +44,8 @@ public sealed partial class RevenantSystem
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly ChatSystem _chat = default!;


private void InitializeAbilities()
{
Expand All @@ -52,6 +55,7 @@ private void InitializeAbilities()

SubscribeLocalEvent<RevenantComponent, RevenantDefileActionEvent>(OnDefileAction);
SubscribeLocalEvent<RevenantComponent, RevenantOverloadLightsActionEvent>(OnOverloadLightsAction);
SubscribeLocalEvent<RevenantComponent, RevenantSedateActionEvent>(OnSedateAction);
SubscribeLocalEvent<RevenantComponent, RevenantBlightActionEvent>(OnBlightAction);
SubscribeLocalEvent<RevenantComponent, RevenantMalfunctionActionEvent>(OnMalfunctionAction);
}
Expand Down Expand Up @@ -314,6 +318,25 @@ private void OnOverloadLightsAction(EntityUid uid, RevenantComponent component,
}
}

private void OnSedateAction(EntityUid uid, RevenantComponent component, RevenantSedateActionEvent args)
{
if (args.Handled)
return;

if (!TryUseAbility(uid, component, component.SedateCost, component.SedateDebuffs))
return;

args.Handled = true;

var pendingSleeping = new PendingSleepingComponent
{
PendingTime = component.SedatePendingTime,
};
EntityManager.AddComponent(args.Target, pendingSleeping);

_chat.TryEmoteWithChat(uid, component.SedateYawnEmote);
}

private void OnBlightAction(EntityUid uid, RevenantComponent component, RevenantBlightActionEvent args)
{
if (args.Handled)
Expand Down
24 changes: 24 additions & 0 deletions Content.Shared/Bed/Sleep/PendingSleepingComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Bed.Sleep;

/// <summary>
/// Makes entity wait before sleep
/// </summary>
[NetworkedComponent, RegisterComponent]
[AutoGenerateComponentState, AutoGenerateComponentPause(Dirty = true)]
public sealed partial class PendingSleepingComponent : Component
{
/// <summary>
/// Time in seconds before entity goes to sleep
/// </summary>
[DataField]
public float PendingTime;

/// <summary>
/// Cooldown time between users hand interaction.
/// </summary>
[DataField]
[AutoNetworkedField, AutoPausedField]
public TimeSpan FallAsleepTime;
}
28 changes: 26 additions & 2 deletions Content.Shared/Bed/Sleep/SleepingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,31 @@ public override void Initialize()
SubscribeLocalEvent<SleepingComponent, GetVerbsEvent<AlternativeVerb>>(AddWakeVerb);
SubscribeLocalEvent<SleepingComponent, InteractHandEvent>(OnInteractHand);

SubscribeLocalEvent<ForcedSleepingComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<PendingSleepingComponent, ComponentInit>(OnPendingSleepingInit);
SubscribeLocalEvent<ForcedSleepingComponent, ComponentInit>(OnForcedSleepingInit);
SubscribeLocalEvent<SleepingComponent, UnbuckleAttemptEvent>(OnUnbuckleAttempt);
SubscribeLocalEvent<SleepingComponent, EmoteAttemptEvent>(OnEmoteAttempt);

SubscribeLocalEvent<SleepingComponent, BeforeForceSayEvent>(OnChangeForceSay, after: new []{typeof(PainNumbnessSystem)});
}

public override void Update(float frameTime)
{
base.Update(frameTime);
var query = EntityQueryEnumerator<PendingSleepingComponent>();
while (query.MoveNext(out var uid, out var pendingSleeping))
{
if (pendingSleeping?.FallAsleepTime != null && _gameTiming?.CurTime != null)
{
if (pendingSleeping.FallAsleepTime < _gameTiming.CurTime)
{
TrySleeping(uid);
EntityManager.RemoveComponent<PendingSleepingComponent>(uid);
}
}
}
}

private void OnUnbuckleAttempt(Entity<SleepingComponent> ent, ref UnbuckleAttemptEvent args)
{
// TODO is this necessary?
Expand Down Expand Up @@ -235,7 +253,13 @@ private void OnMobStateChanged(Entity<SleepingComponent> ent, ref MobStateChange
_emitSound.SetEnabled((ent, spam), args.NewMobState == MobState.Alive);
}

private void OnInit(Entity<ForcedSleepingComponent> ent, ref ComponentInit args)
private void OnPendingSleepingInit(Entity<PendingSleepingComponent> ent, ref ComponentInit args)
{
if (ent.Comp.PendingTime != null)
ent.Comp.FallAsleepTime = TimeSpan.FromSeconds(ent.Comp.PendingTime);
}

private void OnForcedSleepingInit(Entity<ForcedSleepingComponent> ent, ref ComponentInit args)
{
TrySleeping(ent.Owner);
}
Expand Down
31 changes: 31 additions & 0 deletions Content.Shared/Revenant/Components/RevenantComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Content.Shared.Chat.Prototypes;

namespace Content.Shared.Revenant.Components;

Expand Down Expand Up @@ -144,6 +145,36 @@ public sealed partial class RevenantComponent : Component
public float OverloadZapRadius = 2f;
#endregion

#region Sedate Ability
/// <summary>
/// The amount of essence that is needed to use the ability.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float SedateCost = 50;

/// <summary>
/// The status effects applied after the ability
/// the first float corresponds to amount of time the entity is stunned.
/// the second corresponds to the amount of time the entity is made solid.
/// </summary>
[DataField]
public Vector2 SedateDebuffs = new(2, 5);

/// <summary>
/// The radius around the user that this ability affects
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float SedatePendingTime = 5f;

/// <summary>
/// The emote when gasps
/// </summary>
[DataField]
public ProtoId<EmotePrototype> SedateYawnEmote = "Yawn";


#endregion

#region Blight Ability
/// <summary>
/// The amount of essence that is needed to use the ability.
Expand Down
4 changes: 4 additions & 0 deletions Content.Shared/Revenant/SharedRevenant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public sealed partial class RevenantOverloadLightsActionEvent : InstantActionEve
{
}

public sealed partial class RevenantSedateActionEvent : EntityTargetActionEvent
{
}

public sealed partial class RevenantBlightActionEvent : InstantActionEvent
{
}
Expand Down
11 changes: 11 additions & 0 deletions Resources/Prototypes/Actions/revenant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
event: !type:RevenantOverloadLightsActionEvent
useDelay: 20

- type: entity
id: ActionRevenantSedate
name: Sedate
description: Costs 50 Essence.
components:
- type: EntityTargetAction
icon: Interface/Actions/blight.png
event: !type:RevenantSedateActionEvent
useDelay: 20
itemIconStyle: BigAction

#- type: entity
# id: ActionRevenantBlight
# name: Blight
Expand Down
13 changes: 13 additions & 0 deletions Resources/Prototypes/Catalog/revenant_catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@
- !type:ListingLimitedStockCondition
stock: 1

- type: listing
id: RevenantSedate
name: Sedate
description: Make your target sleep
productAction: ActionRevenantSedate
cost:
StolenEssence: 1
categories:
- RevenantAbilities
conditions:
- !type:ListingLimitedStockCondition
stock: 1

#- type: listing
# id: RevenantBlight
# name: revenant-blight-name
Expand Down

0 comments on commit 5b58a18

Please sign in to comment.