Example #1
0
        /// <summary>
        /// Constructs a new EntityMover.
        /// </summary>
        /// <param name="e">Entity to move.</param>
        public EntityMover(Entity e)
        {
            IsUpdatedSequentially = false;
            LinearMotor           = new SingleEntityLinearMotor(e, e.Position);
            Entity = e;

            LinearMotor.Settings.Mode = MotorMode.Servomechanism;
            TargetPosition            = e.Position;
        }
Example #2
0
        /// <summary>
        /// Constructs a new EntityMover.
        /// </summary>
        /// <param name="e">Entity to move.</param>
        /// <param name="linearMotor">Motor to use for linear motion if the entity is dynamic.</param>
        public EntityMover(Entity e, SingleEntityLinearMotor linearMotor)
        {
            IsUpdatedSequentially = false;
            LinearMotor           = linearMotor;
            Entity = e;

            linearMotor.Entity        = Entity;
            linearMotor.Settings.Mode = MotorMode.Servomechanism;
            TargetPosition            = e.Position;
        }
Example #3
0
        /// <summary>
        /// Constructs a grab constraint.
        /// </summary>
        public MotorizedGrabSpring()
        {
            //Note that when the motor is created using the empty constructor,
            //it starts deactivated.  This prevents explosions from attempting
            //to update it without being configured.
            linearMotor  = new SingleEntityLinearMotor();
            angularMotor = new SingleEntityAngularMotor();
            linearMotor.Settings.Mode = MotorMode.Servomechanism;

            //The stiffness, damping, and maximum force could be assigned during setup if the motor
            //needs to behave similarly for entities of varying masses.  When using a fixed configuration,
            //the grabspring will behave weakly when trying to move extremely heavy objects, while staying
            //very responsive for sufficiently light objects.

            IsUpdating = false;
        }
Example #4
0
        public ShipObj(Vector3 position, Quaternion orientation, ShipData data)
            : base()
        {
            Data = data;
            Data.ComposeHitbox();
            Data.Hitbox.Position    = position;
            Data.Hitbox.Orientation = orientation;
            this.SetEntity(Data.Hitbox, 2);


            Health          = Data.TotalArmor;
            Thrusters       = new SingleEntityLinearMotor(Entity, Position);
            ControlSurfaces = new SingleEntityAngularMotor(Entity);
            ControlSurfaces.Settings.Mode = MotorMode.Servomechanism;

            Thrusters.Settings.Mode = MotorMode.VelocityMotor;
            Thrusters.Settings.VelocityMotor.Softness = 0.002f;
            Entity.IsAffectedByGravity = true;

            Sector.Redria.Space.Add(Thrusters);
            Sector.Redria.Space.Add(ControlSurfaces);
            Network.AddShip();
        }