-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
In my game entities can have slots in which you place objects.
For example you can place crates in a crate cabinet, this is done through a slotcomponent.
If I create the occupant (crate) before I query retrieve the slot component all is well, no problems:
Entity crateCabinet = GameEntityBuilder.Create(cm, "objects/CrateCabinet/diffuse", new(5.667f, 0.0f, 0), new(128, 162))
.Build(
GameEntityBuilder.PhysicsBuilder(GameEntityBuilder.CreateRectangle(1.2f, 0.7f, 0.3f, 0.1f)),
GameEntityBuilder.MapComponentBuilder("objects/CrateCabinet/normal", "objects/CrateCabinet/height")
);
Entity slotEntity0 = Globals.FrentWorld.Create(new SlotComponent(crateCabinet, new Vector3(-0.05f, 0.0f, 0.0f)));
Entity slotEntity1 = Globals.FrentWorld.Create(new SlotComponent(crateCabinet, new Vector3(0.30f, 0.0f, 0.0f)));
Entity slotEntity2 = Globals.FrentWorld.Create(new SlotComponent(crateCabinet, new Vector3(-0.05f, 0.0f, 0.4f)));
Entity slotEntity3 = Globals.FrentWorld.Create(new SlotComponent(crateCabinet, new Vector3(0.30f, 0.0f, 0.4f)));
//Create crate first, then GetSlot works.
Entity crateEntity = CrateCreator.CreateCrate(cm);
ref SlotComponent slot = ref slotEntity0.Get<SlotComponent>();
slot.Insert(slotEntity0, crateEntity);However if I first grab the SlotComponent and then create the crate, the slot.insert parameters are still correct, slotEntity0 has a value and crateEntity has a value. But the data is lost, resulting a value of null on the SlotComponent.
Entity crateCabinet = GameEntityBuilder.Create(cm, "objects/CrateCabinet/diffuse", new(5.667f, 0.0f, 0), new(128, 162))
.Build(
GameEntityBuilder.PhysicsBuilder(GameEntityBuilder.CreateRectangle(1.2f, 0.7f, 0.3f, 0.1f)),
GameEntityBuilder.MapComponentBuilder("objects/CrateCabinet/normal", "objects/CrateCabinet/height")
);
Entity slotEntity0 = Globals.FrentWorld.Create(new SlotComponent(crateCabinet, new Vector3(-0.05f, 0.0f, 0.0f)));
Entity slotEntity1 = Globals.FrentWorld.Create(new SlotComponent(crateCabinet, new Vector3(0.30f, 0.0f, 0.0f)));
Entity slotEntity2 = Globals.FrentWorld.Create(new SlotComponent(crateCabinet, new Vector3(-0.05f, 0.0f, 0.4f)));
Entity slotEntity3 = Globals.FrentWorld.Create(new SlotComponent(crateCabinet, new Vector3(0.30f, 0.0f, 0.4f)));
//Get slot first, then create the crate does not work
ref SlotComponent slot = ref slotEntity0.Get<SlotComponent>();
Entity crateEntity = CrateCreator.CreateCrate(cm);
slot.Insert(slotEntity0, crateEntity);Why is this dependant on the order of Create Entity and Get Component?
Is this due to a lack of my understanding, or is potentially a bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation