Skip to content

Commit

Permalink
Merge pull request #46 from StarCoreSE/yarding
Browse files Browse the repository at this point in the history
preload yard build fix
  • Loading branch information
InvalidArgument3 authored Nov 9, 2024
2 parents 664553e + 573dd0e commit 0dfc6ce
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions ShipyardsRevival/Data/Scripts/ShipyardMod/ProcessShipyardAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -831,31 +831,20 @@ private bool BuildTarget(BlockTarget target, ShipyardItem item, IMyCubeBlock too
{
IMyProjector projector = target.Projector;
IMySlimBlock block = target.Block;

if (projector == null || block == null)
return false;

if (projector.CanBuild(block, false) != BuildCheckResult.OK)
return false;

if (MyAPIGateway.Session.CreativeMode)
{
projector.Build(block, projector.OwnerId, projector.EntityId, false, projector.OwnerId);
return projector.CanBuild(block, true) != BuildCheckResult.OK;
}

//try to remove the first component from inventory
string name = ((MyCubeBlockDefinition)block.BlockDefinition).Components[0].Definition.Id.SubtypeName;
if (_tmpInventory.PullAny(item.ConnectedCargo, name, 1))
{
_tmpInventory.Clear();

projector.Build(block, projector.OwnerId, projector.EntityId, false, projector.OwnerId);
// Attempt to build the block, which places it into the world as a projected block
// but does not complete it unless components are supplied during welding
projector.Build(block, projector.OwnerId, projector.EntityId, false, projector.OwnerId);

return projector.CanBuild(block, true) != BuildCheckResult.OK;
}

return false;
// Return true if the block is now placed into the world
return projector.CanBuild(block, true) != BuildCheckResult.OK;
}

}
}

0 comments on commit 0dfc6ce

Please sign in to comment.