Lathe Refactor and ECS (#11201)

* lathe and material storage refactor

* materialStorage ECS

it kinda sus tho

* beginning the lathe shitcode dive

* couple lathe visuals and lathe system

* lathe changes and such

* dynamic lathe databases

* rewrote internal logic

on to ui

* da newI

* material display clientside

* misc ui changes

* component state handling and various other things

* moar

* Update Content.Shared/Lathe/LatheComponent.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* first volley of sloth review

* more fixes

* losin' my mind

* all da changes

* test fix and other review

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Nemanja
2022-09-16 19:49:05 -04:00
committed by GitHub
parent b62ab67fcb
commit 2e7dcb1ed8
40 changed files with 1225 additions and 1554 deletions

View File

@@ -16,13 +16,14 @@ using Content.Server.EUI;
using Content.Server.MachineLinking.System;
using Content.Server.MachineLinking.Events;
using Content.Server.MobState;
using Content.Server.Lathe.Components;
using Content.Shared.Chemistry.Components;
using Content.Server.Fluids.EntitySystems;
using Content.Server.Chat.Systems;
using Content.Server.Construction.Components;
using Content.Server.Materials;
using Content.Server.Stack;
using Content.Server.Jobs;
using Content.Shared.Materials;
using Robust.Server.GameObjects;
using Robust.Server.Containers;
using Robust.Server.Player;
@@ -54,6 +55,7 @@ namespace Content.Server.Cloning.Systems
[Dependency] private readonly SpillableSystem _spillableSystem = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly IConfigurationManager _configManager = default!;
[Dependency] private readonly MaterialStorageSystem _material = default!;
public readonly Dictionary<Mind.Mind, EntityUid> ClonesWaitingForMind = new();
public const float EasyModeCloningCost = 0.7f;
@@ -79,10 +81,7 @@ namespace Content.Server.Cloning.Systems
private void OnDeconstruct(EntityUid uid, CloningPodComponent component, MachineDeconstructedEvent args)
{
if (!TryComp<MaterialStorageComponent>(uid, out var storage))
return;
_serverStackSystem.SpawnMultiple(storage.GetMaterialAmount("Biomass"), 100, "Biomass", Transform(uid).Coordinates);
_serverStackSystem.SpawnMultiple(_material.GetMaterialAmount(uid, "Biomass"), 100, "Biomass", Transform(uid).Coordinates);
}
private void UpdateAppearance(CloningPodComponent clonePod)
@@ -140,8 +139,7 @@ namespace Content.Server.Cloning.Systems
if (!args.IsInDetailsRange || !_powerReceiverSystem.IsPowered(uid))
return;
if (TryComp<MaterialStorageComponent>(uid, out var storage))
args.PushMarkup(Loc.GetString("cloning-pod-biomass", ("number", storage.GetMaterialAmount("Biomass"))));
args.PushMarkup(Loc.GetString("cloning-pod-biomass", ("number", _material.GetMaterialAmount(uid, "Biomass"))));
}
public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Mind.Mind mind, CloningPodComponent? clonePod)
@@ -170,9 +168,6 @@ namespace Content.Server.Cloning.Systems
if (mind.UserId == null || !_playerManager.TryGetSessionById(mind.UserId.Value, out var client))
return false; // If we can't track down the client, we can't offer transfer. That'd be quite bad.
if (!TryComp<MaterialStorageComponent>(clonePod.Owner, out var podStorage))
return false;
if (!TryComp<HumanoidAppearanceComponent>(bodyToClone, out var humanoid))
return false; // whatever body was to be cloned, was not a humanoid
@@ -188,7 +183,7 @@ namespace Content.Server.Cloning.Systems
cloningCost = (int) Math.Round(cloningCost * EasyModeCloningCost);
// biomass checks
var biomassAmount = podStorage.GetMaterialAmount("Biomass");
var biomassAmount = _material.GetMaterialAmount(uid, "Biomass");
if (biomassAmount < cloningCost)
{
@@ -197,7 +192,7 @@ namespace Content.Server.Cloning.Systems
return false;
}
podStorage.RemoveMaterial("Biomass", cloningCost);
_material.TryChangeMaterialAmount(uid, "Biomass", -cloningCost);
clonePod.UsedBiomass = cloningCost;
// end of biomass checks