StackSystem uses the EntitySystem proxy methods. (#5699)
This commit is contained in:
committed by
GitHub
parent
8c295d340d
commit
d75b384213
@@ -47,16 +47,16 @@ namespace Content.Server.Stack
|
||||
// Get a prototype ID to spawn the new entity. Null is also valid, although it should rarely be picked...
|
||||
var prototype = _prototypeManager.TryIndex<StackPrototype>(stack.StackTypeId, out var stackType)
|
||||
? stackType.Spawn
|
||||
: EntityManager.GetComponent<MetaDataComponent>(stack.Owner).EntityPrototype?.ID;
|
||||
: Prototype(stack.Owner)?.ID;
|
||||
|
||||
// Try to remove the amount of things we want to split from the original stack...
|
||||
if (!Use(uid, amount, stack))
|
||||
return default;
|
||||
|
||||
// Set the output parameter in the event instance to the newly split stack.
|
||||
var entity = EntityManager.SpawnEntity(prototype, spawnPosition);
|
||||
var entity = Spawn(prototype, spawnPosition);
|
||||
|
||||
if (EntityManager.TryGetComponent(entity, out SharedStackComponent? stackComp))
|
||||
if (TryComp(entity, out SharedStackComponent? stackComp))
|
||||
{
|
||||
// Set the split stack's count.
|
||||
SetCount(entity, amount, stackComp);
|
||||
@@ -73,8 +73,8 @@ namespace Content.Server.Stack
|
||||
public EntityUid Spawn(int amount, StackPrototype prototype, EntityCoordinates spawnPosition)
|
||||
{
|
||||
// Set the output result parameter to the new stack entity...
|
||||
var entity = EntityManager.SpawnEntity(prototype.Spawn, spawnPosition);
|
||||
var stack = EntityManager.GetComponent<StackComponent>(entity);
|
||||
var entity = Spawn(prototype.Spawn, spawnPosition);
|
||||
var stack = Comp<StackComponent>(entity);
|
||||
|
||||
// And finally, set the correct amount!
|
||||
SetCount(entity, amount, stack);
|
||||
@@ -86,7 +86,7 @@ namespace Content.Server.Stack
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
if (!EntityManager.TryGetComponent<StackComponent?>(args.Used, out var otherStack))
|
||||
if (!TryComp<StackComponent>(args.Used, out var otherStack))
|
||||
return;
|
||||
|
||||
if (!otherStack.StackTypeId.Equals(stack.StackTypeId))
|
||||
@@ -100,7 +100,7 @@ namespace Content.Server.Stack
|
||||
|
||||
if (!popupPos.IsValid(EntityManager))
|
||||
{
|
||||
popupPos = EntityManager.GetComponent<TransformComponent>(args.User).Coordinates;
|
||||
popupPos = Transform(args.User).Coordinates;
|
||||
}
|
||||
|
||||
var filter = Filter.Entities(args.User);
|
||||
@@ -131,11 +131,13 @@ namespace Content.Server.Stack
|
||||
if (!args.CanAccess || !args.CanInteract)
|
||||
return;
|
||||
|
||||
Verb halve = new();
|
||||
halve.Text = Loc.GetString("comp-stack-split-halve");
|
||||
halve.Category = VerbCategory.Split;
|
||||
halve.Act = () => UserSplit(uid, args.User, stack.Count / 2, stack);
|
||||
halve.Priority = 1;
|
||||
Verb halve = new()
|
||||
{
|
||||
Text = Loc.GetString("comp-stack-split-halve"),
|
||||
Category = VerbCategory.Split,
|
||||
Act = () => UserSplit(uid, args.User, stack.Count / 2, stack),
|
||||
Priority = 1
|
||||
};
|
||||
args.Verbs.Add(halve);
|
||||
|
||||
var priority = 0;
|
||||
@@ -144,13 +146,15 @@ namespace Content.Server.Stack
|
||||
if (amount >= stack.Count)
|
||||
continue;
|
||||
|
||||
Verb verb = new();
|
||||
verb.Text = amount.ToString();
|
||||
verb.Category = VerbCategory.Split;
|
||||
verb.Act = () => UserSplit(uid, args.User, amount, stack);
|
||||
Verb verb = new()
|
||||
{
|
||||
Text = amount.ToString(),
|
||||
Category = VerbCategory.Split,
|
||||
Act = () => UserSplit(uid, args.User, amount, stack),
|
||||
// we want to sort by size, not alphabetically by the verb text.
|
||||
Priority = priority
|
||||
};
|
||||
|
||||
// we want to sort by size, not alphabetically by the verb text.
|
||||
verb.Priority = priority;
|
||||
priority--;
|
||||
|
||||
args.Verbs.Add(verb);
|
||||
@@ -173,22 +177,10 @@ namespace Content.Server.Stack
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityManager.TryGetComponent<HandsComponent>(userUid, out var hands))
|
||||
{
|
||||
if (hands.TryGetActiveHeldEntity(out var heldItem) && heldItem != stack.Owner)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Split(uid, amount, userTransform.Coordinates, stack) is not {Valid: true} split)
|
||||
if (Split(uid, amount, userTransform.Coordinates, stack) is not {} split)
|
||||
return;
|
||||
|
||||
if (EntityManager.TryGetComponent<ItemComponent>(split, out var item))
|
||||
if (TryComp<HandsComponent>(userUid, out var hands) && TryComp<ItemComponent>(split, out var item))
|
||||
{
|
||||
hands.PutInHandOrDrop(item);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user