@@ -17,11 +17,11 @@ using Content.Shared.Mobs.Systems;
|
|||||||
using Content.Shared.Movement.Events;
|
using Content.Shared.Movement.Events;
|
||||||
using Content.Shared.Nutrition.Components;
|
using Content.Shared.Nutrition.Components;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
|
using Content.Shared.Random.Helpers;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.Random;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
@@ -44,7 +44,6 @@ public sealed class SharedKitchenSpikeSystem : EntitySystem
|
|||||||
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
||||||
[Dependency] private readonly SharedBodySystem _bodySystem = default!;
|
[Dependency] private readonly SharedBodySystem _bodySystem = default!;
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -94,15 +93,24 @@ public sealed class SharedKitchenSpikeSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnEntInsertedIntoContainer(Entity<KitchenSpikeComponent> ent, ref EntInsertedIntoContainerMessage args)
|
private void OnEntInsertedIntoContainer(Entity<KitchenSpikeComponent> ent, ref EntInsertedIntoContainerMessage args)
|
||||||
{
|
{
|
||||||
|
if (_gameTiming.ApplyingState)
|
||||||
|
return;
|
||||||
|
|
||||||
EnsureComp<KitchenSpikeHookedComponent>(args.Entity);
|
EnsureComp<KitchenSpikeHookedComponent>(args.Entity);
|
||||||
_damageableSystem.TryChangeDamage(args.Entity, ent.Comp.SpikeDamage, true);
|
_damageableSystem.TryChangeDamage(args.Entity, ent.Comp.SpikeDamage, true);
|
||||||
|
|
||||||
|
ent.Comp.NextDamage = _gameTiming.CurTime + ent.Comp.DamageInterval;
|
||||||
|
Dirty(ent);
|
||||||
|
|
||||||
// TODO: Add sprites for different species.
|
// TODO: Add sprites for different species.
|
||||||
_appearanceSystem.SetData(ent.Owner, KitchenSpikeVisuals.Status, KitchenSpikeStatus.Bloody);
|
_appearanceSystem.SetData(ent.Owner, KitchenSpikeVisuals.Status, KitchenSpikeStatus.Bloody);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEntRemovedFromContainer(Entity<KitchenSpikeComponent> ent, ref EntRemovedFromContainerMessage args)
|
private void OnEntRemovedFromContainer(Entity<KitchenSpikeComponent> ent, ref EntRemovedFromContainerMessage args)
|
||||||
{
|
{
|
||||||
|
if (_gameTiming.ApplyingState)
|
||||||
|
return;
|
||||||
|
|
||||||
RemComp<KitchenSpikeHookedComponent>(args.Entity);
|
RemComp<KitchenSpikeHookedComponent>(args.Entity);
|
||||||
_damageableSystem.TryChangeDamage(args.Entity, ent.Comp.SpikeDamage, true);
|
_damageableSystem.TryChangeDamage(args.Entity, ent.Comp.SpikeDamage, true);
|
||||||
|
|
||||||
@@ -275,7 +283,11 @@ public sealed class SharedKitchenSpikeSystem : EntitySystem
|
|||||||
PopupType.MediumCaution);
|
PopupType.MediumCaution);
|
||||||
|
|
||||||
// Get a random entry to spawn.
|
// Get a random entry to spawn.
|
||||||
var index = _random.Next(butcherable.SpawnedEntities.Count);
|
// TODO: Replace with RandomPredicted once the engine PR is merged
|
||||||
|
var seed = SharedRandomExtensions.HashCodeCombine(new() { (int)_gameTiming.CurTick.Value, GetNetEntity(ent).Id });
|
||||||
|
var rand = new System.Random(seed);
|
||||||
|
|
||||||
|
var index = rand.Next(butcherable.SpawnedEntities.Count);
|
||||||
var entry = butcherable.SpawnedEntities[index];
|
var entry = butcherable.SpawnedEntities[index];
|
||||||
|
|
||||||
var uid = PredictedSpawnNextToOrDrop(entry.PrototypeId, ent);
|
var uid = PredictedSpawnNextToOrDrop(entry.PrototypeId, ent);
|
||||||
@@ -378,13 +390,18 @@ public sealed class SharedKitchenSpikeSystem : EntitySystem
|
|||||||
|
|
||||||
while (query.MoveNext(out var uid, out var kitchenSpike))
|
while (query.MoveNext(out var uid, out var kitchenSpike))
|
||||||
{
|
{
|
||||||
|
var contained = kitchenSpike.BodyContainer.ContainedEntity;
|
||||||
|
|
||||||
|
if (!contained.HasValue)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (kitchenSpike.NextDamage > _gameTiming.CurTime)
|
if (kitchenSpike.NextDamage > _gameTiming.CurTime)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
kitchenSpike.NextDamage += kitchenSpike.DamageInterval;
|
kitchenSpike.NextDamage += kitchenSpike.DamageInterval;
|
||||||
Dirty(uid, kitchenSpike);
|
Dirty(uid, kitchenSpike);
|
||||||
|
|
||||||
_damageableSystem.TryChangeDamage(kitchenSpike.BodyContainer.ContainedEntity, kitchenSpike.TimeDamage, true);
|
_damageableSystem.TryChangeDamage(contained, kitchenSpike.TimeDamage, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user