Page MenuHomeFeedback Tracker

InventoryStorageManagerComponent::TrySpawnPrefabToStorage creates the object twice
Assigned, NormalPublic

Description

I am not sure if intended, but when using InventoryStorageManagerComponent::TrySpawnPrefabToStorage the prefab you want to spawn is created twice, and the first prefab is deleted before the function returns. Maybe the first one is created so it can perform the can check before spawning the actual instance, however, this looks rather wasteful to me. It should spawn only one, check, and if not working delete or else keep the instance. Or maybe this is unrelated and just a general bug.

SCRIPT : TrySpawnPrefabToStorage before
SCRIPT : OnPostInit - this:BugPrintComponent<0x000001DF0508F5D0> - owner:GenericEntity<0x000001DF12FD5230>
SCRIPT : OnDelete - this:BugPrintComponent<0x000001DF0508F5D0> - owner:GenericEntity<0x000001DF12FD5230>
SCRIPT : OnPostInit - this:BugPrintComponent<0x000001DF0508F6A0> - owner:GenericEntity<0x000001DF12FD5330>
SCRIPT : TrySpawnPrefabToStorage result: true
SCRIPT : TrySpawnPrefabToStorage after

s. steps to reproduce for full code

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce
  1. Create this component
class BugPrintComponentClass : ScriptComponentClass
{
}

class BugPrintComponent : ScriptComponent
{
	override event void OnPostInit(IEntity owner)
	{
		PrintFormat("OnPostInit - this:%1 - owner:%2", this, owner);
	}
	
	override event void OnDelete(IEntity owner)
    {
		PrintFormat("OnDelete - this:%1 - owner:%2", this, owner);
    }
}
  1. Add that component to AspirinBottle.
  1. Run this action code or put it somewhere else, as long as TrySpawnPrefabToStorage is executed you see the problem.
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
{
	SCR_InventoryStorageManagerComponent inventoryManager = SCR_InventoryStorageManagerComponent.Cast(pUserEntity.FindComponent(SCR_InventoryStorageManagerComponent));
	
	Print("TrySpawnPrefabToStorage before");
	Print("TrySpawnPrefabToStorage result: " + inventoryManager.TrySpawnPrefabToStorage("{C98FCC6CA6C56069}Prefabs/Items/Medicine/AspirinBottle.et"));
	Print("TrySpawnPrefabToStorage after");
}

Event Timeline

Arkensor created this task.Aug 6 2022, 5:58 PM
Arkensor edited Steps To Reproduce. (Show Details)
Geez changed the task status from New to Assigned.Aug 8 2022, 10:57 PM