Чертежи
This commit is contained in:
@@ -160,10 +160,10 @@ namespace Content.Server.Lathe
|
|||||||
{
|
{
|
||||||
var ev = new LatheGetRecipesEvent(uid, getUnavailable)
|
var ev = new LatheGetRecipesEvent(uid, getUnavailable)
|
||||||
{
|
{
|
||||||
Recipes = new List<ProtoId<LatheRecipePrototype>>(component.StaticRecipes)
|
Recipes = new HashSet<ProtoId<LatheRecipePrototype>>(component.StaticRecipes) // WD Ahead of wizden
|
||||||
};
|
};
|
||||||
RaiseLocalEvent(uid, ev);
|
RaiseLocalEvent(uid, ev);
|
||||||
return ev.Recipes;
|
return ev.Recipes.ToList(); // WD Ahead of wizden
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ProtoId<LatheRecipePrototype>> GetAllBaseRecipes(LatheComponent component)
|
public static List<ProtoId<LatheRecipePrototype>> GetAllBaseRecipes(LatheComponent component)
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace Content.Shared.Lathe
|
|||||||
|
|
||||||
public bool getUnavailable;
|
public bool getUnavailable;
|
||||||
|
|
||||||
public List<ProtoId<LatheRecipePrototype>> Recipes = new();
|
public HashSet<ProtoId<LatheRecipePrototype>> Recipes = new(); // WD Ahead of wizden
|
||||||
|
|
||||||
public LatheGetRecipesEvent(EntityUid lathe, bool forced)
|
public LatheGetRecipesEvent(EntityUid lathe, bool forced)
|
||||||
{
|
{
|
||||||
|
|||||||
19
Content.Shared/Research/Components/BlueprintComponent.cs
Normal file
19
Content.Shared/Research/Components/BlueprintComponent.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using Content.Shared.Research.Prototypes;
|
||||||
|
using Content.Shared.Research.Systems;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
|
namespace Content.Shared.Research.Components;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is used for an item that is inserted directly into a given lathe to provide it with a recipe.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, NetworkedComponent, Access(typeof(BlueprintSystem))]
|
||||||
|
public sealed partial class BlueprintComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The recipes that this blueprint provides.
|
||||||
|
/// </summary>
|
||||||
|
[DataField(required: true)]
|
||||||
|
public HashSet<ProtoId<LatheRecipePrototype>> ProvidedRecipes = new();
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using Content.Shared.Research.Systems;
|
||||||
|
using Content.Shared.Whitelist;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
|
namespace Content.Shared.Research.Components;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is used for a lathe that can utilize <see cref="BlueprintComponent"/>s to gain more recipes.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, NetworkedComponent, Access(typeof(BlueprintSystem))]
|
||||||
|
public sealed partial class BlueprintReceiverComponent : Component
|
||||||
|
{
|
||||||
|
[DataField]
|
||||||
|
public string ContainerId = "blueprint";
|
||||||
|
|
||||||
|
[DataField(required: true)]
|
||||||
|
public EntityWhitelist Whitelist = new();
|
||||||
|
}
|
||||||
114
Content.Shared/Research/Systems/BlueprintSystem.cs
Normal file
114
Content.Shared/Research/Systems/BlueprintSystem.cs
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
using Content.Shared.IdentityManagement;
|
||||||
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Lathe;
|
||||||
|
using Content.Shared.Popups;
|
||||||
|
using Content.Shared.Research.Components;
|
||||||
|
using Content.Shared.Research.Prototypes;
|
||||||
|
using Content.Shared.Whitelist;
|
||||||
|
using Robust.Shared.Containers;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
|
namespace Content.Shared.Research.Systems;
|
||||||
|
|
||||||
|
public sealed class BlueprintSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||||
|
[Dependency] private readonly EntityWhitelistSystem _entityWhitelist = default!;
|
||||||
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
SubscribeLocalEvent<BlueprintReceiverComponent, ComponentStartup>(OnStartup);
|
||||||
|
SubscribeLocalEvent<BlueprintReceiverComponent, AfterInteractUsingEvent>(OnAfterInteract);
|
||||||
|
SubscribeLocalEvent<BlueprintReceiverComponent, LatheGetRecipesEvent>(OnGetRecipes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnStartup(Entity<BlueprintReceiverComponent> ent, ref ComponentStartup args)
|
||||||
|
{
|
||||||
|
_container.EnsureContainer<Container>(ent, ent.Comp.ContainerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAfterInteract(Entity<BlueprintReceiverComponent> ent, ref AfterInteractUsingEvent args)
|
||||||
|
{
|
||||||
|
if (args.Handled || !args.CanReach || !TryComp<BlueprintComponent>(args.Used, out var blueprintComponent))
|
||||||
|
return;
|
||||||
|
args.Handled = TryInsertBlueprint(ent, (args.Used, blueprintComponent), args.User);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGetRecipes(Entity<BlueprintReceiverComponent> ent, ref LatheGetRecipesEvent args)
|
||||||
|
{
|
||||||
|
var recipes = GetBlueprintRecipes(ent);
|
||||||
|
foreach (var recipe in recipes)
|
||||||
|
{
|
||||||
|
args.Recipes.Add(recipe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryInsertBlueprint(Entity<BlueprintReceiverComponent> ent, Entity<BlueprintComponent> blueprint, EntityUid? user)
|
||||||
|
{
|
||||||
|
if (!CanInsertBlueprint(ent, blueprint, user))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (user is not null)
|
||||||
|
{
|
||||||
|
var userId = Identity.Entity(user.Value, EntityManager);
|
||||||
|
var bpId = Identity.Entity(blueprint, EntityManager);
|
||||||
|
var machineId = Identity.Entity(ent, EntityManager);
|
||||||
|
var msg = Loc.GetString("blueprint-receiver-popup-insert",
|
||||||
|
("user", userId),
|
||||||
|
("blueprint", bpId),
|
||||||
|
("receiver", machineId));
|
||||||
|
_popup.PopupPredicted(msg, ent, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
_container.Insert(blueprint.Owner, _container.GetContainer(ent, ent.Comp.ContainerId));
|
||||||
|
|
||||||
|
var ev = new TechnologyDatabaseModifiedEvent();
|
||||||
|
RaiseLocalEvent(ent, ref ev);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanInsertBlueprint(Entity<BlueprintReceiverComponent> ent, Entity<BlueprintComponent> blueprint, EntityUid? user)
|
||||||
|
{
|
||||||
|
if (_entityWhitelist.IsWhitelistFail(ent.Comp.Whitelist, blueprint))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blueprint.Comp.ProvidedRecipes.Count == 0)
|
||||||
|
{
|
||||||
|
Log.Error($"Attempted to insert blueprint {ToPrettyString(blueprint)} with no recipes.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't add new blueprints if there are no new recipes.
|
||||||
|
var currentRecipes = GetBlueprintRecipes(ent);
|
||||||
|
if (currentRecipes.Count != 0 && currentRecipes.IsSupersetOf(blueprint.Comp.ProvidedRecipes))
|
||||||
|
{
|
||||||
|
_popup.PopupPredicted(Loc.GetString("blueprint-receiver-popup-recipe-exists"), ent, user);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _container.CanInsert(blueprint, _container.GetContainer(ent, ent.Comp.ContainerId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashSet<ProtoId<LatheRecipePrototype>> GetBlueprintRecipes(Entity<BlueprintReceiverComponent> ent)
|
||||||
|
{
|
||||||
|
var contained = _container.GetContainer(ent, ent.Comp.ContainerId);
|
||||||
|
|
||||||
|
var recipes = new HashSet<ProtoId<LatheRecipePrototype>>();
|
||||||
|
foreach (var blueprint in contained.ContainedEntities)
|
||||||
|
{
|
||||||
|
if (!TryComp<BlueprintComponent>(blueprint, out var blueprintComponent))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (var provided in blueprintComponent.ProvidedRecipes)
|
||||||
|
{
|
||||||
|
recipes.Add(provided);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return recipes;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -81,4 +81,17 @@ public sealed class EntityWhitelistSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WD Ahead of wizden.
|
||||||
|
/// Helper function to determine if Whitelist is not null and entity is not on the list
|
||||||
|
/// </summary>
|
||||||
|
public bool IsWhitelistFail(EntityWhitelist? whitelist, EntityUid uid)
|
||||||
|
{
|
||||||
|
if (whitelist == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return !IsValid(whitelist, uid);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
2
Resources/Locale/ru-RU/research/components/blueprint.ftl
Normal file
2
Resources/Locale/ru-RU/research/components/blueprint.ftl
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
blueprint-receiver-popup-insert = { CAPITALIZE($user) } помещает { $blueprint } в { $receiver }.
|
||||||
|
blueprint-receiver-popup-recipe-exists = Такой чертёж уже был добавлен!
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
ent-BaseBlueprint = чертёж
|
||||||
|
.desc = Чертёж какого-то устройства. Его можно поместить в автолат.
|
||||||
|
ent-BlueprintFulton = чертёж фултона
|
||||||
|
.desc = Чертёж со схемой фултона. Его можно поместить в автолат.
|
||||||
|
ent-BlueprintSeismicCharge = чертёж сейсмического заряда
|
||||||
|
.desc = Чертеж со схемой сейсмического заряда. Его можно поместить в автолат.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
ent-Autolathe = автолат
|
ent-Autolathe = автолат
|
||||||
.desc = Он производит изделия из металла и стекла.
|
.desc = Производит базовые изделия из металла и стекла. Имеет возможность обрабатывать чертежи для печати по новым рецептам.
|
||||||
ent-Protolathe = протолат
|
ent-Protolathe = протолат
|
||||||
.desc = Преобразует сырье в полезные предметы.
|
.desc = Преобразует сырье в полезные предметы.
|
||||||
ent-CircuitImprinter = принтер схем
|
ent-CircuitImprinter = принтер схем
|
||||||
|
|||||||
39
Resources/Prototypes/Entities/Objects/Tools/blueprint.yml
Normal file
39
Resources/Prototypes/Entities/Objects/Tools/blueprint.yml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
- type: entity
|
||||||
|
parent: BaseItem
|
||||||
|
id: BaseBlueprint
|
||||||
|
name: blueprint
|
||||||
|
description: A blueprint for some machine. It can be inserted into an autolathe.
|
||||||
|
abstract: true
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Objects/Tools/blueprint.rsi
|
||||||
|
state: icon
|
||||||
|
- type: Item
|
||||||
|
sprite: Objects/Tools/blueprint.rsi
|
||||||
|
size: Normal
|
||||||
|
- type: Blueprint
|
||||||
|
- type: StaticPrice
|
||||||
|
price: 1000
|
||||||
|
- type: Tag
|
||||||
|
tags:
|
||||||
|
- BlueprintAutolathe
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: BaseBlueprint
|
||||||
|
id: BlueprintFulton
|
||||||
|
name: fulton blueprint
|
||||||
|
description: A blueprint with a schematic of a fulton. It can be inserted into an autolathe.
|
||||||
|
components:
|
||||||
|
- type: Blueprint
|
||||||
|
providedRecipes:
|
||||||
|
- Fulton
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: BaseBlueprint
|
||||||
|
id: BlueprintSeismicCharge
|
||||||
|
name: seismic charge blueprint
|
||||||
|
description: A blueprint with a schematic of a seismic charge. It can be inserted into an autolathe.
|
||||||
|
components:
|
||||||
|
- type: Blueprint
|
||||||
|
providedRecipes:
|
||||||
|
- SeismicCharge
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
id: Autolathe
|
id: Autolathe
|
||||||
parent: BaseLatheLube
|
parent: BaseLatheLube
|
||||||
name: autolathe
|
name: autolathe
|
||||||
description: It produces basic items using metal and glass.
|
description: It produces basic items using metal and glass. Has the ability to process blueprints to print new recipes.
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Structures/Machines/autolathe.rsi
|
sprite: Structures/Machines/autolathe.rsi
|
||||||
@@ -276,6 +276,18 @@
|
|||||||
- HolographicSightModule
|
- HolographicSightModule
|
||||||
- TelescopicSightModule
|
- TelescopicSightModule
|
||||||
- type: BluespaceStorage
|
- type: BluespaceStorage
|
||||||
|
- type: BlueprintReceiver
|
||||||
|
whitelist:
|
||||||
|
tags:
|
||||||
|
- BlueprintAutolathe
|
||||||
|
- type: ContainerContainer
|
||||||
|
containers:
|
||||||
|
machine_board: !type:Container
|
||||||
|
machine_parts: !type:Container
|
||||||
|
blueprint: !type:Container
|
||||||
|
- type: EmptyOnMachineDeconstruct
|
||||||
|
containers:
|
||||||
|
- blueprint
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: AutolatheHyperConvection
|
id: AutolatheHyperConvection
|
||||||
|
|||||||
@@ -50,6 +50,8 @@
|
|||||||
SpaceCash500: 1.0
|
SpaceCash500: 1.0
|
||||||
SpaceCash1000: 0.75
|
SpaceCash1000: 0.75
|
||||||
SpaceCash2500: 0.5
|
SpaceCash2500: 0.5
|
||||||
|
# blueprints WD
|
||||||
|
BlueprintFulton: 1.0
|
||||||
|
|
||||||
- type: weightedRandomEntity
|
- type: weightedRandomEntity
|
||||||
id: SalvageRewardEpic
|
id: SalvageRewardEpic
|
||||||
@@ -74,3 +76,5 @@
|
|||||||
SpaceCash2500: 1.0
|
SpaceCash2500: 1.0
|
||||||
SpaceCash5000: 0.75
|
SpaceCash5000: 0.75
|
||||||
SpaceCash10000: 0.5
|
SpaceCash10000: 0.5
|
||||||
|
# blueprints WD
|
||||||
|
BlueprintSeismicCharge: 1.0
|
||||||
|
|||||||
@@ -1,16 +1,28 @@
|
|||||||
- type: latheRecipe
|
- type: latheRecipe
|
||||||
id: Fulton
|
id: Fulton
|
||||||
result: Fulton1
|
result: Fulton1
|
||||||
|
category: Tools
|
||||||
completetime: 1
|
completetime: 1
|
||||||
materials:
|
materials:
|
||||||
Steel: 200
|
Steel: 200
|
||||||
Cloth: 100
|
Cloth: 500
|
||||||
|
|
||||||
- type: latheRecipe
|
- type: latheRecipe
|
||||||
id: FultonBeacon
|
id: FultonBeacon
|
||||||
result: FultonBeacon
|
result: FultonBeacon
|
||||||
|
category: Tools
|
||||||
completetime: 5
|
completetime: 5
|
||||||
materials:
|
materials:
|
||||||
Steel: 1000
|
Steel: 1000
|
||||||
Glass: 500
|
Glass: 500
|
||||||
# If they get spammed make it cost silver.
|
# If they get spammed make it cost silver.
|
||||||
|
|
||||||
|
- type: latheRecipe
|
||||||
|
id: SeismicCharge
|
||||||
|
result: SeismicCharge
|
||||||
|
category: Tools
|
||||||
|
completetime: 5 # WD Edit from 1 to 5
|
||||||
|
materials:
|
||||||
|
Plastic: 1500
|
||||||
|
Steel: 100
|
||||||
|
Silver: 100
|
||||||
|
|||||||
@@ -63,6 +63,9 @@
|
|||||||
- type: Tag
|
- type: Tag
|
||||||
id: Bloodpack
|
id: Bloodpack
|
||||||
|
|
||||||
|
- type: Tag
|
||||||
|
id: BlueprintAutolathe
|
||||||
|
|
||||||
- type: Tag
|
- type: Tag
|
||||||
id: BodyBag
|
id: BodyBag
|
||||||
|
|
||||||
|
|||||||
BIN
Resources/Textures/Objects/Tools/blueprint.rsi/icon.png
Normal file
BIN
Resources/Textures/Objects/Tools/blueprint.rsi/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 449 B |
BIN
Resources/Textures/Objects/Tools/blueprint.rsi/inhand-left.png
Normal file
BIN
Resources/Textures/Objects/Tools/blueprint.rsi/inhand-left.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 341 B |
BIN
Resources/Textures/Objects/Tools/blueprint.rsi/inhand-right.png
Normal file
BIN
Resources/Textures/Objects/Tools/blueprint.rsi/inhand-right.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 358 B |
22
Resources/Textures/Objects/Tools/blueprint.rsi/meta.json
Normal file
22
Resources/Textures/Objects/Tools/blueprint.rsi/meta.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"license": "CC-BY-SA-3.0",
|
||||||
|
"copyright": "Taken from https://github.com/vgstation-coders/vgstation13/commit/dd749c36c416a6960782732cecf25e5ebac326e8",
|
||||||
|
"size": {
|
||||||
|
"x": 32,
|
||||||
|
"y": 32
|
||||||
|
},
|
||||||
|
"states": [
|
||||||
|
{
|
||||||
|
"name": "inhand-left",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-right",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "icon"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user