Space Engineers

Space Engineers

Airtight Force Field Hangar Doors
Hannobal  [开发者] 2019 年 2 月 7 日 下午 1:39
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(); } }
最后由 Hannobal 编辑于; 2019 年 2 月 7 日 下午 1:49
< >
正在显示第 1 - 1 条,共 1 条留言
Vento 2019 年 6 月 22 日 下午 2:55 
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.
< >
正在显示第 1 - 1 条,共 1 条留言
每页显示数: 1530 50