cloning machine upgrade support (#11588)
* cloning machine upgrade support * foo
This commit is contained in:
@@ -17,6 +17,7 @@ using Content.Server.MobState;
|
|||||||
using Content.Shared.Chemistry.Components;
|
using Content.Shared.Chemistry.Components;
|
||||||
using Content.Server.Fluids.EntitySystems;
|
using Content.Server.Fluids.EntitySystems;
|
||||||
using Content.Server.Chat.Systems;
|
using Content.Server.Chat.Systems;
|
||||||
|
using Content.Server.Construction;
|
||||||
using Content.Server.Construction.Components;
|
using Content.Server.Construction.Components;
|
||||||
using Content.Server.Materials;
|
using Content.Server.Materials;
|
||||||
using Content.Server.Stack;
|
using Content.Server.Stack;
|
||||||
@@ -31,7 +32,6 @@ using Robust.Shared.Configuration;
|
|||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.Physics.Components;
|
using Robust.Shared.Physics.Components;
|
||||||
|
|
||||||
|
|
||||||
namespace Content.Server.Cloning.Systems
|
namespace Content.Server.Cloning.Systems
|
||||||
{
|
{
|
||||||
public sealed class CloningSystem : EntitySystem
|
public sealed class CloningSystem : EntitySystem
|
||||||
@@ -48,6 +48,7 @@ namespace Content.Server.Cloning.Systems
|
|||||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||||
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
||||||
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||||
[Dependency] private readonly SharedStackSystem _stackSystem = default!;
|
[Dependency] private readonly SharedStackSystem _stackSystem = default!;
|
||||||
[Dependency] private readonly StackSystem _serverStackSystem = default!;
|
[Dependency] private readonly StackSystem _serverStackSystem = default!;
|
||||||
[Dependency] private readonly SpillableSystem _spillableSystem = default!;
|
[Dependency] private readonly SpillableSystem _spillableSystem = default!;
|
||||||
@@ -63,6 +64,7 @@ namespace Content.Server.Cloning.Systems
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<CloningPodComponent, ComponentInit>(OnComponentInit);
|
SubscribeLocalEvent<CloningPodComponent, ComponentInit>(OnComponentInit);
|
||||||
|
SubscribeLocalEvent<CloningPodComponent, RefreshPartsEvent>(OnPartsRefreshed);
|
||||||
SubscribeLocalEvent<CloningPodComponent, MachineDeconstructedEvent>(OnDeconstruct);
|
SubscribeLocalEvent<CloningPodComponent, MachineDeconstructedEvent>(OnDeconstruct);
|
||||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
||||||
SubscribeLocalEvent<BeingClonedComponent, MindAddedMessage>(HandleMindAdded);
|
SubscribeLocalEvent<BeingClonedComponent, MindAddedMessage>(HandleMindAdded);
|
||||||
@@ -77,17 +79,20 @@ namespace Content.Server.Cloning.Systems
|
|||||||
_signalSystem.EnsureReceiverPorts(uid, CloningPodComponent.PodPort);
|
_signalSystem.EnsureReceiverPorts(uid, CloningPodComponent.PodPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnPartsRefreshed(EntityUid uid, CloningPodComponent component, RefreshPartsEvent args)
|
||||||
|
{
|
||||||
|
var materialRating = args.PartRatings[component.MachinePartMaterialUse];
|
||||||
|
var speedRating = args.PartRatings[component.MachinePartCloningSpeed];
|
||||||
|
|
||||||
|
component.BiomassRequirementMultiplier = MathF.Pow(component.PartRatingMaterialMultiplier, materialRating - 1);
|
||||||
|
component.CloningTime = component.BaseCloningTime * MathF.Pow(component.PartRatingSpeedMultiplier, speedRating - 1);
|
||||||
|
}
|
||||||
|
|
||||||
private void OnDeconstruct(EntityUid uid, CloningPodComponent component, MachineDeconstructedEvent args)
|
private void OnDeconstruct(EntityUid uid, CloningPodComponent component, MachineDeconstructedEvent args)
|
||||||
{
|
{
|
||||||
_serverStackSystem.SpawnMultiple(_material.GetMaterialAmount(uid, "Biomass"), 100, "Biomass", Transform(uid).Coordinates);
|
_serverStackSystem.SpawnMultiple(_material.GetMaterialAmount(uid, "Biomass"), 100, "Biomass", Transform(uid).Coordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAppearance(CloningPodComponent clonePod)
|
|
||||||
{
|
|
||||||
if (TryComp<AppearanceComponent>(clonePod.Owner, out var appearance))
|
|
||||||
appearance.SetData(CloningPodVisuals.Status, clonePod.Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void TransferMindToClone(Mind.Mind mind)
|
internal void TransferMindToClone(Mind.Mind mind)
|
||||||
{
|
{
|
||||||
if (!ClonesWaitingForMind.TryGetValue(mind, out var entity) ||
|
if (!ClonesWaitingForMind.TryGetValue(mind, out var entity) ||
|
||||||
@@ -106,7 +111,7 @@ namespace Content.Server.Cloning.Systems
|
|||||||
if (clonedComponent.Parent == EntityUid.Invalid ||
|
if (clonedComponent.Parent == EntityUid.Invalid ||
|
||||||
!EntityManager.EntityExists(clonedComponent.Parent) ||
|
!EntityManager.EntityExists(clonedComponent.Parent) ||
|
||||||
!TryComp<CloningPodComponent>(clonedComponent.Parent, out var cloningPodComponent) ||
|
!TryComp<CloningPodComponent>(clonedComponent.Parent, out var cloningPodComponent) ||
|
||||||
clonedComponent.Owner != cloningPodComponent.BodyContainer?.ContainedEntity)
|
clonedComponent.Owner != cloningPodComponent.BodyContainer.ContainedEntity)
|
||||||
{
|
{
|
||||||
EntityManager.RemoveComponent<BeingClonedComponent>(clonedComponent.Owner);
|
EntityManager.RemoveComponent<BeingClonedComponent>(clonedComponent.Owner);
|
||||||
return;
|
return;
|
||||||
@@ -142,7 +147,7 @@ namespace Content.Server.Cloning.Systems
|
|||||||
|
|
||||||
public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Mind.Mind mind, CloningPodComponent? clonePod)
|
public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Mind.Mind mind, CloningPodComponent? clonePod)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref clonePod) || bodyToClone == null)
|
if (!Resolve(uid, ref clonePod))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (HasComp<ActiveCloningPodComponent>(uid))
|
if (HasComp<ActiveCloningPodComponent>(uid))
|
||||||
@@ -175,7 +180,7 @@ namespace Content.Server.Cloning.Systems
|
|||||||
if (!TryComp<PhysicsComponent>(bodyToClone, out var physics))
|
if (!TryComp<PhysicsComponent>(bodyToClone, out var physics))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int cloningCost = (int) physics.FixturesMass;
|
var cloningCost = (int) Math.Round(physics.FixturesMass * clonePod.BiomassRequirementMultiplier);
|
||||||
|
|
||||||
if (_configManager.GetCVar(CCVars.BiomassEasyMode))
|
if (_configManager.GetCVar(CCVars.BiomassEasyMode))
|
||||||
cloningCost = (int) Math.Round(cloningCost * EasyModeCloningCost);
|
cloningCost = (int) Math.Round(cloningCost * EasyModeCloningCost);
|
||||||
@@ -221,7 +226,6 @@ namespace Content.Server.Cloning.Systems
|
|||||||
cloneMindReturn.Mind = mind;
|
cloneMindReturn.Mind = mind;
|
||||||
cloneMindReturn.Parent = clonePod.Owner;
|
cloneMindReturn.Parent = clonePod.Owner;
|
||||||
clonePod.BodyContainer.Insert(mob);
|
clonePod.BodyContainer.Insert(mob);
|
||||||
clonePod.CapturedMind = mind;
|
|
||||||
ClonesWaitingForMind.Add(mind, mob);
|
ClonesWaitingForMind.Add(mind, mob);
|
||||||
UpdateStatus(CloningPodStatus.NoMind, clonePod);
|
UpdateStatus(CloningPodStatus.NoMind, clonePod);
|
||||||
_euiManager.OpenEui(new AcceptCloningEui(mind, this), client);
|
_euiManager.OpenEui(new AcceptCloningEui(mind, this), client);
|
||||||
@@ -235,7 +239,7 @@ namespace Content.Server.Cloning.Systems
|
|||||||
{
|
{
|
||||||
foreach (var special in mind.CurrentJob.Prototype.Special)
|
foreach (var special in mind.CurrentJob.Prototype.Special)
|
||||||
{
|
{
|
||||||
if (special.GetType() == typeof(AddComponentSpecial))
|
if (special is AddComponentSpecial)
|
||||||
special.AfterEquip(mob);
|
special.AfterEquip(mob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,7 +250,7 @@ namespace Content.Server.Cloning.Systems
|
|||||||
public void UpdateStatus(CloningPodStatus status, CloningPodComponent cloningPod)
|
public void UpdateStatus(CloningPodStatus status, CloningPodComponent cloningPod)
|
||||||
{
|
{
|
||||||
cloningPod.Status = status;
|
cloningPod.Status = status;
|
||||||
UpdateAppearance(cloningPod);
|
_appearance.SetData(cloningPod.Owner, CloningPodVisuals.Status, cloningPod.Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
@@ -280,7 +284,6 @@ namespace Content.Server.Cloning.Systems
|
|||||||
|
|
||||||
EntityManager.RemoveComponent<BeingClonedComponent>(entity);
|
EntityManager.RemoveComponent<BeingClonedComponent>(entity);
|
||||||
clonePod.BodyContainer.Remove(entity);
|
clonePod.BodyContainer.Remove(entity);
|
||||||
clonePod.CapturedMind = null;
|
|
||||||
clonePod.CloningProgress = 0f;
|
clonePod.CloningProgress = 0f;
|
||||||
clonePod.UsedBiomass = 0;
|
clonePod.UsedBiomass = 0;
|
||||||
UpdateStatus(CloningPodStatus.Idle, clonePod);
|
UpdateStatus(CloningPodStatus.Idle, clonePod);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using Content.Shared.Cloning;
|
using Content.Shared.Cloning;
|
||||||
|
using Content.Shared.Construction.Prototypes;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
|
|
||||||
namespace Content.Server.Cloning.Components
|
namespace Content.Server.Cloning.Components
|
||||||
{
|
{
|
||||||
@@ -7,14 +9,69 @@ namespace Content.Server.Cloning.Components
|
|||||||
public sealed class CloningPodComponent : Component
|
public sealed class CloningPodComponent : Component
|
||||||
{
|
{
|
||||||
public const string PodPort = "CloningPodReceiver";
|
public const string PodPort = "CloningPodReceiver";
|
||||||
[ViewVariables] public ContainerSlot BodyContainer = default!;
|
|
||||||
[ViewVariables] public Mind.Mind? CapturedMind;
|
[ViewVariables]
|
||||||
[ViewVariables] public float CloningProgress = 0;
|
public ContainerSlot BodyContainer = default!;
|
||||||
[ViewVariables] public int UsedBiomass = 70;
|
|
||||||
[ViewVariables] public bool FailedClone = false;
|
/// <summary>
|
||||||
[DataField("cloningTime")]
|
/// How long the cloning has been going on for.
|
||||||
[ViewVariables] public float CloningTime = 30f;
|
/// </summary>
|
||||||
[ViewVariables] public CloningPodStatus Status;
|
[ViewVariables]
|
||||||
|
public float CloningProgress = 0;
|
||||||
|
|
||||||
|
[ViewVariables]
|
||||||
|
public int UsedBiomass = 70;
|
||||||
|
|
||||||
|
[ViewVariables]
|
||||||
|
public bool FailedClone = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The base amount of time it takes to clone a body
|
||||||
|
/// </summary>
|
||||||
|
[DataField("baseCloningTime")]
|
||||||
|
public float BaseCloningTime = 30f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The multiplier for cloning duration
|
||||||
|
/// </summary>
|
||||||
|
[DataField("partRatingSpeedMultiplier")]
|
||||||
|
public float PartRatingSpeedMultiplier = 0.75f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The machine part that affects cloning speed
|
||||||
|
/// </summary>
|
||||||
|
[DataField("machinePartCloningSpeed", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
|
||||||
|
public string MachinePartCloningSpeed = "ScanningModule";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current amount of time it takes to clone a body
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public float CloningTime = 30f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The machine part that affects how much biomass is needed to clone a body.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("partRatingMaterialMultiplier")]
|
||||||
|
public float PartRatingMaterialMultiplier = 0.85f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current multiplier on the body weight, which determines the
|
||||||
|
/// amount of biomass needed to clone.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public float BiomassRequirementMultiplier = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The machine part that decreases the amount of material needed for cloning
|
||||||
|
/// </summary>
|
||||||
|
[DataField("machinePartMaterialUse", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
|
||||||
|
public string MachinePartMaterialUse = "Manipulator";
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public CloningPodStatus Status;
|
||||||
|
|
||||||
|
[ViewVariables]
|
||||||
public EntityUid? ConnectedConsole;
|
public EntityUid? ConnectedConsole;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user