Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow some mobs to not despawn with events #2039

Merged
merged 3 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 11 additions & 1 deletion Content.Server/StationEvents/Events/BluespaceErrorRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,20 @@ 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 (!salvMob.DespawnIfOffLinkedGrid)
{
var transform = Transform(salvUid);
if (transform.GridUid != salvMob.LinkedGridEntity)
{
RemComp<NFSalvageMobRestrictionsComponent>(salvUid);
continue;
}
}

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
@@ -1,9 +1,3 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using System;

namespace Content.Server._NF.Salvage;

/// <summary>
Expand All @@ -14,9 +8,15 @@ 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;

/// <summary>
/// If set to false, this mob will not be despawned when its linked entity is despawned.
/// Useful for event ghost roles, for instance.
/// </summary>
[DataField]
public bool DespawnIfOffLinkedGrid = 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
Loading