Space Engineers

Space Engineers

Airtight Force Field Hangar Doors
Hannobal  [developer] 7 Feb, 2019 @ 1:39pm
Update Subpart Positions
So I finally found a way to update the positions for the subparts. Actually it's really easy by callingPositionComp.UpdateWorldMatrix(ref mat, null, true, true), but the ModAPI is really underdocumented...

Now here's the issue with the update that I'd like to do every frame but currently only works every 10th frame. The code below works fine, but if I move the content of UpdateAfterSimulation10() to UpdateAfterSimulation() and change EACH_10TH_FRAME to EACH_FRAME the function is not called. I also checked other Mods, that do exactly that (like Vicizlat's Multifloor Elevator), but I couldn't reproduce the behavior. Are there any experts, who could give me advice here?

I also tested misusing the UpdateOnceBeforeFrame() function by setting BEFORE_NEXT_FRAME again at the end of the call and using a bool to branch off the initialization. However, that's extremely hard on CPU and leads to lag, because something else seems to be called other than my override of UpdateOnceBeforeFrame.

[MyEntityComponentDescriptor(typeof(MyObjectBuilder_AirtightHangarDoor),true, "ForceFieldDoor0", "ForceFieldDoor1", "ForceFieldDoor2", "ForceFieldDoor3", "ForceFieldDoor4", "ForceFieldDoor5", "ForceFieldDoor6", "ForceFieldDoor7", "ForceFieldDoor8", "ForceFieldDoor9", "ForceFieldDoor10", "SmallForceFieldDoor0", "SmallForceFieldDoor1", "SmallForceFieldDoor2", "SmallForceFieldDoor3", "SmallForceFieldDoor4", "SmallForceFieldDoor5", "SmallForceFieldDoor6", "SmallForceFieldDoor7", "SmallForceFieldDoor8", "SmallForceFieldDoor9", "SmallForceFieldDoor10")] public class ForceField : MyGameLogicComponent { public override void Init(MyObjectBuilder_EntityBase objectBuilder) { m_objectBuilder = objectBuilder; Entity.NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME | MyEntityUpdateEnum.EACH_10TH_FRAME; } public override void UpdateOnceBeforeFrame() { // actual initialization here } public override void UpdateAfterSimulation10() { base.UpdateAfterSimulation10(); MatrixD mat = Entity.WorldMatrix; var door = Entity as MyAirtightDoorGeneric; foreach (KeyValuePair<string, MyEntitySubpart> sp in door.Subparts) { sp.Value.PositionComp.UpdateWorldMatrix(ref mat, null, true, true); } } public override void UpdateAfterSimulation() { base.UpdateAfterSimulation(); } }
Last edited by Hannobal; 7 Feb, 2019 @ 1:49pm
< >
Showing 1-1 of 1 comments
Vento 22 Jun, 2019 @ 2:55pm 
For something so complex, contact one of the keen developers on discord. For me they give you an answer quickly, given the beauty of this mod.
< >
Showing 1-1 of 1 comments
Per page: 1530 50