Fix skeletons spawning in folded body bags (#37151)
* Fix skeleton spawning * Add comments * Fix the comments Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
@@ -30,6 +30,7 @@ public sealed class FoldableSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<FoldableComponent, ComponentInit>(OnFoldableInit);
|
SubscribeLocalEvent<FoldableComponent, ComponentInit>(OnFoldableInit);
|
||||||
SubscribeLocalEvent<FoldableComponent, ContainerGettingInsertedAttemptEvent>(OnInsertEvent);
|
SubscribeLocalEvent<FoldableComponent, ContainerGettingInsertedAttemptEvent>(OnInsertEvent);
|
||||||
SubscribeLocalEvent<FoldableComponent, StorageOpenAttemptEvent>(OnFoldableOpenAttempt);
|
SubscribeLocalEvent<FoldableComponent, StorageOpenAttemptEvent>(OnFoldableOpenAttempt);
|
||||||
|
SubscribeLocalEvent<FoldableComponent, EntityStorageInsertedIntoAttemptEvent>(OnEntityStorageAttemptInsert);
|
||||||
|
|
||||||
SubscribeLocalEvent<FoldableComponent, StrapAttemptEvent>(OnStrapAttempt);
|
SubscribeLocalEvent<FoldableComponent, StrapAttemptEvent>(OnStrapAttempt);
|
||||||
}
|
}
|
||||||
@@ -56,6 +57,13 @@ public sealed class FoldableSystem : EntitySystem
|
|||||||
args.Cancelled = true;
|
args.Cancelled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnEntityStorageAttemptInsert(Entity<FoldableComponent> entity,
|
||||||
|
ref EntityStorageInsertedIntoAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (entity.Comp.IsFolded)
|
||||||
|
args.Cancelled = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns false if the entity isn't foldable.
|
/// Returns false if the entity isn't foldable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -146,9 +146,18 @@ public sealed class EntityStorageComponentState : ComponentState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised on the entity being inserted whenever checking if an entity can be inserted into an entity storage.
|
||||||
|
/// </summary>
|
||||||
[ByRefEvent]
|
[ByRefEvent]
|
||||||
public record struct InsertIntoEntityStorageAttemptEvent(EntityUid ItemToInsert, bool Cancelled = false);
|
public record struct InsertIntoEntityStorageAttemptEvent(EntityUid ItemToInsert, bool Cancelled = false);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised on the entity storage whenever checking if an entity can be inserted into it.
|
||||||
|
/// </summary>
|
||||||
|
[ByRefEvent]
|
||||||
|
public record struct EntityStorageInsertedIntoAttemptEvent(EntityUid ItemToInsert, bool Cancelled = false);
|
||||||
|
|
||||||
[ByRefEvent]
|
[ByRefEvent]
|
||||||
public record struct StorageOpenAttemptEvent(EntityUid User, bool Silent, bool Cancelled = false);
|
public record struct StorageOpenAttemptEvent(EntityUid User, bool Silent, bool Cancelled = false);
|
||||||
|
|
||||||
|
|||||||
@@ -343,6 +343,13 @@ public abstract class SharedEntityStorageSystem : EntitySystem
|
|||||||
if (attemptEvent.Cancelled)
|
if (attemptEvent.Cancelled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Allow other components on the container to prevent inserting the item: e.g. the container is folded
|
||||||
|
var containerAttemptEvent = new EntityStorageInsertedIntoAttemptEvent(toInsert);
|
||||||
|
RaiseLocalEvent(container, ref containerAttemptEvent);
|
||||||
|
|
||||||
|
if (containerAttemptEvent.Cancelled)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Consult the whitelist. The whitelist ignores the default assumption about how entity storage works.
|
// Consult the whitelist. The whitelist ignores the default assumption about how entity storage works.
|
||||||
if (component.Whitelist != null)
|
if (component.Whitelist != null)
|
||||||
return _whitelistSystem.IsValid(component.Whitelist, toInsert);
|
return _whitelistSystem.IsValid(component.Whitelist, toInsert);
|
||||||
|
|||||||
Reference in New Issue
Block a user