biomass reclaimer machine part upgrade support (#11545)
* biomass reclaimer upgrade * readonly struct
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using Content.Shared.Storage;
|
||||
using System.Threading;
|
||||
using Content.Shared.Construction.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Medical.BiomassReclaimer
|
||||
{
|
||||
@@ -34,15 +36,40 @@ namespace Content.Server.Medical.BiomassReclaimer
|
||||
/// <summary>
|
||||
/// How many units of biomass it produces for each unit of mass.
|
||||
/// </summary>
|
||||
[DataField("yieldPerUnitMass")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float YieldPerUnitMass = 0.4f;
|
||||
|
||||
/// <summary>
|
||||
/// The base yield when no components are upgraded
|
||||
/// </summary>
|
||||
[DataField("baseYieldPerUnitMass")]
|
||||
public float BaseYieldPerUnitMass = 0.4f;
|
||||
|
||||
/// <summary>
|
||||
/// Machine part whose rating modifies the yield per mass.
|
||||
/// </summary>
|
||||
[DataField("machinePartYieldAmount", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
|
||||
public string MachinePartYieldAmount = "Manipulator";
|
||||
|
||||
/// <summary>
|
||||
/// Lower number = faster processing.
|
||||
/// Good for machine upgrading I guess.
|
||||
/// </summmary>
|
||||
public float ProcessingSpeedMultiplier = 0.5f;
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float ProcessingSpeedMultiplier = 0.4f;
|
||||
|
||||
/// <summary>
|
||||
/// The base multiplier of processing speed with no upgrades
|
||||
/// that is used with the weight to calculate the yield
|
||||
/// </summary>
|
||||
[DataField("baseProcessingSpeedMultiplier")]
|
||||
public float BaseProcessingSpeedMultiplier = 0.4f;
|
||||
|
||||
/// <summary>
|
||||
/// The machine part that increses the processing speed.
|
||||
/// </summary>
|
||||
[DataField("machinePartProcessSpeed", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
|
||||
public string MachinePartProcessingSpeed = "Laser";
|
||||
|
||||
/// <summary>
|
||||
/// Will this refuse to gib a living mob?
|
||||
|
||||
@@ -15,6 +15,7 @@ using Content.Server.Power.Components;
|
||||
using Content.Server.Fluids.EntitySystems;
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Climbing;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Humanoid;
|
||||
using Content.Server.Mind.Components;
|
||||
@@ -91,6 +92,7 @@ namespace Content.Server.Medical.BiomassReclaimer
|
||||
SubscribeLocalEvent<ActiveBiomassReclaimerComponent, UnanchorAttemptEvent>(OnUnanchorAttempt);
|
||||
SubscribeLocalEvent<BiomassReclaimerComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
|
||||
SubscribeLocalEvent<BiomassReclaimerComponent, ClimbedOnEvent>(OnClimbedOn);
|
||||
SubscribeLocalEvent<BiomassReclaimerComponent, RefreshPartsEvent>(OnRefreshParts);
|
||||
SubscribeLocalEvent<ReclaimSuccessfulEvent>(OnReclaimSuccessful);
|
||||
SubscribeLocalEvent<ReclaimCancelledEvent>(OnReclaimCancelled);
|
||||
}
|
||||
@@ -148,6 +150,19 @@ namespace Content.Server.Medical.BiomassReclaimer
|
||||
StartProcessing(args.Climber, component);
|
||||
}
|
||||
|
||||
private void OnRefreshParts(EntityUid uid, BiomassReclaimerComponent component, RefreshPartsEvent args)
|
||||
{
|
||||
var laserRating = args.PartRatings[component.MachinePartProcessingSpeed];
|
||||
var manipRating = args.PartRatings[component.MachinePartYieldAmount];
|
||||
|
||||
//sloping down from 1/2 multiplier
|
||||
component.ProcessingSpeedMultiplier =
|
||||
component.BaseProcessingSpeedMultiplier * MathF.Pow(0.65f, laserRating - 1) + 0.1f;
|
||||
|
||||
//linear increase by .1 per rating
|
||||
component.YieldPerUnitMass = component.BaseYieldPerUnitMass + (manipRating - 1) * 0.1f;
|
||||
}
|
||||
|
||||
private void OnReclaimSuccessful(ReclaimSuccessfulEvent args)
|
||||
{
|
||||
if (!TryComp<BiomassReclaimerComponent>(args.Reclaimer, out var reclaimer))
|
||||
@@ -210,19 +225,20 @@ namespace Content.Server.Medical.BiomassReclaimer
|
||||
return false;
|
||||
|
||||
// Reject souled bodies in easy mode.
|
||||
if (_configManager.GetCVar(CCVars.BiomassEasyMode) && HasComp<HumanoidComponent>(dragged) &&
|
||||
if (_configManager.GetCVar(CCVars.BiomassEasyMode) &&
|
||||
HasComp<HumanoidComponent>(dragged) &&
|
||||
TryComp<MindComponent>(dragged, out var mindComp))
|
||||
{
|
||||
if (mindComp.Mind?.UserId != null && _playerManager.TryGetSessionById(mindComp.Mind.UserId.Value, out var client))
|
||||
return false;
|
||||
}
|
||||
{
|
||||
if (mindComp.Mind?.UserId != null && _playerManager.TryGetSessionById(mindComp.Mind.UserId.Value, out _))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private sealed class ReclaimCancelledEvent : EntityEventArgs
|
||||
private readonly struct ReclaimCancelledEvent
|
||||
{
|
||||
public EntityUid Reclaimer;
|
||||
public readonly EntityUid Reclaimer;
|
||||
|
||||
public ReclaimCancelledEvent(EntityUid reclaimer)
|
||||
{
|
||||
@@ -230,11 +246,11 @@ namespace Content.Server.Medical.BiomassReclaimer
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class ReclaimSuccessfulEvent : EntityEventArgs
|
||||
private readonly struct ReclaimSuccessfulEvent
|
||||
{
|
||||
public EntityUid User;
|
||||
public EntityUid Target;
|
||||
public EntityUid Reclaimer;
|
||||
public readonly EntityUid User;
|
||||
public readonly EntityUid Target;
|
||||
public readonly EntityUid Reclaimer;
|
||||
public ReclaimSuccessfulEvent(EntityUid user, EntityUid target, EntityUid reclaimer)
|
||||
{
|
||||
User = user;
|
||||
|
||||
Reference in New Issue
Block a user