From 73c9f0402430dd6e5394a5f474013b32346fdb79 Mon Sep 17 00:00:00 2001 From: Dvir Date: Sat, 21 Sep 2024 17:13:08 +0300 Subject: [PATCH] Allow some mobs to not despawn with events --- .../Salvage/SalvageSystem.ExpeditionConsole.cs | 2 +- .../StationEvents/Events/BluespaceErrorRule.cs | 12 ++++++++++-- .../Worldgen/Systems/LocalityLoaderSystem.cs | 2 +- ...onent.cs => NFSalvageMobRestrictionsComponent.cs} | 8 +++++--- .../_NF/Salvage/SalvageMobRestrictionsSystem.cs | 8 ++++---- Resources/Prototypes/Entities/Mobs/NPCs/carp.yml | 4 ++-- Resources/Prototypes/Entities/Mobs/NPCs/flesh.yml | 2 +- Resources/Prototypes/Entities/Mobs/NPCs/space.yml | 8 ++++---- .../Prototypes/Entities/Mobs/NPCs/spacetick.yml | 2 +- Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml | 4 ++-- Resources/Prototypes/Entities/Mobs/Player/dragon.yml | 2 +- .../Prototypes/_NF/Entities/Mobs/NPCs/corpses.yml | 2 +- .../Prototypes/_NF/Entities/Mobs/NPCs/elemental.yml | 4 ++-- .../_NF/Entities/Mobs/NPCs/mob_hostile_base.yml | 4 ++-- .../Mobs/NPCs/mob_hostile_expeditions_xeno.yml | 2 +- 15 files changed, 38 insertions(+), 28 deletions(-) rename Content.Server/_NF/Salvage/{SalvageMobRestrictionsNFComponent.cs => NFSalvageMobRestrictionsComponent.cs} (77%) diff --git a/Content.Server/Salvage/SalvageSystem.ExpeditionConsole.cs b/Content.Server/Salvage/SalvageSystem.ExpeditionConsole.cs index bf777208d05..45855dd1afd 100644 --- a/Content.Server/Salvage/SalvageSystem.ExpeditionConsole.cs +++ b/Content.Server/Salvage/SalvageSystem.ExpeditionConsole.cs @@ -139,7 +139,7 @@ private void OnSalvageFinishMessage(EntityUid entity, SalvageExpeditionConsoleCo continue; // NPC, definitely not a person - if (HasComp(uid) || HasComp(uid)) + if (HasComp(uid) || HasComp(uid)) continue; // Hostile ghost role, continue diff --git a/Content.Server/StationEvents/Events/BluespaceErrorRule.cs b/Content.Server/StationEvents/Events/BluespaceErrorRule.cs index e39d09d7d33..4678da4db6f 100644 --- a/Content.Server/StationEvents/Events/BluespaceErrorRule.cs +++ b/Content.Server/StationEvents/Events/BluespaceErrorRule.cs @@ -77,11 +77,19 @@ protected override void Ended(EntityUid uid, BluespaceErrorRuleComponent compone var gridValue = _pricing.AppraiseGrid(gridUid, null); // Handle mobrestrictions getting deleted - var query = AllEntityQuery(); + var query = AllEntityQuery(); while (query.MoveNext(out var salvUid, out var salvMob)) { - if (gridTransform.GridUid == salvMob.LinkedGridEntity) + if (!salvMob.DespawnIfOffEventGrid) + { + var transform = Transform(salvUid); + if (transform.GridUid != salvMob.LinkedGridEntity) + { + RemComp(salvUid); + } + } + else if (gridTransform.GridUid == salvMob.LinkedGridEntity) { QueueDel(salvUid); } diff --git a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs index 56df1fac56a..152a54dac91 100644 --- a/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs +++ b/Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs @@ -81,7 +81,7 @@ private void OnDebrisDespawn(EntityUid entity, SpaceDebrisComponent component, E if (entity != null) { // Handle mobrestrictions getting deleted - var query = AllEntityQuery(); + var query = AllEntityQuery(); while (query.MoveNext(out var salvUid, out var salvMob)) { diff --git a/Content.Server/_NF/Salvage/SalvageMobRestrictionsNFComponent.cs b/Content.Server/_NF/Salvage/NFSalvageMobRestrictionsComponent.cs similarity index 77% rename from Content.Server/_NF/Salvage/SalvageMobRestrictionsNFComponent.cs rename to Content.Server/_NF/Salvage/NFSalvageMobRestrictionsComponent.cs index 340257e6d9a..22e57ef2dd5 100644 --- a/Content.Server/_NF/Salvage/SalvageMobRestrictionsNFComponent.cs +++ b/Content.Server/_NF/Salvage/NFSalvageMobRestrictionsComponent.cs @@ -14,9 +14,11 @@ namespace Content.Server._NF.Salvage; /// whatever it's currently parented to. /// [RegisterComponent] -public sealed partial class SalvageMobRestrictionsNFComponent : Component +public sealed partial class NFSalvageMobRestrictionsComponent : Component { - [ViewVariables(VVAccess.ReadOnly)] - [DataField("linkedGridEntity")] + [DataField, ViewVariables(VVAccess.ReadOnly)] public EntityUid LinkedGridEntity = EntityUid.Invalid; + + [DataField] + public bool DespawnIfOffEventGrid = true; } diff --git a/Content.Server/_NF/Salvage/SalvageMobRestrictionsSystem.cs b/Content.Server/_NF/Salvage/SalvageMobRestrictionsSystem.cs index f6a50e762b5..c4b3e5c7c71 100644 --- a/Content.Server/_NF/Salvage/SalvageMobRestrictionsSystem.cs +++ b/Content.Server/_NF/Salvage/SalvageMobRestrictionsSystem.cs @@ -15,12 +15,12 @@ public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnInit); - SubscribeLocalEvent(OnRemove); + SubscribeLocalEvent(OnInit); + SubscribeLocalEvent(OnRemove); SubscribeLocalEvent(OnRemoveGrid); } - private void OnInit(EntityUid uid, SalvageMobRestrictionsNFComponent component, ComponentInit args) + private void OnInit(EntityUid uid, NFSalvageMobRestrictionsComponent component, ComponentInit args) { var gridUid = Transform(uid).ParentUid; if (!EntityManager.EntityExists(gridUid)) @@ -38,7 +38,7 @@ private void OnInit(EntityUid uid, SalvageMobRestrictionsNFComponent component, component.LinkedGridEntity = gridUid; } - private void OnRemove(EntityUid uid, SalvageMobRestrictionsNFComponent component, ComponentRemove args) + private void OnRemove(EntityUid uid, NFSalvageMobRestrictionsComponent component, ComponentRemove args) { if (TryComp(component.LinkedGridEntity, out SalvageMobRestrictionsGridComponent? rg)) { diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml b/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml index 82d4b76eb54..fcddfecde8c 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml @@ -149,7 +149,7 @@ parent: MobCarp suffix: "Salvage Ruleset" components: - - type: SalvageMobRestrictionsNF + - type: NFSalvageMobRestrictions # Frontier - type: entity name: space carp @@ -238,4 +238,4 @@ parent: MobShark suffix: "Salvage Ruleset" components: - - type: SalvageMobRestrictionsNF + - type: NFSalvageMobRestrictions diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/flesh.yml b/Resources/Prototypes/Entities/Mobs/NPCs/flesh.yml index 89ab08a5c9b..8f909f6e9fb 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/flesh.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/flesh.yml @@ -252,7 +252,7 @@ Slash: 6 - type: ReplacementAccent accent: genericAggressive - - type: SalvageMobRestrictionsNF + - type: NFSalvageMobRestrictions # Frontier - type: entity parent: BaseMobFleshSalvage diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/space.yml b/Resources/Prototypes/Entities/Mobs/NPCs/space.yml index 1fd12111f00..038f3ebd04e 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/space.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/space.yml @@ -116,7 +116,7 @@ parent: MobBearSpace suffix: "Salvage Ruleset" components: - - type: SalvageMobRestrictionsNF + - type: NFSalvageMobRestrictions # Frontier - type: entity name: space kangaroo @@ -173,7 +173,7 @@ parent: MobKangarooSpace suffix: "Salvage Ruleset" components: - - type: SalvageMobRestrictionsNF + - type: NFSalvageMobRestrictions # Frontier - type: entity name: space spider @@ -271,7 +271,7 @@ parent: MobSpiderSpace suffix: "Salvage Ruleset" components: - - type: SalvageMobRestrictionsNF + - type: NFSalvageMobRestrictions - type: entity name: space cobra @@ -368,4 +368,4 @@ parent: MobCobraSpace suffix: "Salvage Ruleset" components: - - type: SalvageMobRestrictionsNF + - type: NFSalvageMobRestrictions diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/spacetick.yml b/Resources/Prototypes/Entities/Mobs/NPCs/spacetick.yml index e3e04c8b076..896b9ac115f 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/spacetick.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/spacetick.yml @@ -85,5 +85,5 @@ parent: MobTick suffix: "Salvage Ruleset" components: - - type: SalvageMobRestrictionsNF + - type: NFSalvageMobRestrictions # Frontier diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml b/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml index d10a9b7f062..104981f61a5 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml @@ -120,7 +120,7 @@ molsPerSecondPerUnitMass: 0.0005 - type: Speech speechVerb: LargeMob - - type: SalvageMobRestrictionsNF # Frontier + - type: NFSalvageMobRestrictions # Frontier - type: ReplacementAccent # Frontier accent: genericAggressive # Frontier @@ -430,7 +430,7 @@ tags: - DoorBumpOpener - FootstepSound - - type: SalvageMobRestrictionsNF # Frontier + - type: NFSalvageMobRestrictions # Frontier - type: ReplacementAccent # Frontier accent: genericAggressive # Frontier diff --git a/Resources/Prototypes/Entities/Mobs/Player/dragon.yml b/Resources/Prototypes/Entities/Mobs/Player/dragon.yml index 63a313a1b43..3e9285aefb5 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/dragon.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/dragon.yml @@ -217,7 +217,7 @@ - type: ActionGun #Frontier action: ActionDragonsBreath #Frontier gunProto: DragonsBreathGun #Frontier - - type: SalvageMobRestrictionsNF # Frontier + - type: NFSalvageMobRestrictions # Frontier - type: entity id: ActionSpawnRift diff --git a/Resources/Prototypes/_NF/Entities/Mobs/NPCs/corpses.yml b/Resources/Prototypes/_NF/Entities/Mobs/NPCs/corpses.yml index 065dec3ca9d..12a857dcbd8 100644 --- a/Resources/Prototypes/_NF/Entities/Mobs/NPCs/corpses.yml +++ b/Resources/Prototypes/_NF/Entities/Mobs/NPCs/corpses.yml @@ -12,7 +12,7 @@ factions: - SimpleHostile - type: Carriable # Carrying system from nyanotrasen. - #- type: SalvageMobRestrictionsNF + #- type: NFSalvageMobRestrictions - type: Butcherable butcheringType: Spike spawned: diff --git a/Resources/Prototypes/_NF/Entities/Mobs/NPCs/elemental.yml b/Resources/Prototypes/_NF/Entities/Mobs/NPCs/elemental.yml index 3618900e12a..b9e12ad674e 100644 --- a/Resources/Prototypes/_NF/Entities/Mobs/NPCs/elemental.yml +++ b/Resources/Prototypes/_NF/Entities/Mobs/NPCs/elemental.yml @@ -145,7 +145,7 @@ factions: - SimpleHostile # Because AI stupid ass hell right now - type: MovementIgnoreGravity # Or they just can't do something - - type: SalvageMobRestrictionsNF + - type: NFSalvageMobRestrictions - type: entity parent: MobOreCrabNF @@ -390,7 +390,7 @@ - type: Damageable damageContainer: StructuralInorganic - type: MovementIgnoreGravity # Or they just can't do something - - type: SalvageMobRestrictionsNF + - type: NFSalvageMobRestrictions - type: Appearance # Next three components make the mob fall over when dead - type: StandingState - type: RotationVisuals diff --git a/Resources/Prototypes/_NF/Entities/Mobs/NPCs/mob_hostile_base.yml b/Resources/Prototypes/_NF/Entities/Mobs/NPCs/mob_hostile_base.yml index f73d8e48c9e..0803f37338f 100644 --- a/Resources/Prototypes/_NF/Entities/Mobs/NPCs/mob_hostile_base.yml +++ b/Resources/Prototypes/_NF/Entities/Mobs/NPCs/mob_hostile_base.yml @@ -227,7 +227,7 @@ minimumWait: 120 # 1 * 2 maximumWait: 240 # 2 * 60 nextAdvertisementTime: 0 - - type: SalvageMobRestrictionsNF + - type: NFSalvageMobRestrictions - type: FTLKnockdownImmune - type: Respirator updateInterval: 99999 # Shouldn't run often, if ever. @@ -304,7 +304,7 @@ - type: MobPrice price: 1500 deathPenalty: 0.5 - - type: SalvageMobRestrictionsNF + - type: NFSalvageMobRestrictions - type: Tag tags: - CanPilot diff --git a/Resources/Prototypes/_NF/Entities/Mobs/NPCs/mob_hostile_expeditions_xeno.yml b/Resources/Prototypes/_NF/Entities/Mobs/NPCs/mob_hostile_expeditions_xeno.yml index 2c91ea907d5..d67e754933d 100644 --- a/Resources/Prototypes/_NF/Entities/Mobs/NPCs/mob_hostile_expeditions_xeno.yml +++ b/Resources/Prototypes/_NF/Entities/Mobs/NPCs/mob_hostile_expeditions_xeno.yml @@ -284,7 +284,7 @@ - type: Tag tags: - CannotSuicide - - type: SalvageMobRestrictionsNF + - type: NFSalvageMobRestrictions - type: ReplacementAccent accent: xeno - type: GhostRole