Hotfix for Body Bags (#9155)
* Oops * Requested changes * Renamed * rename Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -19,7 +19,8 @@ namespace Content.Server.Foldable
|
|||||||
|
|
||||||
SubscribeLocalEvent<FoldableComponent, StorageOpenAttemptEvent>(OnFoldableOpenAttempt);
|
SubscribeLocalEvent<FoldableComponent, StorageOpenAttemptEvent>(OnFoldableOpenAttempt);
|
||||||
SubscribeLocalEvent<FoldableComponent, GetVerbsEvent<AlternativeVerb>>(AddFoldVerb);
|
SubscribeLocalEvent<FoldableComponent, GetVerbsEvent<AlternativeVerb>>(AddFoldVerb);
|
||||||
SubscribeLocalEvent<FoldableComponent, InsertIntoEntityStorageAttemptEvent>(OnEntityStorageInsertAttempt);
|
SubscribeLocalEvent<FoldableComponent, StoreThisAttemptEvent>(OnStoreThisAttempt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFoldableOpenAttempt(EntityUid uid, FoldableComponent component, StorageOpenAttemptEvent args)
|
private void OnFoldableOpenAttempt(EntityUid uid, FoldableComponent component, StorageOpenAttemptEvent args)
|
||||||
@@ -87,9 +88,9 @@ namespace Content.Server.Foldable
|
|||||||
strap.Enabled = !component.IsFolded;
|
strap.Enabled = !component.IsFolded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnEntityStorageInsertAttempt(EntityUid uid, FoldableComponent comp, InsertIntoEntityStorageAttemptEvent args)
|
public void OnStoreThisAttempt(EntityUid uid, FoldableComponent comp, StoreThisAttemptEvent args)
|
||||||
{
|
{
|
||||||
if (!comp.IsFolded)
|
if (comp.IsFolded)
|
||||||
args.Cancel();
|
args.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,14 +216,13 @@ namespace Content.Server.Storage.Components
|
|||||||
// 4. items can always be eaten unless a previous law prevents it
|
// 4. items can always be eaten unless a previous law prevents it
|
||||||
// 5. if this is NOT AN ITEM, then mobs can always be eaten unless unless a previous law prevents it
|
// 5. if this is NOT AN ITEM, then mobs can always be eaten unless unless a previous law prevents it
|
||||||
// 6. if this is an item, then mobs must only be eaten if some other component prevents pick-up interactions while a mob is inside (e.g. foldable)
|
// 6. if this is an item, then mobs must only be eaten if some other component prevents pick-up interactions while a mob is inside (e.g. foldable)
|
||||||
|
|
||||||
var attemptEvent = new InsertIntoEntityStorageAttemptEvent();
|
var attemptEvent = new InsertIntoEntityStorageAttemptEvent();
|
||||||
_entMan.EventBus.RaiseLocalEvent(entity, attemptEvent);
|
_entMan.EventBus.RaiseLocalEvent(entity, attemptEvent);
|
||||||
if (attemptEvent.Cancelled)
|
if (attemptEvent.Cancelled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// checks
|
// checks
|
||||||
|
// TODO: Make the others sub to it.
|
||||||
var targetIsItem = _entMan.HasComponent<SharedItemComponent>(entity);
|
var targetIsItem = _entMan.HasComponent<SharedItemComponent>(entity);
|
||||||
var targetIsMob = _entMan.HasComponent<SharedBodyComponent>(entity);
|
var targetIsMob = _entMan.HasComponent<SharedBodyComponent>(entity);
|
||||||
var storageIsItem = _entMan.HasComponent<SharedItemComponent>(Owner);
|
var storageIsItem = _entMan.HasComponent<SharedItemComponent>(Owner);
|
||||||
@@ -239,9 +238,14 @@ namespace Content.Server.Storage.Components
|
|||||||
{
|
{
|
||||||
if (!storageIsItem)
|
if (!storageIsItem)
|
||||||
allowedToEat = true;
|
allowedToEat = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var storeEv = new StoreThisAttemptEvent();
|
||||||
|
_entMan.EventBus.RaiseLocalEvent(Owner, storeEv);
|
||||||
|
allowedToEat = !storeEv.Cancelled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_entMan.EventBus.RaiseLocalEvent(entity, allowedToEat);
|
|
||||||
return allowedToEat;
|
return allowedToEat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,6 +371,11 @@ namespace Content.Server.Storage.Components
|
|||||||
public sealed class InsertIntoEntityStorageAttemptEvent : CancellableEntityEventArgs
|
public sealed class InsertIntoEntityStorageAttemptEvent : CancellableEntityEventArgs
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class StoreThisAttemptEvent : CancellableEntityEventArgs
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public sealed class StorageOpenAttemptEvent : CancellableEntityEventArgs
|
public sealed class StorageOpenAttemptEvent : CancellableEntityEventArgs
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public abstract class SharedFoldableSystem : EntitySystem
|
|||||||
public virtual void SetFolded(FoldableComponent component, bool folded)
|
public virtual void SetFolded(FoldableComponent component, bool folded)
|
||||||
{
|
{
|
||||||
component.IsFolded = folded;
|
component.IsFolded = folded;
|
||||||
component.Dirty();
|
Dirty(component);
|
||||||
|
|
||||||
if (TryComp(component.Owner, out AppearanceComponent? appearance))
|
if (TryComp(component.Owner, out AppearanceComponent? appearance))
|
||||||
appearance.SetData(FoldKey, folded);
|
appearance.SetData(FoldKey, folded);
|
||||||
|
|||||||
Reference in New Issue
Block a user