Refactor stacks to not use method events (#4177)

This commit is contained in:
Vera Aguilera Puerto
2021-06-12 11:24:34 +02:00
committed by GitHub
parent ca4e665296
commit 0093a961bc
17 changed files with 79 additions and 248 deletions

View File

@@ -44,8 +44,8 @@ namespace Content.Server.Wires.Components
var droppedEnt = Owner.EntityManager.SpawnEntity(_wireDroppedOnCutPrototype, eventArgs.ClickLocation);
// TODO: Literally just use a prototype that has a single thing in the stack, it's not that complicated...
if (droppedEnt.HasComponent<StackComponent>())
Owner.EntityManager.EventBus.RaiseLocalEvent(droppedEnt.Uid, new StackChangeCountEvent(1), false);
if (droppedEnt.TryGetComponent<StackComponent>(out var stack))
EntitySystem.Get<StackSystem>().SetCount(droppedEnt.Uid, stack, 1);
return true;
}

View File

@@ -47,14 +47,9 @@ namespace Content.Server.Wires.Components
}
}
if (Owner.HasComponent<StackComponent>())
{
var stackUse = new StackUseEvent(){Amount = 1};
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, stackUse);
if(!stackUse.Result)
return true;
}
if (Owner.TryGetComponent<StackComponent>(out var stack)
&& !EntitySystem.Get<StackSystem>().Use(Owner.Uid, stack, 1))
return true;
Owner.EntityManager.SpawnEntity(_wirePrototypeID, grid.GridTileToLocal(snapPos));
return true;