Skip to content

Commit

Permalink
Allow some mobs to not despawn with events
Browse files Browse the repository at this point in the history
  • Loading branch information
dvir001 committed Sep 21, 2024
1 parent bceffc9 commit 73c9f04
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Content.Server/Salvage/SalvageSystem.ExpeditionConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private void OnSalvageFinishMessage(EntityUid entity, SalvageExpeditionConsoleCo
continue;

// NPC, definitely not a person
if (HasComp<ActiveNPCComponent>(uid) || HasComp<SalvageMobRestrictionsNFComponent>(uid))
if (HasComp<ActiveNPCComponent>(uid) || HasComp<NFSalvageMobRestrictionsComponent>(uid))
continue;

// Hostile ghost role, continue
Expand Down
12 changes: 10 additions & 2 deletions Content.Server/StationEvents/Events/BluespaceErrorRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SalvageMobRestrictionsNFComponent>();
var query = AllEntityQuery<NFSalvageMobRestrictionsComponent>();

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<NFSalvageMobRestrictionsComponent>(salvUid);
}
}
else if (gridTransform.GridUid == salvMob.LinkedGridEntity)
{
QueueDel(salvUid);
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Worldgen/Systems/LocalityLoaderSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void OnDebrisDespawn(EntityUid entity, SpaceDebrisComponent component, E
if (entity != null)
{
// Handle mobrestrictions getting deleted
var query = AllEntityQuery<SalvageMobRestrictionsNFComponent>();
var query = AllEntityQuery<NFSalvageMobRestrictionsComponent>();

while (query.MoveNext(out var salvUid, out var salvMob))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ namespace Content.Server._NF.Salvage;
/// whatever it's currently parented to.
/// </summary>
[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;
}
8 changes: 4 additions & 4 deletions Content.Server/_NF/Salvage/SalvageMobRestrictionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<SalvageMobRestrictionsNFComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<SalvageMobRestrictionsNFComponent, ComponentRemove>(OnRemove);
SubscribeLocalEvent<NFSalvageMobRestrictionsComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<NFSalvageMobRestrictionsComponent, ComponentRemove>(OnRemove);
SubscribeLocalEvent<SalvageMobRestrictionsGridComponent, ComponentRemove>(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))
Expand All @@ -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))
{
Expand Down
4 changes: 2 additions & 2 deletions Resources/Prototypes/Entities/Mobs/NPCs/carp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
parent: MobCarp
suffix: "Salvage Ruleset"
components:
- type: SalvageMobRestrictionsNF
- type: NFSalvageMobRestrictions # Frontier

- type: entity
name: space carp
Expand Down Expand Up @@ -238,4 +238,4 @@
parent: MobShark
suffix: "Salvage Ruleset"
components:
- type: SalvageMobRestrictionsNF
- type: NFSalvageMobRestrictions
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Mobs/NPCs/flesh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
Slash: 6
- type: ReplacementAccent
accent: genericAggressive
- type: SalvageMobRestrictionsNF
- type: NFSalvageMobRestrictions # Frontier

- type: entity
parent: BaseMobFleshSalvage
Expand Down
8 changes: 4 additions & 4 deletions Resources/Prototypes/Entities/Mobs/NPCs/space.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
parent: MobBearSpace
suffix: "Salvage Ruleset"
components:
- type: SalvageMobRestrictionsNF
- type: NFSalvageMobRestrictions # Frontier

- type: entity
name: space kangaroo
Expand Down Expand Up @@ -173,7 +173,7 @@
parent: MobKangarooSpace
suffix: "Salvage Ruleset"
components:
- type: SalvageMobRestrictionsNF
- type: NFSalvageMobRestrictions # Frontier

- type: entity
name: space spider
Expand Down Expand Up @@ -271,7 +271,7 @@
parent: MobSpiderSpace
suffix: "Salvage Ruleset"
components:
- type: SalvageMobRestrictionsNF
- type: NFSalvageMobRestrictions

- type: entity
name: space cobra
Expand Down Expand Up @@ -368,4 +368,4 @@
parent: MobCobraSpace
suffix: "Salvage Ruleset"
components:
- type: SalvageMobRestrictionsNF
- type: NFSalvageMobRestrictions
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Mobs/NPCs/spacetick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@
parent: MobTick
suffix: "Salvage Ruleset"
components:
- type: SalvageMobRestrictionsNF
- type: NFSalvageMobRestrictions # Frontier

4 changes: 2 additions & 2 deletions Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
molsPerSecondPerUnitMass: 0.0005
- type: Speech
speechVerb: LargeMob
- type: SalvageMobRestrictionsNF # Frontier
- type: NFSalvageMobRestrictions # Frontier
- type: ReplacementAccent # Frontier
accent: genericAggressive # Frontier

Expand Down Expand Up @@ -430,7 +430,7 @@
tags:
- DoorBumpOpener
- FootstepSound
- type: SalvageMobRestrictionsNF # Frontier
- type: NFSalvageMobRestrictions # Frontier
- type: ReplacementAccent # Frontier
accent: genericAggressive # Frontier

Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Mobs/Player/dragon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
- type: ActionGun #Frontier
action: ActionDragonsBreath #Frontier
gunProto: DragonsBreathGun #Frontier
- type: SalvageMobRestrictionsNF # Frontier
- type: NFSalvageMobRestrictions # Frontier

- type: entity
id: ActionSpawnRift
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/_NF/Entities/Mobs/NPCs/corpses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
factions:
- SimpleHostile
- type: Carriable # Carrying system from nyanotrasen.
#- type: SalvageMobRestrictionsNF
#- type: NFSalvageMobRestrictions
- type: Butcherable
butcheringType: Spike
spawned:
Expand Down
4 changes: 2 additions & 2 deletions Resources/Prototypes/_NF/Entities/Mobs/NPCs/elemental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -304,7 +304,7 @@
- type: MobPrice
price: 1500
deathPenalty: 0.5
- type: SalvageMobRestrictionsNF
- type: NFSalvageMobRestrictions
- type: Tag
tags:
- CanPilot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
- type: Tag
tags:
- CannotSuicide
- type: SalvageMobRestrictionsNF
- type: NFSalvageMobRestrictions
- type: ReplacementAccent
accent: xeno
- type: GhostRole
Expand Down

0 comments on commit 73c9f04

Please sign in to comment.