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