Beispiel #1
0
        public Rotor(World world, RotorDesc rotor, string cobName)
        {
            //Rotor name
            _name = rotor.Name + Guid.NewGuid().ToString();
            _displayName = rotor.Name;
            //Defines the force direction depending of the helix type
            _baseForceApplied = 1;
            if (rotor.Blade.Type == BladeType.LeftHandedBlade)
            {
                _baseForceApplied = -1;
            }

            //Defines the engine rotor direction depending of the engine power polarity
            _torque = 1;
            if (rotor.Engine.Polarity == Polarity.Negative)
            {
                _torque = -1;
                _baseForceApplied = -_baseForceApplied;
            }

            //Defines the rotor lift
            _baseForceApplied *= (rotor.MassLift * ((WorldDesc)world.Descriptor).Gravity.Length()) / (rotor.RPMLift * rotor.RPMLift);

            //Subscribes to the world for getting back the rotor's actor and joint
            world.JointAddedFiltered.Subscribe(new RegexFilter<IJoint>(cobName + "[.]" + rotor.Engine.Name), BindJoint);
            world.ActorAddedFiltered.Subscribe(new RegexFilter<IActor>(cobName + "[.]ComplexObject[.]" + rotor.Blade.Name), BindActor);

            world.AddActuator(this);
        }