protected override bool OpenData(out BobEffect.Data data) { if (!this.glob.valid) { data = null; return(false); } data = new BobPunchEffect.PunchData() { effect = this }; return(true); }
protected override BOBRES SimulateData(ref BobEffect.Context ctx) { if (ctx.dt == 0) { return(BOBRES.CONTINUE); } BobPunchEffect.PunchData punchDatum = (BobPunchEffect.PunchData)ctx.data; if (punchDatum.time >= this.glob.endTime) { return(BOBRES.EXIT); } if (punchDatum.time >= this.glob.endTime) { return(BOBRES.EXIT); } if (this.x.valid) { if (this.x.constant || punchDatum.time <= this.x.startTime) { punchDatum.force.x = (double)this.x.startValue; } else if (punchDatum.time < this.x.endValue) { punchDatum.force.x = (double)this.x.curve.Evaluate(punchDatum.time); } else { punchDatum.force.x = (double)this.x.endValue; } } if (this.y.valid) { if (this.y.constant || punchDatum.time <= this.y.startTime) { punchDatum.force.y = (double)this.y.startValue; } else if (punchDatum.time < this.y.endValue) { punchDatum.force.y = (double)this.y.curve.Evaluate(punchDatum.time); } else { punchDatum.force.y = (double)this.y.endValue; } } if (this.z.valid) { if (this.z.constant || punchDatum.time <= this.z.startTime) { punchDatum.force.z = (double)this.z.startValue; } else if (punchDatum.time < this.z.endValue) { punchDatum.force.z = (double)this.z.curve.Evaluate(punchDatum.time); } else { punchDatum.force.z = (double)this.z.endValue; } } if (this.pitch.valid) { if (this.pitch.constant || punchDatum.time <= this.pitch.startTime) { punchDatum.torque.x = (double)this.pitch.startValue; } else if (punchDatum.time < this.pitch.endValue) { punchDatum.torque.x = (double)this.pitch.curve.Evaluate(punchDatum.time); } else { punchDatum.torque.x = (double)this.pitch.endValue; } } if (this.yaw.valid) { if (this.yaw.constant || punchDatum.time <= this.yaw.startTime) { punchDatum.torque.y = (double)this.yaw.startValue; } else if (punchDatum.time < this.yaw.endValue) { punchDatum.torque.y = (double)this.yaw.curve.Evaluate(punchDatum.time); } else { punchDatum.torque.y = (double)this.yaw.endValue; } } if (this.roll.valid) { if (this.roll.constant || punchDatum.time <= this.roll.startTime) { punchDatum.torque.z = (double)this.roll.startValue; } else if (punchDatum.time < this.roll.endValue) { punchDatum.torque.z = (double)this.roll.curve.Evaluate(punchDatum.time); } else { punchDatum.torque.z = (double)this.roll.endValue; } } BobPunchEffect.PunchData punchDatum1 = punchDatum; punchDatum1.time = punchDatum1.time + (float)ctx.dt; return(BOBRES.CONTINUE); }