public void Init(Intension intension, Perception perception, FishBody body) { this.motorControllers.Clear(); var focusser = perception.GetFocuser(); var normal = body.modelData.Normal; var left = body.modelData.Left; var dir = focusser.target.obj.obj.Position - body.modelData.GeometryCenter; var motorType = focusser.motorPreference.MaxValue.type; if (motorType == Focusser.MotorPreference.Type.MoveForward) { if (this.smc == null) { this.smc = new SwimMC(); this.curves = this.smc.ActivationData.ToAnimationCurves(); } if (focusser.target.obj != null) { this.smc.UpdateSpeed(focusser.target.obj.distance); } this.motorControllers.Add(this.smc); } else if (motorType == Focusser.MotorPreference.Type.TurnLeft) { if (this.tlmc == null) { this.tlmc = new TurnLeftMC(); this.curves = this.tlmc.ActivationData.ToAnimationCurves(); } var angle = this.GetAngleInFish(dir, normal, left); this.tlmc.UpdateAngle(angle); this.motorControllers.Add(this.tlmc); this.smc?.UpdateSpeed(0); } else if (motorType == Focusser.MotorPreference.Type.TurnRight) { if (this.trmc == null) { this.trmc = new TurnRightMC(); this.curves = this.trmc.ActivationData.ToAnimationCurves(); } var angle = this.GetAngleInFish(dir, normal, left); this.trmc.UpdateAngle(angle); this.motorControllers.Add(this.trmc); this.smc?.UpdateSpeed(0); } var balance = new BalanceMC(); balance.UpdateBalance(left, normal); this.motorControllers.Add(balance); }
protected void InitActivations() { this.smc = new SwimMC(); this.lmc = new TurnLeftMC(); this.rmc = new TurnRightMC(); }