fix emagged lathes (#23318)
* implement * pass uid * fix * fix dementia * event implementation * fix
This commit is contained in:
@@ -107,7 +107,7 @@ namespace Content.Server.Lathe
|
|||||||
if (args.Storage != uid)
|
if (args.Storage != uid)
|
||||||
return;
|
return;
|
||||||
var materialWhitelist = new List<ProtoId<MaterialPrototype>>();
|
var materialWhitelist = new List<ProtoId<MaterialPrototype>>();
|
||||||
var recipes = GetAllBaseRecipes(component);
|
var recipes = GetAvailableRecipes(uid, component, true);
|
||||||
foreach (var id in recipes)
|
foreach (var id in recipes)
|
||||||
{
|
{
|
||||||
if (!_proto.TryIndex(id, out var proto))
|
if (!_proto.TryIndex(id, out var proto))
|
||||||
@@ -126,18 +126,18 @@ namespace Content.Server.Lathe
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public bool TryGetAvailableRecipes(EntityUid uid, [NotNullWhen(true)] out List<ProtoId<LatheRecipePrototype>>? recipes, [NotNullWhen(true)] LatheComponent? component = null)
|
public bool TryGetAvailableRecipes(EntityUid uid, [NotNullWhen(true)] out List<ProtoId<LatheRecipePrototype>>? recipes, [NotNullWhen(true)] LatheComponent? component = null, bool getUnavailable = false)
|
||||||
{
|
{
|
||||||
recipes = null;
|
recipes = null;
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
return false;
|
return false;
|
||||||
recipes = GetAvailableRecipes(uid, component);
|
recipes = GetAvailableRecipes(uid, component, getUnavailable);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProtoId<LatheRecipePrototype>> GetAvailableRecipes(EntityUid uid, LatheComponent component)
|
public List<ProtoId<LatheRecipePrototype>> GetAvailableRecipes(EntityUid uid, LatheComponent component, bool getUnavailable = false)
|
||||||
{
|
{
|
||||||
var ev = new LatheGetRecipesEvent(uid)
|
var ev = new LatheGetRecipesEvent(uid, getUnavailable)
|
||||||
{
|
{
|
||||||
Recipes = new List<ProtoId<LatheRecipePrototype>>(component.StaticRecipes)
|
Recipes = new List<ProtoId<LatheRecipePrototype>>(component.StaticRecipes)
|
||||||
};
|
};
|
||||||
@@ -236,7 +236,7 @@ namespace Content.Server.Lathe
|
|||||||
|
|
||||||
foreach (var recipe in latheComponent.DynamicRecipes)
|
foreach (var recipe in latheComponent.DynamicRecipes)
|
||||||
{
|
{
|
||||||
if (!component.UnlockedRecipes.Contains(recipe) || args.Recipes.Contains(recipe))
|
if (!(args.getUnavailable || component.UnlockedRecipes.Contains(recipe)) || args.Recipes.Contains(recipe))
|
||||||
continue;
|
continue;
|
||||||
args.Recipes.Add(recipe);
|
args.Recipes.Add(recipe);
|
||||||
}
|
}
|
||||||
@@ -246,11 +246,11 @@ namespace Content.Server.Lathe
|
|||||||
{
|
{
|
||||||
if (uid != args.Lathe || !TryComp<TechnologyDatabaseComponent>(uid, out var technologyDatabase))
|
if (uid != args.Lathe || !TryComp<TechnologyDatabaseComponent>(uid, out var technologyDatabase))
|
||||||
return;
|
return;
|
||||||
if (!HasComp<EmaggedComponent>(uid))
|
if (!args.getUnavailable && !HasComp<EmaggedComponent>(uid))
|
||||||
return;
|
return;
|
||||||
foreach (var recipe in component.EmagDynamicRecipes)
|
foreach (var recipe in component.EmagDynamicRecipes)
|
||||||
{
|
{
|
||||||
if (!technologyDatabase.UnlockedRecipes.Contains(recipe) || args.Recipes.Contains(recipe))
|
if (!(args.getUnavailable || technologyDatabase.UnlockedRecipes.Contains(recipe)) || args.Recipes.Contains(recipe))
|
||||||
continue;
|
continue;
|
||||||
args.Recipes.Add(recipe);
|
args.Recipes.Add(recipe);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,23 @@
|
|||||||
using Content.Shared.Research.Prototypes;
|
using Content.Shared.Research.Prototypes;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||||
|
|
||||||
namespace Content.Shared.Lathe
|
namespace Content.Shared.Lathe
|
||||||
{
|
{
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
[AutoGenerateComponentState]
|
|
||||||
public sealed partial class EmagLatheRecipesComponent : Component
|
public sealed partial class EmagLatheRecipesComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All of the dynamic recipes that the lathe is capable to get using EMAG
|
/// All of the dynamic recipes that the lathe is capable to get using EMAG
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("emagDynamicRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer<LatheRecipePrototype>))]
|
[DataField, AutoNetworkedField]
|
||||||
[AutoNetworkedField]
|
public List<ProtoId<LatheRecipePrototype>> EmagDynamicRecipes = new();
|
||||||
public List<string> EmagDynamicRecipes = new();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All of the static recipes that the lathe is capable to get using EMAG
|
/// All of the static recipes that the lathe is capable to get using EMAG
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("emagStaticRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer<LatheRecipePrototype>))]
|
[DataField, AutoNetworkedField]
|
||||||
[AutoNetworkedField]
|
public List<ProtoId<LatheRecipePrototype>> EmagStaticRecipes = new();
|
||||||
public List<string> EmagStaticRecipes = new();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,11 +68,14 @@ namespace Content.Shared.Lathe
|
|||||||
{
|
{
|
||||||
public readonly EntityUid Lathe;
|
public readonly EntityUid Lathe;
|
||||||
|
|
||||||
|
public bool getUnavailable;
|
||||||
|
|
||||||
public List<ProtoId<LatheRecipePrototype>> Recipes = new();
|
public List<ProtoId<LatheRecipePrototype>> Recipes = new();
|
||||||
|
|
||||||
public LatheGetRecipesEvent(EntityUid lathe)
|
public LatheGetRecipesEvent(EntityUid lathe, bool forced)
|
||||||
{
|
{
|
||||||
Lathe = lathe;
|
Lathe = lathe;
|
||||||
|
getUnavailable = forced;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user