Skip to content

Commit

Permalink
Фикс события "Скелет из шкафа" (#277)
Browse files Browse the repository at this point in the history
* delete skeleton event

* fix

* uncommented ClosetSkeleton

* fix 2
  • Loading branch information
bazelik-null authored Oct 19, 2023
1 parent 9b0de95 commit 51e8411
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Content.Server.StationEvents.Events;
public sealed class RandomEntityStorageSpawnRule : StationEventSystem<RandomEntityStorageSpawnRuleComponent>
{
[Dependency] private readonly EntityStorageSystem _entityStorage = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;

protected override void Started(EntityUid uid, RandomEntityStorageSpawnRuleComponent comp, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
Expand All @@ -18,8 +19,8 @@ protected override void Started(EntityUid uid, RandomEntityStorageSpawnRuleCompo
if (!TryGetRandomStation(out var station))
return;

var validLockers = new List<(EntityUid, EntityStorageComponent)>();
var spawn = Spawn(comp.Prototype, MapCoordinates.Nullspace);
var validLockers = new List<(EntityUid, EntityStorageComponent, TransformComponent)>();

var query = EntityQueryEnumerator<EntityStorageComponent, TransformComponent>();
while (query.MoveNext(out var ent, out var storage, out var xform))
Expand All @@ -30,7 +31,7 @@ protected override void Started(EntityUid uid, RandomEntityStorageSpawnRuleCompo
if (!_entityStorage.CanInsert(spawn, ent, storage))
continue;

validLockers.Add((ent, storage));
validLockers.Add((ent, storage, xform));
}

if (validLockers.Count == 0)
Expand All @@ -39,7 +40,8 @@ protected override void Started(EntityUid uid, RandomEntityStorageSpawnRuleCompo
return;
}

var (locker, storageComp) = RobustRandom.Pick(validLockers);
var (locker, storageComp, lockerPos) = RobustRandom.Pick(validLockers);
_transform.SetCoordinates(spawn, lockerPos.Coordinates);
if (!_entityStorage.Insert(spawn, locker, storageComp))
{
Del(spawn);
Expand Down

0 comments on commit 51e8411

Please sign in to comment.