From 495a65bc6d6d9a8f65ffeec0bfa144959a3106ea Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 25 May 2022 17:43:48 +1000 Subject: [PATCH] Mime cleanup (#8433) --- Content.Client/Entry/IgnoredComponents.cs | 1 + .../Abilities/Mime/InvisibleWallComponent.cs | 12 ------- .../Abilities/Mime/MimePowersSystem.cs | 34 ++++++------------- .../Delete/DeleteAfterTimeComponent.cs | 15 ++++++++ .../Delete/DeleteAfterTimeSystem.cs | 18 ++++++++++ .../Entities/Structures/Walls/walls.yml | 10 +++--- 6 files changed, 51 insertions(+), 39 deletions(-) delete mode 100644 Content.Server/Abilities/Mime/InvisibleWallComponent.cs create mode 100644 Content.Server/Delete/DeleteAfterTimeComponent.cs create mode 100644 Content.Server/Delete/DeleteAfterTimeSystem.cs diff --git a/Content.Client/Entry/IgnoredComponents.cs b/Content.Client/Entry/IgnoredComponents.cs index 9278d9f23e..f114e225ec 100644 --- a/Content.Client/Entry/IgnoredComponents.cs +++ b/Content.Client/Entry/IgnoredComponents.cs @@ -349,6 +349,7 @@ namespace Content.Client.Entry "Artifact", "RandomArtifactSprite", "EnergySword", + "DeleteAfterTime", "MeleeSound", "RangedDamageSound", "DoorRemote", diff --git a/Content.Server/Abilities/Mime/InvisibleWallComponent.cs b/Content.Server/Abilities/Mime/InvisibleWallComponent.cs deleted file mode 100644 index fafa2c8e83..0000000000 --- a/Content.Server/Abilities/Mime/InvisibleWallComponent.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Content.Server.Abilities.Mime -{ - // Tracks invisible wall despawning - [RegisterComponent] - public sealed class InvisibleWallComponent : Component - { - [DataField("accumulator")] - public float Accumulator = 0f; - [DataField("despawnTime")] - public TimeSpan DespawnTime = TimeSpan.FromSeconds(30); - } -} diff --git a/Content.Server/Abilities/Mime/MimePowersSystem.cs b/Content.Server/Abilities/Mime/MimePowersSystem.cs index d9bfcc5111..b3601fcdb6 100644 --- a/Content.Server/Abilities/Mime/MimePowersSystem.cs +++ b/Content.Server/Abilities/Mime/MimePowersSystem.cs @@ -28,27 +28,16 @@ namespace Content.Server.Abilities.Mime public override void Update(float frameTime) { base.Update(frameTime); - /// Queue to despawn invis walls - foreach (var invisWall in EntityQuery()) - { - invisWall.Accumulator += frameTime; - if (invisWall.Accumulator < invisWall.DespawnTime.TotalSeconds) - { - continue; - } - EntityManager.QueueDeleteEntity(invisWall.Owner); - } - /// Queue to track whether mimes can retake vows yet + // Queue to track whether mimes can retake vows yet foreach (var mime in EntityQuery()) { if (!mime.VowBroken || mime.ReadyToRepent) - return; + continue; mime.Accumulator += frameTime; if (mime.Accumulator < mime.VowCooldown.TotalSeconds) - { continue; - } + mime.ReadyToRepent = true; _popupSystem.PopupEntity(Loc.GetString("mime-ready-to-repent"), mime.Owner, Filter.Entities(mime.Owner)); } @@ -77,14 +66,14 @@ namespace Content.Server.Abilities.Mime return; var xform = Transform(uid); - /// Get the tile in front of the mime + // Get the tile in front of the mime var offsetValue = xform.LocalRotation.ToWorldVec().Normalized; - var coords = xform.Coordinates.Offset(offsetValue).SnapToGrid(); - /// Check there are no walls or mobs there + var coords = xform.Coordinates.Offset(offsetValue).SnapToGrid(EntityManager); + // Check there are no walls or mobs there foreach (var entity in coords.GetEntitiesInTile()) { - IPhysBody? physics = null; /// We use this to check if it's impassable - if ((HasComp(entity) && entity != uid) || /// Is it a mob? + IPhysBody? physics = null; // We use this to check if it's impassable + if ((HasComp(entity) && entity != uid) || // Is it a mob? ((Resolve(entity, ref physics, false) && (physics.CollisionLayer & (int) CollisionGroup.Impassable) != 0) // Is it impassable? && !(TryComp(entity, out var door) && door.State != DoorState.Closed))) // Is it a door that's open and so not actually impassable? { @@ -93,10 +82,9 @@ namespace Content.Server.Abilities.Mime } } _popupSystem.PopupEntity(Loc.GetString("mime-invisible-wall-popup", ("mime", uid)), uid, Filter.Pvs(uid)); - /// Make sure we set the invisible wall to despawn properly - var wall = EntityManager.SpawnEntity(component.WallPrototype, coords); - EnsureComp(wall); - /// Handle args so cooldown works + // Make sure we set the invisible wall to despawn properly + Spawn(component.WallPrototype, coords); + // Handle args so cooldown works args.Handled = true; } diff --git a/Content.Server/Delete/DeleteAfterTimeComponent.cs b/Content.Server/Delete/DeleteAfterTimeComponent.cs new file mode 100644 index 0000000000..60be4d4cba --- /dev/null +++ b/Content.Server/Delete/DeleteAfterTimeComponent.cs @@ -0,0 +1,15 @@ +namespace Content.Server.Delete +{ + /// + /// Deletes the entity after the specified period of time. + /// + [RegisterComponent] + public sealed class DeleteAfterTimeComponent : Component + { + [ViewVariables(VVAccess.ReadWrite), DataField("accumulator")] + public float Accumulator = 0f; + + [ViewVariables(VVAccess.ReadWrite), DataField("despawnTime")] + public TimeSpan DespawnTime = TimeSpan.FromSeconds(30); + } +} diff --git a/Content.Server/Delete/DeleteAfterTimeSystem.cs b/Content.Server/Delete/DeleteAfterTimeSystem.cs new file mode 100644 index 0000000000..52ff0262d5 --- /dev/null +++ b/Content.Server/Delete/DeleteAfterTimeSystem.cs @@ -0,0 +1,18 @@ +namespace Content.Server.Delete; + +public sealed class DeleteAfterTimeSystem : EntitySystem +{ + public override void Update(float frameTime) + { + base.Update(frameTime); + + foreach (var comp in EntityQuery()) + { + comp.Accumulator += frameTime; + if (comp.Accumulator < comp.DespawnTime.TotalSeconds) + continue; + + QueueDel(comp.Owner); + } + } +} diff --git a/Resources/Prototypes/Entities/Structures/Walls/walls.yml b/Resources/Prototypes/Entities/Structures/Walls/walls.yml index c7ec79d908..5c5fa19a2b 100644 --- a/Resources/Prototypes/Entities/Structures/Walls/walls.yml +++ b/Resources/Prototypes/Entities/Structures/Walls/walls.yml @@ -649,7 +649,7 @@ parent: WallBase id: WallVaultAlien name: alien vault wall - description: A mysterious ornate looking wall. There may be ancient dangers inside. + description: A mysterious ornate looking wall. There may be ancient dangers inside. components: - type: Sprite sprite: Structures/Walls/vault.rsi @@ -665,7 +665,7 @@ behaviors: - !type:DoActsBehavior acts: [ "Destruction" ] - + - type: entity parent: WallVaultAlien id: WallVaultRock @@ -677,7 +677,7 @@ - type: Icon sprite: Structures/Walls/vault.rsi state: rockvault - + - type: entity parent: WallVaultAlien id: WallVaultSandstone @@ -697,6 +697,8 @@ id: WallInvisible name: Invisible Wall components: + - type: DeleteAfterTime + despawnTime: 30 - type: Tag tags: - Wall @@ -711,4 +713,4 @@ - FullTileMask layer: - GlassLayer - - type: Airtight \ No newline at end of file + - type: Airtight