Biomass (#10313)
* Material * good prototype * Fix material storage * You can insert biomass into the cloner * ok, basic biomass subtraction works * amogus * ok chance works * Alright, the biomass and genetic stuff works * feedback for cloning * more reclaimer polish * ship it * starting biomass + fix lathes * I changed my mind on rat mass and these guys are definitely getting ground up * Doafter * clean up, sync the two * fix naming, fix mass * technology + construction * additional logging, stop unanchoring when active * fix event / logs * dont gib dead salvage * auto eject * fix deconstruction behavior * make warning message better, temporarily disable cancer scanner * fix biomass stacks * add easy mode CVAR * stack cleanup, make biomass 2x as fast * bugfix * new sprite from hyenh * fix tests * hello? :smilethink: * :smilethink: * medical scanner gets antirotting * fix cloner and medical scanner Co-authored-by: Moony <moonheart08@users.noreply.github.com>
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
using Content.Shared.Lathe;
|
||||
using Content.Shared.Research.Prototypes;
|
||||
using Robust.Server.GameObjects;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
using Content.Shared.Materials;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Lathe.Components
|
||||
@@ -12,20 +9,6 @@ namespace Content.Server.Lathe.Components
|
||||
[RegisterComponent]
|
||||
public sealed class LatheComponent : SharedLatheComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Whitelist for specifying the kind of materials that can be insert into the lathe
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("whitelist")]
|
||||
public EntityWhitelist? LatheWhitelist;
|
||||
|
||||
/// <summary>
|
||||
/// Whitelist generated on runtime for what items are specifically used for the lathe's recipes.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("materialWhiteList", customTypeSerializer: typeof(PrototypeIdListSerializer<MaterialPrototype>))]
|
||||
public List<string> MaterialWhiteList = new();
|
||||
|
||||
/// <summary>
|
||||
/// The lathe's construction queue
|
||||
/// </summary>
|
||||
@@ -49,12 +32,6 @@ namespace Content.Server.Lathe.Components
|
||||
/// </summary>
|
||||
[DataField("producingSound")]
|
||||
public SoundSpecifier? ProducingSound;
|
||||
|
||||
/// <summary>
|
||||
/// The sound that plays when inserting an item into the lathe, if any
|
||||
/// </summary>
|
||||
[DataField("insertingSound")]
|
||||
public SoundSpecifier? InsertingSound;
|
||||
|
||||
/// <summmary>
|
||||
/// The lathe's UI.
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
using Content.Shared.Lathe;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
using Content.Shared.Materials;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Lathe.Components
|
||||
{
|
||||
@@ -17,6 +21,26 @@ namespace Content.Server.Lathe.Components
|
||||
[DataField("StorageLimit")]
|
||||
private int _storageLimit = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Whitelist for specifying the kind of items that can be insert into this entity.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("whitelist")]
|
||||
public EntityWhitelist? EntityWhitelist;
|
||||
|
||||
/// <summary>
|
||||
/// Whitelist generated on runtime for what specific materials can be inserted into this entity.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("materialWhiteList", customTypeSerializer: typeof(PrototypeIdListSerializer<MaterialPrototype>))]
|
||||
public List<string> MaterialWhiteList = new();
|
||||
|
||||
/// <summary>
|
||||
/// The sound that plays when inserting an item into the storage
|
||||
/// </summary>
|
||||
[DataField("insertingSound")]
|
||||
public SoundSpecifier? InsertingSound;
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new MaterialStorageState(Storage);
|
||||
@@ -73,5 +97,14 @@ namespace Content.Server.Lathe.Components
|
||||
{
|
||||
return InsertMaterial(id, -amount);
|
||||
}
|
||||
|
||||
// forgive me I needed to write a crumb of e/c code to not go fucking insane i swear i will ecs this entire shitty fucking system one day
|
||||
public int GetMaterialAmount(string id)
|
||||
{
|
||||
if (!Storage.TryGetValue(id, out var amount))
|
||||
return 0;
|
||||
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Content.Server.Lathe
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<LatheComponent, InteractUsingEvent>(OnInteractUsing);
|
||||
SubscribeLocalEvent<MaterialStorageComponent, InteractUsingEvent>(OnInteractUsing);
|
||||
SubscribeLocalEvent<LatheComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<LatheComponent, LatheQueueRecipeMessage>(OnLatheQueueRecipeMessage);
|
||||
SubscribeLocalEvent<LatheComponent, LatheSyncRequestMessage>(OnLatheSyncRequestMessage);
|
||||
@@ -85,35 +85,34 @@ namespace Content.Server.Lathe
|
||||
if (recipes == null)
|
||||
return;
|
||||
|
||||
if (!TryComp<MaterialStorageComponent>(uid, out var storage))
|
||||
return;
|
||||
|
||||
foreach (var recipe in recipes)
|
||||
{
|
||||
foreach (var mat in recipe.RequiredMaterials)
|
||||
{
|
||||
if (!component.MaterialWhiteList.Contains(mat.Key))
|
||||
component.MaterialWhiteList.Add(mat.Key);
|
||||
if (!storage.MaterialWhiteList.Contains(mat.Key))
|
||||
storage.MaterialWhiteList.Add(mat.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When someone tries to use an item on the lathe,
|
||||
/// insert it if it's a stack and fits inside
|
||||
/// </summary>
|
||||
private void OnInteractUsing(EntityUid uid, LatheComponent component, InteractUsingEvent args)
|
||||
private void OnInteractUsing(EntityUid uid, MaterialStorageComponent component, InteractUsingEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
if (!TryComp<MaterialStorageComponent>(uid, out var storage)
|
||||
|| !TryComp<MaterialComponent>(args.Used, out var material)
|
||||
|| component.LatheWhitelist?.IsValid(args.Used) == false)
|
||||
|| storage.EntityWhitelist?.IsValid(args.Used) == false)
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
|
||||
var matUsed = false;
|
||||
foreach (var mat in material.Materials)
|
||||
if (component.MaterialWhiteList.Contains(mat.ID))
|
||||
if (storage.MaterialWhiteList.Contains(mat.ID))
|
||||
matUsed = true;
|
||||
|
||||
if (!matUsed)
|
||||
@@ -148,16 +147,25 @@ namespace Content.Server.Lathe
|
||||
lastMat = mat;
|
||||
}
|
||||
|
||||
EntityManager.QueueDeleteEntity(args.Used);
|
||||
|
||||
// Play a sound when inserting, if any
|
||||
if (component.InsertingSound != null)
|
||||
_audioSys.PlayPvs(component.InsertingSound, uid);
|
||||
|
||||
_popupSystem.PopupEntity(Loc.GetString("machine-insert-item", ("machine", uid),
|
||||
("item", args.Used)), uid, Filter.Entities(args.User));
|
||||
|
||||
// TODO: You can probably split this part off of lathe component too
|
||||
if (!TryComp<LatheComponent>(uid, out var lathe))
|
||||
return;
|
||||
|
||||
// We need the prototype to get the color
|
||||
_prototypeManager.TryIndex(lastMat, out MaterialPrototype? matProto);
|
||||
|
||||
EntityManager.QueueDeleteEntity(args.Used);
|
||||
|
||||
EnsureComp<LatheInsertingComponent>(uid).TimeRemaining = component.InsertionTime;
|
||||
EnsureComp<LatheInsertingComponent>(uid).TimeRemaining = lathe.InsertionTime;
|
||||
|
||||
_popupSystem.PopupEntity(Loc.GetString("machine-insert-item", ("machine", uid),
|
||||
("item", args.Used)), uid, Filter.Entities(args.User));
|
||||
|
||||
Reference in New Issue
Block a user