Refactor workbench resource handling with provider component (#1522)
* Refactor workbench resource handling with provider component Introduces CP14WorkbenchPlaceableProviderComponent and related event to abstract resource provision for workbenches. Updates system logic to use the new provider event instead of directly accessing ItemPlacerComponent, improving modularity and extensibility. Adjusts entity prototype to include the new provider component. * map resave * resave Frigid
This commit is contained in:
@@ -33,6 +33,7 @@ public sealed partial class CP14WorkbenchSystem : CP14SharedWorkbenchSystem
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
InitProviders();
|
||||
|
||||
SubscribeLocalEvent<CP14WorkbenchComponent, MapInitEvent>(OnMapInit);
|
||||
|
||||
@@ -82,11 +83,12 @@ public sealed partial class CP14WorkbenchSystem : CP14SharedWorkbenchSystem
|
||||
if (!_proto.TryIndex(args.Recipe, out var recipe))
|
||||
return;
|
||||
|
||||
var placedEntities = _lookup.GetEntitiesInRange(Transform(ent).Coordinates,
|
||||
ent.Comp.WorkbenchRadius,
|
||||
LookupFlags.Uncontained);
|
||||
var getResource = new CP14WorkbenchGetResourcesEvent();
|
||||
RaiseLocalEvent(ent.Owner, getResource);
|
||||
|
||||
if (!CanCraftRecipe(recipe, placedEntities, args.User))
|
||||
var resources = getResource.Resources;
|
||||
|
||||
if (!CanCraftRecipe(recipe, resources, args.User))
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("cp14-workbench-cant-craft"), ent, args.User);
|
||||
return;
|
||||
@@ -106,7 +108,7 @@ public sealed partial class CP14WorkbenchSystem : CP14SharedWorkbenchSystem
|
||||
|
||||
foreach (var req in recipe.Requirements)
|
||||
{
|
||||
req.PostCraft(EntityManager, _proto, placedEntities);
|
||||
req.PostCraft(EntityManager, _proto, resources);
|
||||
}
|
||||
|
||||
if (passConditions)
|
||||
|
||||
Reference in New Issue
Block a user