mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
Infer type for EntSelector (#30856)
Infer type for EntSelector.cs (cherry picked from commit e180a1b11b552ab790c59e3e5ee6ef2eeedb8bd5)
This commit is contained in:
@@ -8,7 +8,9 @@ namespace Content.Shared.EntityTable.EntitySelectors;
|
||||
/// </summary>
|
||||
public sealed partial class EntSelector : EntityTableSelector
|
||||
{
|
||||
[DataField(required: true)]
|
||||
public const string IdDataFieldTag = "id";
|
||||
|
||||
[DataField(IdDataFieldTag, required: true)]
|
||||
public EntProtoId Id;
|
||||
|
||||
[DataField]
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
using Robust.Shared.Serialization.Markdown.Mapping;
|
||||
using Robust.Shared.Serialization.Markdown.Validation;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Interfaces;
|
||||
|
||||
namespace Content.Shared.EntityTable.EntitySelectors;
|
||||
|
||||
[TypeSerializer]
|
||||
public sealed class EntityTableTypeSerializer :
|
||||
ITypeReader<EntityTableSelector, MappingDataNode>
|
||||
{
|
||||
public ValidationNode Validate(ISerializationManager serializationManager,
|
||||
MappingDataNode node,
|
||||
IDependencyCollection dependencies,
|
||||
ISerializationContext? context = null)
|
||||
{
|
||||
if (node.Has(EntSelector.IdDataFieldTag))
|
||||
return serializationManager.ValidateNode<EntSelector>(node, context);
|
||||
|
||||
return new ErrorNode(node, "Custom validation not supported! Please specify the type manually!");
|
||||
}
|
||||
|
||||
public EntityTableSelector Read(ISerializationManager serializationManager,
|
||||
MappingDataNode node,
|
||||
IDependencyCollection dependencies,
|
||||
SerializationHookContext hookCtx,
|
||||
ISerializationContext? context = null,
|
||||
ISerializationManager.InstantiationDelegate<EntityTableSelector>? instanceProvider = null)
|
||||
{
|
||||
var type = typeof(EntityTableSelector);
|
||||
if (node.Has(EntSelector.IdDataFieldTag))
|
||||
type = typeof(EntSelector);
|
||||
|
||||
return (EntityTableSelector) serializationManager.Read(type, node, context)!;
|
||||
}
|
||||
}
|
||||
@@ -2,67 +2,43 @@
|
||||
id: AllPlushiesTable
|
||||
table: !type:GroupSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: PlushieBee
|
||||
- !type:EntSelector
|
||||
id: PlushieNar
|
||||
- id: PlushieBee
|
||||
- id: PlushieNar
|
||||
weight: 0.5
|
||||
- !type:EntSelector
|
||||
id: PlushieRatvar
|
||||
- id: PlushieRatvar
|
||||
weight: 0.5
|
||||
- !type:EntSelector
|
||||
id: PlushieNuke
|
||||
- !type:EntSelector
|
||||
id: PlushieSlime
|
||||
- !type:EntSelector
|
||||
id: PlushieSnake
|
||||
- id: PlushieNuke
|
||||
- id: PlushieSlime
|
||||
- id: PlushieSnake
|
||||
- !type:GroupSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: PlushieLizard
|
||||
- id: PlushieLizard
|
||||
weight: 9
|
||||
- !type:EntSelector
|
||||
id: PlushieSpaceLizard
|
||||
- id: PlushieSpaceLizard
|
||||
weight: 1
|
||||
- !type:GroupSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: PlushieCarp
|
||||
- !type:EntSelector
|
||||
id: PlushieHolocarp
|
||||
- id: PlushieCarp
|
||||
- id: PlushieHolocarp
|
||||
weight: 0.25
|
||||
- !type:EntSelector
|
||||
id: PlushieMagicarp
|
||||
- id: PlushieMagicarp
|
||||
weight: 0.25
|
||||
- !type:EntSelector
|
||||
id: PlushieRainbowCarp
|
||||
- id: PlushieRainbowCarp
|
||||
weight: 0.15
|
||||
- !type:EntSelector
|
||||
id: PlushieVox
|
||||
- !type:EntSelector
|
||||
id: PlushieRouny
|
||||
- id: PlushieVox
|
||||
- id: PlushieRouny
|
||||
- !type:GroupSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: PlushieSharkBlue
|
||||
- !type:EntSelector
|
||||
id: PlushieSharkGrey
|
||||
- !type:EntSelector
|
||||
id: PlushieSharkPink
|
||||
- !type:EntSelector
|
||||
id: PlushieAtmosian
|
||||
- !type:EntSelector
|
||||
id: PlushieDiona
|
||||
- !type:EntSelector
|
||||
id: PlushieXeno
|
||||
- !type:EntSelector
|
||||
id: PlushieHampter
|
||||
- !type:EntSelector
|
||||
id: PlushieMoth
|
||||
- !type:EntSelector
|
||||
id: PlushieArachind
|
||||
- !type:EntSelector
|
||||
id: PlushiePenguin
|
||||
- id: PlushieSharkBlue
|
||||
- id: PlushieSharkGrey
|
||||
- id: PlushieSharkPink
|
||||
- id: PlushieAtmosian
|
||||
- id: PlushieDiona
|
||||
- id: PlushieXeno
|
||||
- id: PlushieHampter
|
||||
- id: PlushieMoth
|
||||
- id: PlushieArachind
|
||||
- id: PlushiePenguin
|
||||
|
||||
- type: entity
|
||||
id: CrateFunPlushie
|
||||
@@ -87,12 +63,10 @@
|
||||
containers:
|
||||
entity_storage: !type:AllSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: PlushieLizard
|
||||
- id: PlushieLizard
|
||||
amount: !type:ConstantNumberSelector
|
||||
value: 3
|
||||
- !type:EntSelector
|
||||
id: PlushieSpaceLizard
|
||||
- id: PlushieSpaceLizard
|
||||
amount: !type:ConstantNumberSelector
|
||||
value: 3
|
||||
|
||||
|
||||
@@ -7,46 +7,31 @@
|
||||
containers:
|
||||
entity_storage: !type:AllSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: ClothingBeltMilitaryWebbing
|
||||
- !type:EntSelector
|
||||
id: ClothingHandsGlovesCombat
|
||||
- !type:EntSelector
|
||||
id: JetpackBlackFilled
|
||||
- !type:EntSelector
|
||||
id: ClothingUniformJumpsuitOperative
|
||||
- !type:EntSelector
|
||||
id: ClothingUniformJumpskirtOperative
|
||||
- !type:EntSelector
|
||||
id: ClothingHeadsetAltSyndicate
|
||||
- !type:EntSelector
|
||||
id: ClothingEyesHudSyndicate
|
||||
- id: ClothingBeltMilitaryWebbing
|
||||
- id: ClothingHandsGlovesCombat
|
||||
- id: JetpackBlackFilled
|
||||
- id: ClothingUniformJumpsuitOperative
|
||||
- id: ClothingUniformJumpskirtOperative
|
||||
- id: ClothingHeadsetAltSyndicate
|
||||
- id: ClothingEyesHudSyndicate
|
||||
|
||||
- type: entityTable
|
||||
id: FillLockerEmergencyStandard
|
||||
table: !type:AllSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: ClothingMaskBreath
|
||||
- !type:EntSelector
|
||||
id: ClothingOuterSuitEmergency
|
||||
- id: ClothingMaskBreath
|
||||
- id: ClothingOuterSuitEmergency
|
||||
- !type:GroupSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: EmergencyOxygenTankFilled
|
||||
- !type:EntSelector
|
||||
id: OxygenTankFilled
|
||||
- !type:EntSelector
|
||||
id: ToolboxEmergencyFilled
|
||||
- id: EmergencyOxygenTankFilled
|
||||
- id: OxygenTankFilled
|
||||
- id: ToolboxEmergencyFilled
|
||||
prob: 0.5
|
||||
- !type:EntSelector
|
||||
id: MedkitOxygenFilled
|
||||
- id: MedkitOxygenFilled
|
||||
prob: 0.2
|
||||
- !type:EntSelector
|
||||
id: WeaponFlareGun
|
||||
- id: WeaponFlareGun
|
||||
prob: 0.05
|
||||
- !type:EntSelector
|
||||
id: BoxMRE
|
||||
- id: BoxMRE
|
||||
prob: 0.1
|
||||
|
||||
- type: entity
|
||||
@@ -78,42 +63,30 @@
|
||||
containers:
|
||||
entity_storage: !type:AllSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: ClothingMaskBreath
|
||||
- !type:EntSelector
|
||||
id: ClothingOuterSuitEmergency
|
||||
- id: ClothingMaskBreath
|
||||
- id: ClothingOuterSuitEmergency
|
||||
- !type:GroupSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: EmergencyNitrogenTankFilled
|
||||
- !type:EntSelector
|
||||
id: NitrogenTankFilled
|
||||
- id: EmergencyNitrogenTankFilled
|
||||
- id: NitrogenTankFilled
|
||||
|
||||
- type: entityTable
|
||||
id: FillLockerFireStandard
|
||||
table: !type:AllSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: ClothingOuterSuitFire
|
||||
- !type:EntSelector
|
||||
id: ClothingHeadHelmetFire
|
||||
- !type:EntSelector
|
||||
id: ClothingMaskGas
|
||||
- id: ClothingOuterSuitFire
|
||||
- id: ClothingHeadHelmetFire
|
||||
- id: ClothingMaskGas
|
||||
- !type:GroupSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: EmergencyOxygenTankFilled
|
||||
- !type:EntSelector
|
||||
id: OxygenTankFilled
|
||||
- !type:EntSelector
|
||||
id: CrowbarRed
|
||||
- id: EmergencyOxygenTankFilled
|
||||
- id: OxygenTankFilled
|
||||
- id: CrowbarRed
|
||||
- !type:GroupSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: FireExtinguisher
|
||||
- id: FireExtinguisher
|
||||
weight: 98
|
||||
- !type:EntSelector
|
||||
id: SprayBottleWater #It's just budget cut after budget cut man
|
||||
- id: SprayBottleWater #It's just budget cut after budget cut man
|
||||
weight: 2
|
||||
|
||||
- type: entity
|
||||
@@ -142,28 +115,17 @@
|
||||
children:
|
||||
- !type:GroupSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: ClothingUniformJumpsuitOperative
|
||||
- !type:EntSelector
|
||||
id: ClothingUniformJumpskirtOperative
|
||||
- !type:EntSelector
|
||||
id: ClothingBackpackDuffelSyndicate
|
||||
- !type:EntSelector
|
||||
id: CyberPen
|
||||
- !type:EntSelector
|
||||
id: CigPackSyndicate
|
||||
- !type:EntSelector
|
||||
id: ClothingBackpackDuffelSyndicatePyjamaBundle
|
||||
- !type:EntSelector
|
||||
id: ClothingBeltMilitaryWebbing
|
||||
- !type:EntSelector
|
||||
id: ClothingShoesBootsCombatFilled
|
||||
- !type:EntSelector
|
||||
id: ToolboxSyndicateFilled
|
||||
- !type:EntSelector
|
||||
id: BalloonSyn
|
||||
- !type:EntSelector
|
||||
id: WeaponSniperMosin
|
||||
- id: ClothingUniformJumpsuitOperative
|
||||
- id: ClothingUniformJumpskirtOperative
|
||||
- id: ClothingBackpackDuffelSyndicate
|
||||
- id: CyberPen
|
||||
- id: CigPackSyndicate
|
||||
- id: ClothingBackpackDuffelSyndicatePyjamaBundle
|
||||
- id: ClothingBeltMilitaryWebbing
|
||||
- id: ClothingShoesBootsCombatFilled
|
||||
- id: ToolboxSyndicateFilled
|
||||
- id: BalloonSyn
|
||||
- id: WeaponSniperMosin
|
||||
weight: 2
|
||||
- !type:EntSelector
|
||||
id: ClothingEyesNightVisionGogglesSyndie
|
||||
@@ -174,8 +136,7 @@
|
||||
id: MaintenanceLockerLoot
|
||||
table: !type:AllSelector
|
||||
children:
|
||||
- !type:EntSelector
|
||||
id: StrangePill
|
||||
- id: StrangePill
|
||||
prob: 0.20
|
||||
# Tools
|
||||
- !type:NestedSelector
|
||||
|
||||
Reference in New Issue
Block a user