Files
tbd-station-14/Content.Client/Construction/ConstructionPlacementHijack.cs
Ertanic 81507b9d52 Localizable craftmenu (#32339)
* Now the name of the target craft items is taken directly from the prototypes

* Deleting unnecessary fields

* Deleting unnecessary fields

* Added suffix field

* Added override via localization keys

* My favorite ItemList and TextureRect have been replaced with ListContainer and EntityPrototypeView

* Fix suffix

* Fix construction ghosts... maybe

* Remove suffix from UI

* Suffixes have been removed from prototypes

* Added a description for the secret door

* Fix search..?

* The Icon field of ConstructionPrototype has been removed

* StackPrototypes used in the construction menu have been localized

* TagConstructionGraphStep used in the construction menu have been localized

* The search bar has been localized

* Fix localization and prototypes

* Recipes are now only loaded when the crafting window is opened.

* Fix crooked merge grid of the crafting menu.

* Localization update

* Fix cyborg graph

* Revert "Recipes are now only loaded when the crafting window is opened."

This reverts commit 97749483542c2d6272bda16edf49612c69a0761a.

* Fix loc

* fix merge

* Fix upstream

* Some of the logic has been moved to Shared

* fix

* Small adjustments

* Very small change

---------

Co-authored-by: EmoGarbage404 <retron404@gmail.com>
2025-05-01 10:21:16 -04:00

61 lines
2.0 KiB
C#

using System.Linq;
using Content.Shared.Construction.Prototypes;
using Robust.Client.GameObjects;
using Robust.Client.Placement;
using Robust.Client.ResourceManagement;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
namespace Content.Client.Construction
{
public sealed class ConstructionPlacementHijack : PlacementHijack
{
private readonly ConstructionSystem _constructionSystem;
private readonly ConstructionPrototype? _prototype;
public override bool CanRotate { get; }
public ConstructionPlacementHijack(ConstructionSystem constructionSystem, ConstructionPrototype? prototype)
{
_constructionSystem = constructionSystem;
_prototype = prototype;
CanRotate = prototype?.CanRotate ?? true;
}
/// <inheritdoc />
public override bool HijackPlacementRequest(EntityCoordinates coordinates)
{
if (_prototype != null)
{
var dir = Manager.Direction;
_constructionSystem.SpawnGhost(_prototype, coordinates, dir);
}
return true;
}
/// <inheritdoc />
public override bool HijackDeletion(EntityUid entity)
{
if (IoCManager.Resolve<IEntityManager>().HasComponent<ConstructionGhostComponent>(entity))
{
_constructionSystem.ClearGhost(entity.GetHashCode());
}
return true;
}
/// <inheritdoc />
public override void StartHijack(PlacementManager manager)
{
base.StartHijack(manager);
if (_prototype is null || !_constructionSystem.TryGetRecipePrototype(_prototype.ID, out var targetProtoId))
return;
if (!IoCManager.Resolve<IPrototypeManager>().TryIndex(targetProtoId, out EntityPrototype? proto))
return;
manager.CurrentTextures = SpriteComponent.GetPrototypeTextures(proto, IoCManager.Resolve<IResourceCache>()).ToList();
}
}
}