hamster fixes + entitystorage tweaks (#12987)
* hamster fixes + entitystorage tweaks * make this datafield work * make this shit work better
This commit is contained in:
@@ -61,7 +61,7 @@ public sealed class EntityStorageComponent : Component, IGasMixtureHolder
|
|||||||
[DataField("occludesLight")]
|
[DataField("occludesLight")]
|
||||||
public bool OccludesLight = true;
|
public bool OccludesLight = true;
|
||||||
|
|
||||||
[DataField("deleteContentsOnDestruction")]
|
[DataField("deleteContentsOnDestruction"), ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool DeleteContentsOnDestruction = false;
|
public bool DeleteContentsOnDestruction = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -46,8 +46,9 @@ public sealed class EntityStorageSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<EntityStorageComponent, WeldableAttemptEvent>(OnWeldableAttempt);
|
SubscribeLocalEvent<EntityStorageComponent, WeldableAttemptEvent>(OnWeldableAttempt);
|
||||||
SubscribeLocalEvent<EntityStorageComponent, WeldableChangedEvent>(OnWelded);
|
SubscribeLocalEvent<EntityStorageComponent, WeldableChangedEvent>(OnWelded);
|
||||||
SubscribeLocalEvent<EntityStorageComponent, LockToggleAttemptEvent>(OnLockToggleAttempt);
|
SubscribeLocalEvent<EntityStorageComponent, LockToggleAttemptEvent>(OnLockToggleAttempt);
|
||||||
SubscribeLocalEvent<EntityStorageComponent, DestructionEventArgs>(OnDestroy);
|
SubscribeLocalEvent<EntityStorageComponent, DestructionEventArgs>(OnDestruction);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<InsideEntityStorageComponent, EntGotRemovedFromContainerMessage>(OnRemoved);
|
||||||
SubscribeLocalEvent<InsideEntityStorageComponent, InhaleLocationEvent>(OnInsideInhale);
|
SubscribeLocalEvent<InsideEntityStorageComponent, InhaleLocationEvent>(OnInsideInhale);
|
||||||
SubscribeLocalEvent<InsideEntityStorageComponent, ExhaleLocationEvent>(OnInsideExhale);
|
SubscribeLocalEvent<InsideEntityStorageComponent, ExhaleLocationEvent>(OnInsideExhale);
|
||||||
SubscribeLocalEvent<InsideEntityStorageComponent, AtmosExposedGetAirEvent>(OnInsideExposed);
|
SubscribeLocalEvent<InsideEntityStorageComponent, AtmosExposedGetAirEvent>(OnInsideExposed);
|
||||||
@@ -115,11 +116,19 @@ public sealed class EntityStorageSystem : EntitySystem
|
|||||||
args.Cancelled = true;
|
args.Cancelled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestroy(EntityUid uid, EntityStorageComponent component, DestructionEventArgs args)
|
private void OnDestruction(EntityUid uid, EntityStorageComponent component, DestructionEventArgs args)
|
||||||
{
|
{
|
||||||
component.Open = true;
|
component.Open = true;
|
||||||
if (!component.DeleteContentsOnDestruction)
|
if (!component.DeleteContentsOnDestruction)
|
||||||
|
{
|
||||||
EmptyContents(uid, component);
|
EmptyContents(uid, component);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var ent in new List<EntityUid>(component.Contents.ContainedEntities))
|
||||||
|
{
|
||||||
|
EntityManager.DeleteEntity(ent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleOpen(EntityUid user, EntityUid target, EntityStorageComponent? component = null)
|
public void ToggleOpen(EntityUid user, EntityUid target, EntityStorageComponent? component = null)
|
||||||
@@ -146,12 +155,7 @@ public sealed class EntityStorageSystem : EntitySystem
|
|||||||
var containedArr = component.Contents.ContainedEntities.ToArray();
|
var containedArr = component.Contents.ContainedEntities.ToArray();
|
||||||
foreach (var contained in containedArr)
|
foreach (var contained in containedArr)
|
||||||
{
|
{
|
||||||
if (!component.Contents.Remove(contained))
|
Remove(contained, uid, component, uidXform);
|
||||||
continue;
|
|
||||||
|
|
||||||
RemComp<InsideEntityStorageComponent>(contained);
|
|
||||||
Transform(contained).WorldPosition =
|
|
||||||
uidXform.WorldPosition + uidXform.WorldRotation.RotateVec(component.EnteringOffset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,9 +196,6 @@ public sealed class EntityStorageSystem : EntitySystem
|
|||||||
if (!AddToContents(entity, uid, component))
|
if (!AddToContents(entity, uid, component))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var inside = EnsureComp<InsideEntityStorageComponent>(entity);
|
|
||||||
inside.Storage = uid;
|
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
if (count >= component.Capacity)
|
if (count >= component.Capacity)
|
||||||
break;
|
break;
|
||||||
@@ -218,15 +219,20 @@ public sealed class EntityStorageSystem : EntitySystem
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var inside = EnsureComp<InsideEntityStorageComponent>(toInsert);
|
||||||
|
inside.Storage = container;
|
||||||
return component.Contents.Insert(toInsert, EntityManager);
|
return component.Contents.Insert(toInsert, EntityManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(EntityUid toRemove, EntityUid container, EntityStorageComponent? component = null)
|
public bool Remove(EntityUid toRemove, EntityUid container, EntityStorageComponent? component = null, TransformComponent? xform = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(container, ref component))
|
if (!Resolve(container, ref component, ref xform, false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return component.Contents.Remove(toRemove, EntityManager);
|
RemComp<InsideEntityStorageComponent>(toRemove);
|
||||||
|
component.Contents.Remove(toRemove, EntityManager);
|
||||||
|
Transform(toRemove).WorldPosition = xform.WorldPosition + xform.WorldRotation.RotateVec(component.EnteringOffset);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanInsert(EntityUid container, EntityStorageComponent? component = null)
|
public bool CanInsert(EntityUid container, EntityStorageComponent? component = null)
|
||||||
@@ -434,6 +440,13 @@ public sealed class EntityStorageSystem : EntitySystem
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnRemoved(EntityUid uid, InsideEntityStorageComponent component, EntGotRemovedFromContainerMessage args)
|
||||||
|
{
|
||||||
|
if (args.Container.Owner != component.Storage)
|
||||||
|
return;
|
||||||
|
RemComp(uid, component);
|
||||||
|
}
|
||||||
|
|
||||||
#region Gas mix event handlers
|
#region Gas mix event handlers
|
||||||
|
|
||||||
private void OnInsideInhale(EntityUid uid, InsideEntityStorageComponent component, InhaleLocationEvent args)
|
private void OnInsideInhale(EntityUid uid, InsideEntityStorageComponent component, InhaleLocationEvent args)
|
||||||
|
|||||||
@@ -151,6 +151,7 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
id: CrateNPCHamster
|
id: CrateNPCHamster
|
||||||
parent: CrateRodentCage
|
parent: CrateRodentCage
|
||||||
|
suffix: Filled
|
||||||
components:
|
components:
|
||||||
- type: StorageFill
|
- type: StorageFill
|
||||||
contents:
|
contents:
|
||||||
@@ -159,6 +160,7 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
id: CrateNPCHamlet
|
id: CrateNPCHamlet
|
||||||
parent: CrateRodentCage
|
parent: CrateRodentCage
|
||||||
|
suffix: Hamlet
|
||||||
components:
|
components:
|
||||||
- type: StorageFill
|
- type: StorageFill
|
||||||
contents:
|
contents:
|
||||||
|
|||||||
@@ -312,6 +312,9 @@
|
|||||||
acts: [ "Destruction" ]
|
acts: [ "Destruction" ]
|
||||||
- type: Physics
|
- type: Physics
|
||||||
bodyType: Dynamic
|
bodyType: Dynamic
|
||||||
|
- type: EntityStorage
|
||||||
|
capacity: 500
|
||||||
|
airtight: false
|
||||||
- type: Fixtures
|
- type: Fixtures
|
||||||
fixtures:
|
fixtures:
|
||||||
- shape:
|
- shape:
|
||||||
|
|||||||
Reference in New Issue
Block a user