Обновление биогенератора (#1364)
This commit is contained in:
parent
70656995ef
commit
94dd41a26f
3 changed files with 100 additions and 8 deletions
|
|
@ -4,6 +4,8 @@ using Content.Server.Materials.Components;
|
|||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Storage;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Robust.Server.Audio;
|
||||
|
||||
namespace Content.Server.Materials;
|
||||
|
|
@ -28,11 +30,32 @@ public sealed class ProduceMaterialExtractorSystem : EntitySystem
|
|||
if (!this.IsPowered(ent, EntityManager))
|
||||
return;
|
||||
|
||||
if (!TryComp<ProduceComponent>(args.Used, out var produce))
|
||||
return;
|
||||
bool success = false;
|
||||
|
||||
if (!_solutionContainer.TryGetSolution(args.Used, produce.SolutionName, out var solution))
|
||||
return;
|
||||
// Handle using bags (mainly plant bags)
|
||||
if (ExtractFromStorage(ent, args.Used))
|
||||
success = true;
|
||||
|
||||
// Handle using produce directly
|
||||
if (ExtractFromProduce(ent, args.Used))
|
||||
success = true;
|
||||
|
||||
// TODO: What if a bag is also a plant?
|
||||
|
||||
if (success)
|
||||
{
|
||||
_audio.PlayPvs(ent.Comp.ExtractSound, ent);
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool ExtractFromProduce(Entity<ProduceMaterialExtractorComponent> ent, EntityUid used)
|
||||
{
|
||||
if (!TryComp<ProduceComponent>(used, out var produce))
|
||||
return false;
|
||||
|
||||
if (!_solutionContainer.TryGetSolution(used, produce.SolutionName, out var solution))
|
||||
return false;
|
||||
|
||||
// Can produce even have fractional amounts? Does it matter if they do?
|
||||
// Questions man was never meant to answer.
|
||||
|
|
@ -41,8 +64,22 @@ public sealed class ProduceMaterialExtractorSystem : EntitySystem
|
|||
.Sum(r => r.Quantity.Float());
|
||||
_materialStorage.TryChangeMaterialAmount(ent, ent.Comp.ExtractedMaterial, (int) matAmount);
|
||||
|
||||
_audio.PlayPvs(ent.Comp.ExtractSound, ent);
|
||||
QueueDel(args.Used);
|
||||
args.Handled = true;
|
||||
QueueDel(used);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ExtractFromStorage(Entity<ProduceMaterialExtractorComponent> ent, EntityUid used)
|
||||
{
|
||||
if (!TryComp<StorageComponent>(used, out var storage))
|
||||
return false;
|
||||
|
||||
bool success = false;
|
||||
|
||||
foreach (var (item, _location) in storage.StoredItems)
|
||||
if (ExtractFromProduce(ent, item))
|
||||
success = true;
|
||||
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -235,5 +235,54 @@
|
|||
category: Materials
|
||||
completetime: 3
|
||||
materials:
|
||||
Biomass: 149
|
||||
Biomass: 100
|
||||
|
||||
- type: latheRecipe
|
||||
id: BioClothingBeltPlant
|
||||
result: ClothingBeltPlant
|
||||
category: Materials
|
||||
completetime: 5
|
||||
materials:
|
||||
Biomass: 50
|
||||
|
||||
- type: latheRecipe
|
||||
id: BioClothingBeltUtility
|
||||
result: ClothingBeltUtility
|
||||
category: Materials
|
||||
completetime: 5
|
||||
materials:
|
||||
Biomass: 50
|
||||
|
||||
- type: latheRecipe
|
||||
id: BioClothingBeltMedical
|
||||
result: ClothingBeltMedical
|
||||
category: Materials
|
||||
completetime: 5
|
||||
materials:
|
||||
Biomass: 50
|
||||
|
||||
- type: latheRecipe
|
||||
id: BioClothingBeltJanitor
|
||||
result: ClothingBeltJanitor
|
||||
category: Materials
|
||||
completetime: 5
|
||||
materials:
|
||||
Biomass: 50
|
||||
|
||||
- type: latheRecipe
|
||||
id: BioClothingBeltStorageWaistbag
|
||||
result: ClothingBeltStorageWaistbag
|
||||
category: Materials
|
||||
completetime: 5
|
||||
materials:
|
||||
Biomass: 50
|
||||
|
||||
- type: latheRecipe
|
||||
id: BioClothingBeltChef
|
||||
result: ClothingBeltChef
|
||||
category: Materials
|
||||
completetime: 5
|
||||
materials:
|
||||
Biomass: 50
|
||||
|
||||
# Sunrise-End
|
||||
|
|
|
|||
|
|
@ -4,3 +4,9 @@
|
|||
id: BioGenStaticSunrise
|
||||
recipes:
|
||||
- BioGenHandheldSoil
|
||||
- BioClothingBeltPlant
|
||||
- BioClothingBeltUtility
|
||||
- BioClothingBeltMedical
|
||||
- BioClothingBeltJanitor
|
||||
- BioClothingBeltStorageWaistbag
|
||||
- BioClothingBeltChef
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue