Material cleanup (#4025)

* work

* more work
This commit is contained in:
Vera Aguilera Puerto
2021-05-20 10:37:34 +02:00
committed by GitHub
parent afc8c9163c
commit 3a27490c59
17 changed files with 267 additions and 318 deletions

View File

@@ -3,10 +3,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Materials;
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using Content.Server.GameObjects.Components.Stack;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Materials;
using Content.Shared.GameObjects.Components.Power;
using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Interfaces.GameObjects.Components;
@@ -160,37 +160,37 @@ namespace Content.Server.GameObjects.Components.Research
var totalAmount = 0;
// Check if it can insert all materials.
foreach (var (_, mat) in material.MaterialTypes)
foreach (var mat in material.MaterialIds)
{
// TODO: Change how MaterialComponent works so this is not hard-coded.
if (!storage.CanInsertMaterial(mat.ID, VolumePerSheet * multiplier)) return false;
if (!storage.CanInsertMaterial(mat, VolumePerSheet * multiplier)) return false;
totalAmount += VolumePerSheet * multiplier;
}
// Check if it can take ALL of the material's volume.
if (storage.CanTakeAmount(totalAmount)) return false;
foreach (var (_, mat) in material.MaterialTypes)
foreach (var mat in material.MaterialIds)
{
storage.InsertMaterial(mat.ID, VolumePerSheet * multiplier);
storage.InsertMaterial(mat, VolumePerSheet * multiplier);
}
State = LatheState.Inserting;
switch (material.MaterialTypes.First().Value.Name)
switch (material.Materials.FirstOrDefault()?.ID)
{
case "steel":
case "Steel":
SetAppearance(LatheVisualState.InsertingMetal);
break;
case "glass":
case "Glass":
SetAppearance(LatheVisualState.InsertingGlass);
break;
case "gold":
case "Gold":
SetAppearance(LatheVisualState.InsertingGold);
break;
case "plastic":
case "Plastic":
SetAppearance(LatheVisualState.InsertingPlastic);
break;
case "plasma":
case "Plasma":
SetAppearance(LatheVisualState.InsertingPlasma);
break;
}