// // Return the normalized animation status // public MovementStatus AnimStatus(Sequence.MovementStatus curMovement) { MovementStatus rc; if (MagMoving) { rc = curMovement; } else { rc = ((mag.animTime == closed) ? Sequence.MovementStatus.closed : Sequence.MovementStatus.open); } return(rc); }
void SetMovementStatus(Sequence seq, Sequence.MovementStatus status) { movementStatus = status; while (seq != null) { seq.movementStatus = status; if (status == Sequence.MovementStatus.opening) { seq = seq.childIdx; } else { seq = seq.parentIdx; } } }
public void FixedUpdate() { bool anyMoving = false; Sequence cur = null; #if DEBUG Sequence prev = null; #endif cur = null; bool enableNext = false; switch (movementStatus) { case Sequence.MovementStatus.undef: Log.Error("FixedUpdate, Part: " + part.name + ", movementStatus is undefined"); break; case Sequence.MovementStatus.closed: return; case Sequence.MovementStatus.closing: cur = lastSeq; break; case Sequence.MovementStatus.open: return; case Sequence.MovementStatus.opening: cur = firstSeq; break; } while (cur != null) { if (enableNext) { if ((movementStatus == Sequence.MovementStatus.opening && lastSeqnumEnabled < cur.seqNum) || movementStatus == Sequence.MovementStatus.closing && lastSeqnumEnabled > cur.seqNum) { Log.Info("movementStatus: " + movementStatus + ", cur.seqNum: " + cur.seqNum + ", lastSeqNumEnabled: " + lastSeqnumEnabled); if ((!cur.MagMoving && cur.mag.aniState != ModuleAnimateGeneric.animationStates.MOVING) && ((movementStatus == Sequence.MovementStatus.opening && cur.AnimStatus(movementStatus) != Sequence.MovementStatus.open) || (movementStatus == Sequence.MovementStatus.closing && cur.AnimStatus(movementStatus) != Sequence.MovementStatus.closed)) ) { Log.Info("enableNext, cur.seqNum: " + cur.seqNum + ", movementStatus: " + movementStatus + ", cur.AnimStatus(movementStatus): " + cur.AnimStatus(movementStatus) + "," + "mag.animTime: " + cur.mag.animTime + ", mag.deployPercent: " + cur.mag.deployPercent ); cur.AnimStatus(movementStatus); cur.mag.Toggle(); lastSeqnumEnabled = cur.seqNum; cur.mag.aniState = ModuleAnimateGeneric.animationStates.MOVING; } } enableNext = false; } progress = (cur.closed == 1) ? cur.closed - cur.mag.Progress : cur.mag.Progress; switch (movementStatus) { case Sequence.MovementStatus.opening: { if (cur.MagMoving || cur.mag.aniState == ModuleAnimateGeneric.animationStates.MOVING) { if ((cur.allowChildAnimAt <= progress || progress >= cur.mag.deployPercent / 100f) && cur.childIdx != null) { Log.Info("1-enableNext = true, cur.seqNum:" + cur.seqNum + ", progress: " + progress + ", cur.mag.deployPercent: " + cur.mag.deployPercent); enableNext = true; } anyMoving = true; } else { if (cur.AnimStatus(Sequence.MovementStatus.opening) == Sequence.MovementStatus.open) { cur.movementStatus = Sequence.MovementStatus.open; } } #if DEBUG prev = cur; #endif cur.UpdateAnimTime(); cur = cur.childIdx; } break; case Sequence.MovementStatus.closing: { if (cur.MagMoving || cur.mag.aniState == ModuleAnimateGeneric.animationStates.MOVING) { if (cur.allowParentAnimAt >= progress && cur.parentIdx != null) { Log.Info("3-enableNext = true, movementStatus: " + movementStatus + ", cur.allowParentAnimAt: " + cur.allowParentAnimAt + ", progress: " + progress); enableNext = true; } anyMoving = true; } else { if (cur.AnimStatus(Sequence.MovementStatus.closing) == Sequence.MovementStatus.closed) { cur.movementStatus = Sequence.MovementStatus.closed; } } #if DEBUG prev = cur; #endif cur.UpdateAnimTime(); cur = cur.parentIdx; } break; } } if (!anyMoving) { Log.Info("!anyMoving, lastSeqnumEnabled: " + lastSeqnumEnabled); switch (movementStatus) { case Sequence.MovementStatus.undef: Log.Error("FixedUpdate 2, Part: " + part.name + ", movementStatus is undefined"); break; case Sequence.MovementStatus.closing: cur = lastSeq; while (cur != null) { if (lastSeqnumEnabled == cur.seqNum) { if (cur.parentIdx != null) { enableNext = true; break; } else { movementStatus = Sequence.MovementStatus.closed; break; } } cur = cur.parentIdx; } break; case Sequence.MovementStatus.opening: cur = firstSeq; while (cur != null) { if (lastSeqnumEnabled == cur.seqNum) { if (cur.childIdx != null) { enableNext = true; break; } else { movementStatus = Sequence.MovementStatus.open; break; } } cur = cur.childIdx; } break; } SetEventStatus(); } }
public void Start() { Log.Info("Start, part: " + part.name); { if (seqDict.ContainsKey(part.name)) { sequenceAnimations = seqDict[part.name]; foreach (var sa in sequenceAnimations) { UpdateAnimMovementStatus(sa); } SetUpParentChildValues(); #if DEBUG DumpConfig(); #endif } else { Log.Error("seqDict does NOT contain key: " + part.name); foreach (var s in seqDict.Keys) { Log.Error("seqDict.key: " + s); } } } Events["OpenEvent"].guiName = openEventGUIName; Events["CloseEvent"].guiName = closeEventGUIName; Events["Action"].guiName = actionGUIName; Events["OpenEvent"].active = true; Events["CloseEvent"].active = true; Events["Action"].active = false; Events["CloseEvent"].active = false; Events["AdjustLimitsEvent"].active = false; Sequence cur = firstSeq; while (cur != null) { { cur.mag = GetAnimation(cur.animName); if (cur.mag == null) { Log.Error("No animation found at seqNum: " + cur.seqNum); } else { UpdateAnimMovementStatus(cur); if (movementStatus != Sequence.MovementStatus.undef && movementStatus != cur.movementStatus) { Log.Error("animations have different movement settings"); } movementStatus = cur.movementStatus; } } cur.mag.enabled = true; cur.mag.allowManualControl = true; cur.mag.Events["Toggle"].guiActive = false; cur.mag.Events["ToggleStaging"].guiActive = false; cur.mag.Events["Toggle"].guiActiveEditor = false; cur.mag.Events["ToggleStaging"].guiActiveEditor = false; cur.mag.Actions["ToggleAction"].active = false; cur.mag.Fields["status"].guiActive = false; cur = cur.childIdx; } SetEventStatus(); }