This commit is contained in:
Rane
2022-07-27 00:46:24 -04:00
committed by GitHub
parent 963ddd507b
commit 1c8bdaf7c4
53 changed files with 698 additions and 36 deletions

View File

@@ -181,8 +181,10 @@ namespace Content.Shared.ActionBlocker
private void InteractWithItem(EntityUid user, EntityUid item)
{
var itemEvent = new UserInteractedWithItemEvent(user, item);
RaiseLocalEvent(user, itemEvent);
var userEvent = new UserInteractedWithItemEvent(user, item);
RaiseLocalEvent(user, userEvent);
var itemEvent = new ItemInteractedWithEvent(user, item);
RaiseLocalEvent(item, itemEvent);
}
}
}

View File

@@ -168,7 +168,7 @@ namespace Content.Shared.Atmos
/// <summary>
/// Total number of gases. Increase this if you want to add more!
/// </summary>
public const int TotalNumberOfGases = 7;
public const int TotalNumberOfGases = 8;
/// <summary>
/// This is the actual length of the gases arrays in mixtures.
@@ -285,6 +285,7 @@ namespace Content.Shared.Atmos
Plasma = 3,
Tritium = 4,
WaterVapor = 5,
Miasma = 6
Miasma = 6,
NitrousOxide = 7
}
}

View File

@@ -20,7 +20,8 @@ namespace Content.Shared.Atmos.Piping.Unary.Components
Gas.Plasma,
Gas.Tritium,
Gas.WaterVapor,
Gas.Miasma
Gas.Miasma,
Gas.NitrousOxide
};
// Presets for 'dumb' air alarm modes

View File

@@ -0,0 +1,11 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Bed.Sleep
{
[NetworkedComponent, RegisterComponent]
/// <summary>
/// Prevents waking up. Use as a status effect.
/// </summary>
public sealed class ForcedSleepingComponent : Component
{}
}

View File

@@ -0,0 +1,56 @@
using Content.Shared.Eye.Blinding;
using Content.Shared.Speech;
using Content.Shared.Actions;
using Content.Shared.Bed.Sleep;
namespace Content.Server.Bed.Sleep
{
public sealed class SharedSleepingSystem : EntitySystem
{
[Dependency] private readonly SharedBlindingSystem _blindingSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SleepingComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<SleepingComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<SleepingComponent, SpeakAttemptEvent>(OnSpeakAttempt);
}
private void OnInit(EntityUid uid, SleepingComponent component, ComponentInit args)
{
var ev = new SleepStateChangedEvent(true);
RaiseLocalEvent(uid, ev, false);
_blindingSystem.AdjustBlindSources(uid, true);
}
private void OnShutdown(EntityUid uid, SleepingComponent component, ComponentShutdown args)
{
var ev = new SleepStateChangedEvent(false);
RaiseLocalEvent(uid, ev, false);
_blindingSystem.AdjustBlindSources(uid, false);
}
private void OnSpeakAttempt(EntityUid uid, SleepingComponent component, SpeakAttemptEvent args)
{
args.Cancel();
}
}
}
public sealed class SleepActionEvent : InstantActionEvent {}
public sealed class WakeActionEvent : InstantActionEvent {}
/// <summary>
/// Raised on an entity when they fall asleep or wake up.
/// </summary>
public sealed class SleepStateChangedEvent : EntityEventArgs
{
public bool FellAsleep = false;
public SleepStateChangedEvent(bool fellAsleep)
{
FellAsleep = fellAsleep;
}
}

View File

@@ -0,0 +1,14 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Bed.Sleep;
[NetworkedComponent, RegisterComponent]
/// <summary>
/// Added to entities when they go to sleep.
/// </summary>
public sealed class SleepingComponent : Component
{
// How much damage of any type it takes to wake this entity.
[DataField("wakeThreshold")]
public float WakeThreshold = 2;
}

View File

@@ -0,0 +1,17 @@
namespace Content.Shared.Item;
/// <summary>
/// Raised on the item after they do any sort of interaction with an item,
/// useful for when you want a component on the user to do something to the user
/// E.g. forensics, disease, etc.
/// </summary>
public sealed class ItemInteractedWithEvent : EntityEventArgs
{
public EntityUid User;
public EntityUid Item;
public ItemInteractedWithEvent(EntityUid user, EntityUid item)
{
User = user;
Item = item;
}
}

View File

@@ -5,7 +5,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Inventory.Events;
using Content.Shared.Item;
using Content.Shared.Movement;
using Content.Shared.Bed.Sleep;
using Content.Shared.Movement.Events;
using Content.Shared.Movement.Systems;
using Content.Shared.Standing;
@@ -198,6 +198,9 @@ namespace Content.Shared.Stunnable
if (args.Handled || knocked.HelpTimer > 0f)
return;
if (HasComp<SleepingComponent>(uid))
return;
// Set it to half the help interval so helping is actually useful...
knocked.HelpTimer = knocked.HelpInterval/2f;