Add strange pills, RandomFillSolutionComponent (#15067)
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
using Content.Server.Chemistry.EntitySystems;
|
||||||
|
using Content.Shared.FixedPoint;
|
||||||
|
using Content.Shared.Random;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
|
|
||||||
|
namespace Content.Server.Chemistry.Components.SolutionManager;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fills a solution container randomly using a weighted random prototype
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, Access(typeof(SolutionRandomFillSystem))]
|
||||||
|
public sealed class RandomFillSolutionComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Solution name which to add reagents to.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("solution")]
|
||||||
|
public string Solution { get; set; } = "default";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Weighted random prototype Id. Used to pick reagent.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("weightedRandomId", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<WeightedRandomPrototype>))]
|
||||||
|
public string WeightedRandomId { get; set; } = "default";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Amount of reagent to add.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("quantity")]
|
||||||
|
public FixedPoint2 Quantity { get; set; } = 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using Content.Server.Chemistry.Components.SolutionManager;
|
||||||
|
using Content.Shared.Chemistry.Reagent;
|
||||||
|
using Content.Shared.Random;
|
||||||
|
using Content.Shared.Random.Helpers;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
|
namespace Content.Server.Chemistry.EntitySystems;
|
||||||
|
|
||||||
|
public sealed class SolutionRandomFillSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly SolutionContainerSystem _solutionsSystem = default!;
|
||||||
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||||
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<RandomFillSolutionComponent, MapInitEvent>(OnRandomSolutionFillMapInit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnRandomSolutionFillMapInit(EntityUid uid, RandomFillSolutionComponent component, MapInitEvent args)
|
||||||
|
{
|
||||||
|
var target = _solutionsSystem.EnsureSolution(uid, component.Solution);
|
||||||
|
var reagent = _proto.Index<WeightedRandomPrototype>(component.WeightedRandomId).Pick(_random);
|
||||||
|
|
||||||
|
if (!_proto.TryIndex<ReagentPrototype>(reagent, out ReagentPrototype? reagentProto))
|
||||||
|
{
|
||||||
|
Logger.Error(
|
||||||
|
$"Tried to add invalid reagent Id {reagent} using SolutionRandomFill.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
target.AddReagent(reagent, component.Quantity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -125,6 +125,8 @@
|
|||||||
prob: 0.1
|
prob: 0.1
|
||||||
- id: ClothingHandsGlovesColorYellowBudget
|
- id: ClothingHandsGlovesColorYellowBudget
|
||||||
prob: 0.25
|
prob: 0.25
|
||||||
|
- id: StrangePill
|
||||||
|
prob: 0.20
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: ClosetWallMaintenanceFilledRandom
|
id: ClosetWallMaintenanceFilledRandom
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
- type: weightedRandom
|
||||||
|
id: RandomFillStrangePill
|
||||||
|
weights:
|
||||||
|
# Elements
|
||||||
|
Aluminium: 1
|
||||||
|
Carbon: 1
|
||||||
|
Chlorine: 1
|
||||||
|
Copper: 1
|
||||||
|
Fluorine: 1
|
||||||
|
Hydrogen: 1
|
||||||
|
Iodine: 1
|
||||||
|
Lithium: 1
|
||||||
|
Mercury: 1
|
||||||
|
Potassium: 1
|
||||||
|
Phosphorus: 1
|
||||||
|
Radium: 1
|
||||||
|
Silicon: 1
|
||||||
|
Sulfur: 1
|
||||||
|
Sodium: 1
|
||||||
|
# Medicines
|
||||||
|
Ipecac: 3
|
||||||
|
Omnizine: 2
|
||||||
|
Tricordrazine: 3
|
||||||
|
# Narcotics
|
||||||
|
Desoxyephedrine: 3
|
||||||
|
Ephedrine: 3
|
||||||
|
SpaceDrugs: 5
|
||||||
|
Nocturine: 3
|
||||||
|
MuteToxin: 3
|
||||||
|
NorepinephricAcid: 3
|
||||||
|
# Toxins
|
||||||
|
ChloralHydrate: 3
|
||||||
|
Mold: 3
|
||||||
|
Pax: 3
|
||||||
|
Toxin: 5
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
name: strange pill
|
||||||
|
parent: Pill
|
||||||
|
id: StrangePill
|
||||||
|
description: This unusual pill bears no markings. There's no telling what it contains.
|
||||||
|
components:
|
||||||
|
- type: SolutionContainerManager
|
||||||
|
solutions:
|
||||||
|
food:
|
||||||
|
maxVol: 20
|
||||||
|
- type: RandomFillSolution
|
||||||
|
solution: food
|
||||||
|
weightedRandomId: RandomFillStrangePill
|
||||||
|
quantity: 20
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Objects/Specific/Chemistry/pills.rsi
|
||||||
|
netsync: false
|
||||||
|
layers:
|
||||||
|
- state: pill1
|
||||||
|
map: [ "enum.DamageStateVisualLayers.Base" ]
|
||||||
|
- type: RandomSprite
|
||||||
|
available:
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill1: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill2: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill3: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill4: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill5: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill6: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill7: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill8: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill9: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill10: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill11: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill12: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill13: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill14: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill15: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill16: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill17: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill18: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill19: ""
|
||||||
|
- enum.DamageStateVisualLayers.Base:
|
||||||
|
pill20: ""
|
||||||
Reference in New Issue
Block a user