Fix some things setting StackComponent count manually.
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||
using Content.Server.GameObjects.Components.Interactable;
|
||||
using Content.Server.GameObjects.Components.Stack;
|
||||
using Content.Shared.GameObjects.Components.Interactable;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -58,8 +59,10 @@ namespace Content.Server.GameObjects.Components.Construction
|
||||
{
|
||||
var droppedEnt = Owner.EntityManager.SpawnEntity(result, resultPosition);
|
||||
|
||||
if (droppedEnt.TryGetComponent<StackComponent>(out var stackComp))
|
||||
stackComp.Count = 1;
|
||||
// TODO: If something has a stack... Just use a prototype with a single thing in the stack.
|
||||
// This is not a good way to do it.
|
||||
if (droppedEnt.HasComponent<StackComponent>())
|
||||
Owner.EntityManager.EventBus.RaiseLocalEvent(droppedEnt.Uid, new StackChangeCountEvent(1), false);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Stack;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.Utility;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -32,8 +33,7 @@ namespace Content.Server.GameObjects.Components.Destructible.Thresholds.Behavior
|
||||
if (EntityPrototypeHelpers.HasComponent<StackComponent>(entityId))
|
||||
{
|
||||
var spawned = owner.EntityManager.SpawnEntity(entityId, owner.Transform.MapPosition);
|
||||
var stack = spawned.GetComponent<StackComponent>();
|
||||
stack.Count = count;
|
||||
owner.EntityManager.EventBus.RaiseLocalEvent(spawned.Uid, new StackChangeCountEvent(count), false);
|
||||
spawned.RandomOffset(0.5f);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
||||
using Content.Server.GameObjects.Components.Interactable;
|
||||
using Content.Server.GameObjects.Components.Stack;
|
||||
using Content.Shared.GameObjects.Components.Interactable;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -44,8 +45,9 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
Owner.Delete();
|
||||
var droppedEnt = Owner.EntityManager.SpawnEntity(_wireDroppedOnCutPrototype, eventArgs.ClickLocation);
|
||||
|
||||
if (droppedEnt.TryGetComponent<StackComponent>(out var stackComp))
|
||||
stackComp.Count = 1;
|
||||
// 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);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user