entity storage tweaks (#19182)

This commit is contained in:
Nemanja
2023-08-15 18:49:30 -04:00
committed by GitHub
parent 87b774209f
commit b8250f9601
6 changed files with 18 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
using Content.Shared.Construction.Prototypes; using Content.Shared.Construction.Prototypes;
using Content.Shared.Power; using Content.Shared.Power;
using Content.Shared.Whitelist;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Power.Components namespace Content.Server.Power.Components
@@ -13,14 +14,12 @@ namespace Content.Server.Power.Components
/// <summary> /// <summary>
/// The charge rate of the charger, in watts /// The charge rate of the charger, in watts
/// </summary> /// </summary>
[DataField("chargeRate")] [DataField("chargeRate")]
public float ChargeRate = 20.0f; public float ChargeRate = 20.0f;
/// <summary> /// <summary>
/// The charge rate with no machine upgrades /// The charge rate with no machine upgrades
/// </summary> /// </summary>
[DataField("baseChargeRate")] [DataField("baseChargeRate")]
public float BaseChargeRate = 20.0f; public float BaseChargeRate = 20.0f;
@@ -37,7 +36,16 @@ namespace Content.Server.Power.Components
[DataField("partRatingChargeRateModifier")] [DataField("partRatingChargeRateModifier")]
public float PartRatingChargeRateModifier = 1.5f; public float PartRatingChargeRateModifier = 1.5f;
/// <summary>
/// The container ID that is holds the entities being charged.
/// </summary>
[DataField("slotId", required: true)] [DataField("slotId", required: true)]
public string SlotId = string.Empty; public string SlotId = string.Empty;
/// <summary>
/// A whitelist for what entities can be charged by this Charger.
/// </summary>
[DataField("whitelist")]
public EntityWhitelist? Whitelist;
} }
} }

View File

@@ -210,6 +210,9 @@ internal sealed class ChargerSystem : EntitySystem
if (!receiverComponent.Powered) if (!receiverComponent.Powered)
return; return;
if (component.Whitelist?.IsValid(targetEntity, EntityManager) == false)
return;
if (!SearchForBattery(targetEntity, out var heldBattery)) if (!SearchForBattery(targetEntity, out var heldBattery))
return; return;

View File

@@ -395,7 +395,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
var targetIsMob = HasComp<BodyComponent>(toInsert); var targetIsMob = HasComp<BodyComponent>(toInsert);
var storageIsItem = HasComp<ItemComponent>(container); var storageIsItem = HasComp<ItemComponent>(container);
var allowedToEat = HasComp<ItemComponent>(toInsert); var allowedToEat = whitelist?.IsValid(toInsert) ?? storageIsItem;
// BEFORE REPLACING THIS WITH, I.E. A PROPERTY: // BEFORE REPLACING THIS WITH, I.E. A PROPERTY:
// Make absolutely 100% sure you have worked out how to stop people ending up in backpacks. // Make absolutely 100% sure you have worked out how to stop people ending up in backpacks.
@@ -414,9 +414,6 @@ public abstract class SharedEntityStorageSystem : EntitySystem
} }
} }
if (allowedToEat && whitelist != null)
allowedToEat = whitelist.IsValid(toInsert);
return allowedToEat; return allowedToEat;
} }

View File

@@ -200,6 +200,9 @@
- type: Charger - type: Charger
baseChargeRate: 30 baseChargeRate: 30
slotId: entity_storage slotId: entity_storage
whitelist:
components:
- BorgChassis
- type: Construction - type: Construction
containers: containers:
- machine_parts - machine_parts

View File

@@ -35,7 +35,6 @@
layer: layer:
- MachineLayer - MachineLayer
- type: EntityStorage - type: EntityStorage
capacity: 500
- type: PlaceableSurface - type: PlaceableSurface
isPlaceable: false # defaults to closed. isPlaceable: false # defaults to closed.
- type: Damageable - type: Damageable

View File

@@ -338,7 +338,7 @@
- type: Physics - type: Physics
bodyType: Dynamic bodyType: Dynamic
- type: EntityStorage - type: EntityStorage
capacity: 500 capacity: 1
airtight: false airtight: false
- type: Fixtures - type: Fixtures
fixtures: fixtures: