示例#1
0
        void ResetCar()
        {
            if (Intellect != null)
            {
                if (Intellect.IsControlKeyPressed(GameControlKeys.Reload))
                {
                    PhysicsModel.Bodies[0].ClearForces();
                    PhysicsModel.Bodies[0].LinearVelocity  = Vec3.Zero;
                    PhysicsModel.Bodies[0].AngularVelocity = Vec3.Zero;

                    Ray ray = new Ray(Position, new Vec3(0, 0, -Type.CONF.HeightResetCar));
                    if (!Single.IsNaN(ray.Direction.X) && !Single.IsNaN(ray.Origin.X))
                    {
                        RayCastResult[] piercingResult = PhysicsWorld.Instance.RayCastPiercing(
                            ray, (int)ContactGroup.CastOnlyContact);
                        bool collision = false;
                        foreach (RayCastResult result in piercingResult)
                        {
                            if (Array.IndexOf(PhysicsModel.Bodies, result.Shape.Body) != -1)
                            {
                                continue;
                            }
                            collision = true;
                            break;
                        }
                        if (collision)
                        {
                            Position = new Vec3(OldPosition.X, OldPosition.Y, OldPosition.Z + 0.1f);
                        }
                    }
                    Rotation = new Quat(0, 0, OldRotation.Z, OldRotation.W);
                }
            }
        }
示例#2
0
        private void JetEngineBooster()
        {
            MapObjectAttachedParticle ENBoosterParticle1 = GetFirstAttachedObjectByAlias("ENBoosterParticle1") as MapObjectAttachedParticle;
            MapObjectAttachedParticle ENBoosterParticle2 = GetFirstAttachedObjectByAlias("ENBoosterParticle2") as MapObjectAttachedParticle;

            bool BEngBoosterON = false;

            if (Intellect.IsControlKeyPressed(GameControlKeys.SHIFT))
            {
                if (ENGFuel >= 5)
                {
                    AKJetBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta,
                                       AKJetBody.Rotation * new Vec3(40, 0, 0) * MASS, Vec3.Zero);
                    ENGFuel      -= 0.5f;
                    BEngBoosterON = true;
                }
            }
            else
            {
                BEngBoosterON = false;
                if (ENGFuel < Type.ENGBoosterFuelCapacity)
                {
                    ENGFuel += 0.05f;
                }
            }
            if (ENBoosterParticle1 != null)
            {
                ENBoosterParticle1.Visible = BEngBoosterON;
                ENBoosterParticle2.Visible = BEngBoosterON;
            }
        }
示例#3
0
 private void TickRun()
 {
     if (!Z || croutch)
     {
         return;
     }
     if (Intellect.IsControlKeyPressed(GameControlKeys.Shift) && Z && !croutch)
     {
         if (RunEnergy >= 5)
         {
             Run = true;
             Type.WalkMaxVelocity = 20;
             Type.WalkForce       = 15000f;
             RunEnergy           -= 5;
         }
     }
     else
     {
         Run = false;
         Type.WalkMaxVelocity = 7;
         Type.WalkForce       = 6000f;
         if (RunEnergy < Type.RunEnergyMax)
         {
             RunEnergy += 1;
         }
     }
 }
示例#4
0
        private void ShiftBooster()
        {
            MapObjectAttachedParticle NOS1 = GetFirstAttachedObjectByAlias("NOS1") as MapObjectAttachedParticle;
            MapObjectAttachedParticle NOS2 = GetFirstAttachedObjectByAlias("NOS2") as MapObjectAttachedParticle;

            bool boosted = false;

            if (Intellect.IsControlKeyPressed(GameControlKeys.Shift))
            {
                if (Type.NOSBottel >= 5)
                {
                    boosted         = true;
                    NOSBoost        = 50;
                    Type.NOSBottel -= 0.5f;
                }
                else
                {
                    NOSBoost = 0;
                }
            }
            else
            {
                NOSBoost = 0;
                if (Type.NOSBottel < 100)
                {
                    Type.NOSBottel += 0.05f;
                }
            }
            if (NOS1 != null)
            {
                NOS1.Visible = boosted;
                NOS2.Visible = boosted;
            }
        }
示例#5
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnTick()"/>.</summary>
        protected override void OnTick()
        {
            base.OnTick();

            if (Intellect != null)
            {
                if (Intellect.IsControlKeyPressed(GameControlKeys.Fire1))
                {
                    GunsTryFire(false);
                }
                if (Intellect.IsControlKeyPressed(GameControlKeys.Fire2))
                {
                    GunsTryFire(true);
                }
            }

            //send turn to position to clients
            if (EntitySystemWorld.Instance.IsServer())
            {
                float epsilon = .05f;
                if (!server_shouldSendTurnToPosition.Equals(server_sentTurnToPosition, epsilon))
                {
                    Server_SendTurnToPositionToClients(EntitySystemWorld.Instance.RemoteEntityWorlds,
                                                       server_shouldSendTurnToPosition);
                    server_sentTurnToPosition = server_shouldSendTurnToPosition;
                }
            }
        }
示例#6
0
        public void SetIntellect(Intellect value, bool shouldDeleteAfterDetach)
        {
            Intellect oldIntellect = intellect;
            bool      oldIntellectShouldDeleteAfterDetach = intellectShouldDeleteAfterDetach;

            if (intellect != null)
            {
                UnsubscribeToDeletionEvent(intellect);
            }

            intellect = value;
            intellectShouldDeleteAfterDetach = shouldDeleteAfterDetach;

            if (intellect != null)
            {
                SubscribeToDeletionEvent(intellect);
            }

            if (oldIntellect != null && oldIntellectShouldDeleteAfterDetach)
            {
                oldIntellect.SetForDeletion(true);
            }

            //send update to clients
            if (EntitySystemWorld.Instance.IsServer())
            {
                Server_SendIntellectToClients(EntitySystemWorld.Instance.RemoteEntityWorlds);
            }
        }
示例#7
0
        private void ShiftBooster()
        {
            MapObjectAttachedParticle Shift1 = GetFirstAttachedObjectByAlias("Shift1") as MapObjectAttachedParticle;
            MapObjectAttachedParticle Shift2 = GetFirstAttachedObjectByAlias("Shift2") as MapObjectAttachedParticle;

            bool boosted = false;

            if (Intellect.IsControlKeyPressed(GameControlKeys.SHIFT))
            {
                if (ShiftBottel >= 5)
                {
                    AKVTOLBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta,
                                        AKVTOLBody.Rotation * new Vec3(40, 0, 0) * MASS, Vec3.Zero);
                    ShiftBottel -= 0.5f;
                    boosted      = true;
                }
            }
            else
            {
                boosted = false;
                if (ShiftBottel < Type.MaxShiftBottel)
                {
                    ShiftBottel += 0.05f;
                }
            }

            if (Shift1 != null)
            {
                Shift1.Visible = boosted;
            }
            if (Shift2 != null)
            {
                Shift2.Visible = boosted;
            }
        }
示例#8
0
        private void Client_ReceiveIntellect(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            uint        networkUIN = reader.ReadVariableUInt32();
            bool        shouldDeleteAfterDetach = reader.ReadBoolean();
            FactionType ft = null;

            if (GameMap.Instance.GameType == GameMap.GameTypes.AssaultKnights)
            {
                string factionName = reader.ReadString();
                if (factionName != string.Empty)
                {
                    ft = (FactionType)EntityTypes.Instance.GetByName(factionName);
                }
            }
            if (!reader.Complete())
            {
                return;
            }

            Intellect i = null;

            if (networkUIN != 0)
            {
                i = (Intellect)Entities.Instance.GetByNetworkUIN(networkUIN);
                if (ft != null)
                {
                    i.Faction = ft;
                }
            }
            SetIntellect(i, shouldDeleteAfterDetach);
        }
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnTick()"/>.</summary>
        protected override void OnTick()
        {
            base.OnTick();

            if (Intellect != null)
            {
                if (Intellect.IsControlKeyPressed(GameControlKeys.Fire1))
                {
                    WeaponTryFire(false);
                }

                if (Intellect.IsControlKeyPressed(GameControlKeys.Fire2))
                {
                    WeaponTryFire(true);
                }
            }

            TickContusionTime();

            if (activeWeapon == null || activeWeapon.Ready)
            {
                UpdateTPSArcadeLookDirection();
                UpdatePlatformerDemoLookDirection();
            }
        }
        private void ControlledObject_Damage(Dynamic entity, MapObject prejudicial, Vec3 pos, float damage)
        {
            if (generalTaskType != GeneralTaskTypes.Battle && prejudicial != null)
            {
                Unit sourceUnit = null;

                Bullet bullet = prejudicial as Bullet;
                if (bullet != null)
                {
                    sourceUnit = bullet.SourceUnit;
                }
                Explosion explosion = prejudicial as Explosion;
                if (explosion != null)
                {
                    sourceUnit = explosion.SourceUnit;
                }

                if (sourceUnit != null)
                {
                    Intellect unitIntellect = sourceUnit.Intellect as Intellect;
                    if (unitIntellect != null && unitIntellect.Faction != Faction)
                    {
                        //do battle task
                        DoGeneralTask(GeneralTaskTypes.Battle, null);

                        //move to enemy
                        DoMoveTask(sourceUnit.Position);

                        //notify allies
                        NotifyAlliesOnEnemy(sourceUnit.Position);
                    }
                }
            }
        }
示例#11
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnDeleteSubscribedToDeletionEvent(Entity)"/></summary>
        protected override void OnDeleteSubscribedToDeletionEvent(Entity entity)
        {
            base.OnDeleteSubscribedToDeletionEvent(entity);

            if (intellect == entity)
            {
                intellect = null;
            }
        }
示例#12
0
        private void TickSound()
        {
            bool lastMotorOn = AKJetOn;

            AKJetOn = Intellect != null && Intellect.IsActive();

            //sound on, off
            if (AKJetOn != lastMotorOn)
            {
                if (AKJetOn)
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(Type.SoundOn, SoundMode.Mode3D);
                    if (sound != null)
                    {
                        soundOnChannel = SoundWorld.Instance.SoundPlay(sound, EngineApp.Instance.DefaultSoundChannelGroup, .7f, true);
                        if (soundOnChannel != null)
                        {
                            soundOnChannel.Position = Position;
                            soundOnChannel.Pause    = false;
                        }
                    }
                    //SoundPlay3D(Type.SoundOn, .7f, true);
                }
                else
                {
                    EngineOff();
                    SoundPlay3D(Type.SoundOff, 0.7f, true);
                }
            }

            string needSoundName = null;

            if (AKJetOn)
            {
                needSoundName = Type.SoundIdle;
            }
            if (needSoundName != currentRotorSoundName)
            {
                currentRotorSoundName = needSoundName;

                if (!string.IsNullOrEmpty(needSoundName))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(needSoundName,
                                                                  SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        rotorSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, 1, true);
                        rotorSoundChannel.Position = Position;
                        rotorSoundChannel.Pause    = false;
                    }
                }
            }
        }
示例#13
0
        void CreateInitialAI(bool loaded)
        {
            if (EntitySystemWorld.Instance.IsEditor())
            {
                return;
            }
            if (loaded && EntitySystemWorld.Instance.SerializationMode == SerializationModes.World)
            {
                return;
            }

            if (Intellect != null)
            {
                return;
            }

            AIType initAI = InitialAI;

            if (initAI == null)
            {
                initAI = Type.InitialAI;
            }

            if (initAI == null)
            {
                return;
            }

            if (EntitySystemWorld.Instance.IsDedicatedServer())
            {
                if (initAI.NetworkType == EntityNetworkTypes.ClientOnly)
                {
                    return;
                }
            }
            if (EntitySystemWorld.Instance.IsClientOnly())
            {
                if (initAI.NetworkType == EntityNetworkTypes.ServerOnly)
                {
                    return;
                }
                if (initAI.NetworkType == EntityNetworkTypes.Synchronized)
                {
                    return;
                }
            }

            //create intellect
            Intellect i = (Intellect)Entities.Instance.Create(initAI, World.Instance);

            i.Faction          = InitialFaction;
            i.ControlledObject = this;
            i.PostCreate();
            SetIntellect(i, true);
        }
示例#14
0
        private void TickLadder()
        {
            //!!!!!â òèï?
            const float ladderClimbingSpeedWalk = 1.5f;
            const float ladderClimbingSpeedRun  = 3;

            SphereDir lookDirection = SphereDir.Zero;
            {
                PlayerIntellect playerIntellect = Intellect as PlayerIntellect;
                if (playerIntellect != null)
                {
                    lookDirection = playerIntellect.LookDirection;
                }
            }

            bool wantMove =
                Intellect.IsControlKeyPressed(GameControlKeys.Forward) ||
                Intellect.IsControlKeyPressed(GameControlKeys.Backward) ||
                Intellect.IsControlKeyPressed(GameControlKeys.Left) ||
                Intellect.IsControlKeyPressed(GameControlKeys.Right);

            Ladder ladder = FindLadder(currentLadder != null, wantMove, lookDirection);

            if (ladder != currentLadder)
            {
                SetCurrentLadder(ladder);
            }

            if (currentLadder != null)
            {
                Line line = currentLadder.GetClimbingLine();

                Vec3 projected = MathUtils.ProjectPointToLine(line.Start, line.End, Position);

                Vec3 newPosition = projected;

                float climbingSpeed = IsNeedRun() ? ladderClimbingSpeedRun : ladderClimbingSpeedWalk;

                Vec3 moveVector = Vec3.Zero;

                float lookingSide = new Radian(lookDirection.Vertical).InDegrees() > -20 ? 1 : -1;
                moveVector.Z += Intellect.GetControlKeyStrength(GameControlKeys.Forward) * lookingSide;
                moveVector.Z -= Intellect.GetControlKeyStrength(GameControlKeys.Backward) * lookingSide;

                newPosition += moveVector * (TickDelta * climbingSpeed);

                Position = newPosition;

                if (mainBody != null)
                {
                    mainBody.LinearVelocity  = Vec3.Zero;
                    mainBody.AngularVelocity = Vec3.Zero;
                }
            }
        }
示例#15
0
 protected override void OnTick()
 {
     base.OnTick();
     ResetCar();
     TickCurrentGear();
     TickMotorSound();
     if (Type.CONF.Deformation)
     {
         if (attached_mesh != null)
         {
             attached_mesh.MeshObject.Mesh.SubMeshes[0].VertexData.GetSomeGeometry(ref changeable_vertex_pos,
                                                                                   ref changeable_vertex_norm);
             if (changeable_vertex_pos.Count != 0)
             {
                 if (Type.CONF.ParallelComputing)
                 {
                     DeformationMeshParallel();
                 }
                 else
                 {
                     DeformationMesh();
                 }
             }
         }
     }
     if (PhysicsModel != null)
     {
         float handbrake = 0;
         if (Intellect != null)
         {
             handbrake = Intellect.GetControlKeyStrength(GameControlKeys.VehicleHandbrake);
         }
         else
         {
             handbrake = 1;
         }
         if (!IsInAir() & handbrake != 0 &
             (PhysicsModel.Bodies[0].LinearVelocity.Length() * 3600.0f / 1000.0f) > 30)
         {
             SoundPlay3D(Type.CONF.SoundBrake, .7f, true);
             foreach (RibbonTrail rt in rtbrake)
             {
                 rt.Visible = true;
             }
         }
         else
         {
             foreach (RibbonTrail rt in rtbrake)
             {
                 rt.Visible = false;
             }
         }
     }
     first_tick = false;
 }
示例#16
0
        private void TickIntellect(Intellect intellect)
        {
            Vec2 forceVec = GetMovementByControlKeys();

            if (forceVec != Vec2.Zero)
            {
                float speedCoefficient = 1;
                if (FastMoveInfluence != null)
                {
                    speedCoefficient = FastMoveInfluence.Type.Coefficient;
                }

                float force = 0f;

                Vec2 localVec = (new Vec3(forceVec.X, forceVec.Y, 0) * Rotation.GetInverse()).ToVec2();

                float absSum = Math.Abs(localVec.X) + Math.Abs(localVec.Y);
                if (absSum > 1)
                {
                    localVec /= absSum;
                }

                if (Math.Abs(localVec.X) >= .001f)
                {
                    //forward and backward
                    force += SpeedForwardBack * SpeedMultiplier * Math.Abs(localVec.X) * speedCoefficient;
                }

                if (Math.Abs(localVec.Y) >= .001f)
                {
                    //left and right
                    force += SpeedStrafe * SpeedMultiplier * Math.Abs(localVec.Y) * speedCoefficient;
                }

                //speedCoefficient
                //*= speedCoefficient;
                force *= speedCoefficient;
                Vec3 forcesoffset = new Vec3(forceVec.X, forceVec.Y, PhysicsGravity * TickDelta) * force * TickDelta;
                //forcesoffset.Z += .5f;
                if (Damager_Ball_Player.LinearVelocity.Length() < MaxSpeed)
                {
                    Damager_Ball_Player.AddForce(ForceType.Global, 0, forcesoffset, Vec3.Zero);
                }
                //else
                //{
                //     Damager_Ball_Player.AddForce(ForceType.Global, 0, new Vec3(0, 0, Type.PhysicsGravity ) * TickDelta, Vec3.Zero);
                //}
            }

            //lastTickForceVector = forceVec;
        }
示例#17
0
        protected override void OnTick()
        {
            if (Intellect.InCombatAndActive())
            {
                //REMOVE APS
                if ((lastPosCheck - Position).Normalize() > 0.8)
                {
                    Intellect.IncActionPts(-1);
                    lastPosCheck = Position;
                }
            }

            base.OnTick();
        }
示例#18
0
        public ServerOrSingle_Player ServerOrSingle_GetPlayer(Intellect intellect)
        {
            if (intellect == null)
            {
                Log.Fatal("PlayerManager: ServerOrSingle_GetPlayerByIntellect: intellect == null.");
            }

            //it is can be slowly. need to use Dictionary.
            foreach (ServerOrSingle_Player player in serverOrSingle_players)
            {
                if (player.Intellect == intellect)
                {
                    return(player);
                }
            }
            return(null);
        }
示例#19
0
        public bool CanOpenInventory()
        {
            if (Intellect.OutsideCombatOrActive())
            {
                if (ActionPts > 1)
                {
                    Intellect.IncActionPts(-2);
                }
                else
                {
                    Log.Info("Not enough action points");
                    return(false);
                }
            }

            return(true);
        }
示例#20
0
        void Client_ReceiveIntellect(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            uint networkUIN = reader.ReadVariableUInt32();
            bool shouldDeleteAfterDetach = reader.ReadBoolean();

            if (!reader.Complete())
            {
                return;
            }

            Intellect i = null;

            if (networkUIN != 0)
            {
                i = (Intellect)Entities.Instance.GetByNetworkUIN(networkUIN);
            }
            SetIntellect(i, shouldDeleteAfterDetach);
        }
示例#21
0
        void TickIntellect()
        {
            //horizontalMotor
            {
                float throttle = 0;
                throttle += Intellect.GetControlKeyStrength(GameControlKeys.Left);
                throttle -= Intellect.GetControlKeyStrength(GameControlKeys.Right);

                GearedMotor motor = PhysicsModel.GetMotor("horizontalMotor") as GearedMotor;
                if (motor != null)
                {
                    motor.Throttle = throttle;
                }
            }

            //gibbetMotor
            {
                ServoMotor motor = PhysicsModel.GetMotor("gibbetMotor") as ServoMotor;
                if (motor != null)
                {
                    Radian needAngle = motor.DesiredAngle;

                    needAngle += Intellect.GetControlKeyStrength(GameControlKeys.Forward) * .004f;
                    needAngle -= Intellect.GetControlKeyStrength(GameControlKeys.Backward) * .004f;

                    MathFunctions.Clamp(ref needAngle,
                                        new Degree(-20.0f).InRadians(), new Degree(40.0f).InRadians());

                    motor.DesiredAngle = needAngle;
                }
            }

            //Change player LookDirection at rotation
            PlayerIntellect intellect = Intellect as PlayerIntellect;

            if (intellect != null)
            {
                Vec3 lookVector = intellect.LookDirection.GetVector();
                lookVector *= OldRotation.GetInverse();
                lookVector *= Rotation;
                intellect.LookDirection = SphereDir.FromVector(lookVector);
            }
        }
示例#22
0
        public bool IsNeedRun()
        {
            bool run = false;

            if (Intellect != null)
            {
                run = Intellect.IsAlwaysRun();
            }
            else
            {
                run = false;
            }

            if (Intellect != null && Intellect.IsControlKeyPressed(GameControlKeys.Run))
            {
                run = !run;
            }

            return(run);
        }
示例#23
0
        public FactionType GetRootUnitFaction()
        {
            Unit unit = this;

            while (true)
            {
                Intellect objIntellect = unit.Intellect;
                if (objIntellect != null && objIntellect.Faction != null)
                {
                    return(objIntellect.Faction);
                }

                Unit obj = unit.AttachedMapObjectParent as Unit;
                if (obj == null)
                {
                    return(null);
                }
                unit = obj;
            }
        }
示例#24
0
        void TickMagnet()
        {
            bool userNeedDetach = Intellect != null &&
                                  (Intellect.IsControlKeyPressed(GameControlKeys.Fire1) ||
                                   Intellect.IsControlKeyPressed(GameControlKeys.Fire2));

            //attach new bodies
            if (!userNeedDetach)
            {
                const int needContacts = 3;

                foreach (KeyValuePair <Body, int> pair in lastMagnetContactsCount)
                {
                    Body mapObjectBody = pair.Key;
                    int  contactsCount = pair.Value;

                    if (contactsCount >= needContacts)
                    {
                        MagnetAttachObject(mapObjectBody);
                    }
                }
            }
            lastMagnetContactsCount.Clear();

            //detach by user
            if (userNeedDetach)
            {
                MagnetDetachAllObjects();
            }

            //detach if joint disposed
again:
            foreach (MagnetObjectItem item in magnetAttachedObjects)
            {
                if (item.fixedJoint.IsDisposed)
                {
                    MagnetDetachObject(item);
                    goto again;
                }
            }
        }
示例#25
0
        public void BaseAttack(Dynamic ent, string skill)
        {
            foreach (MapObject m in ObjectsInPath(this, ent))
            {
                Log.Info("Objects in path {0}", m.Name);
            }

            MultipleActionItem mTmp = activeHeldItem as MultipleActionItem;

            if (mTmp != null && mTmp.Use(ent))
            {
                //remove action points, play sound, apply damage
                Intellect.IncActionPts(-mTmp.GetCurActionMode().ActionPoints);
                ent.DoDamage(this, Position, null, GetNetDamage(ent), false);
                SoundPlay3D(mTmp.GetCurActionMode().PlaySound, .5f, true);

                //TODO: do attack anim
                AnimationTree tree = GetFirstAnimationTree();
                if (tree != null)
                {
                    tree.ActivateTrigger("walkDance");
                }
            }
        }
示例#26
0
        private void TickIntellect(Intellect intellect)
        {
            Vec2 forceVec = GetMovementByControlKeys();
            if (forceVec != Vec2.Zero)
            {
                float speedCoefficient = 1;
                if (FastMoveInfluence != null)
                    speedCoefficient = FastMoveInfluence.Type.Coefficient;

                float force = 0f;

                Vec2 localVec = (new Vec3(forceVec.X, forceVec.Y, 0) * Rotation.GetInverse()).ToVec2();

                float absSum = Math.Abs(localVec.X) + Math.Abs(localVec.Y);
                if (absSum > 1)
                    localVec /= absSum;

                if (Math.Abs(localVec.X) >= .001f)
                {
                    //forward and backward
                    force += SpeedForwardBack * SpeedMultiplier * Math.Abs(localVec.X) * speedCoefficient;
                }

                if (Math.Abs(localVec.Y) >= .001f)
                {
                    //left and right
                    force += SpeedStrafe * SpeedMultiplier * Math.Abs(localVec.Y) * speedCoefficient;
                }

                //speedCoefficient
                //*= speedCoefficient;
                force *= speedCoefficient;
                Vec3 forcesoffset = new Vec3(forceVec.X, forceVec.Y, PhysicsGravity * TickDelta) * force * TickDelta;
                //forcesoffset.Z += .5f;
                if (Damager_Ball_Player.LinearVelocity.Length() < MaxSpeed)
                {
                    Damager_Ball_Player.AddForce(ForceType.Global, 0, forcesoffset, Vec3.Zero);
                }
                //else
                //{
                //     Damager_Ball_Player.AddForce(ForceType.Global, 0, new Vec3(0, 0, Type.PhysicsGravity ) * TickDelta, Vec3.Zero);
                //}
            }

            //lastTickForceVector = forceVec;
        }
示例#27
0
        public void SetIntellect(Intellect value, bool shouldDeleteAfterDetach)
        {
            Intellect oldIntellect = intellect;
            bool oldIntellectShouldDeleteAfterDetach = intellectShouldDeleteAfterDetach;

            if (intellect != null)
                UnsubscribeToDeletionEvent(intellect);

            intellect = value;
            intellectShouldDeleteAfterDetach = shouldDeleteAfterDetach;

            if (intellect != null)
                SubscribeToDeletionEvent(intellect);

            if (oldIntellect != null && oldIntellectShouldDeleteAfterDetach)
                oldIntellect.SetForDeletion(true);

            //send update to clients
            if (EntitySystemWorld.Instance.IsServer())
                Server_SendIntellectToClients(EntitySystemWorld.Instance.RemoteEntityWorlds);
        }
示例#28
0
        private void TickChassis()
        {
            bool onGround = leftTrack.onGround || rightTrack.onGround;

            OnGround = onGround;
            float leftTrackThrottle  = 0;
            float rightTrackThrottle = 0;

            if (Intellect != null)
            {
                Reset(false);
                Wheels();
                ShiftBooster();
                GearchangeDtime();

                //force for stability
                float speedkmph = GetRealSpeed() * 3;
                float speedpure = speedkmph - (speedkmph % 1);

                MapObjectAttachedBillboard ta1 = GetFirstAttachedObjectByAlias("tail1")
                                                 as MapObjectAttachedBillboard;

                MapObjectAttachedBillboard ta2 = GetFirstAttachedObjectByAlias("tail2")
                                                 as MapObjectAttachedBillboard;

                MapObjectAttachedBillboard ta3 = GetFirstAttachedObjectByAlias("tail3")
                                                 as MapObjectAttachedBillboard;

                MapObjectAttachedBillboard ta4 = GetFirstAttachedObjectByAlias("tail4")
                                                 as MapObjectAttachedBillboard;

                bool backlightred = false;
                bool backlightw   = false;

                {
                    ServoMotor THREF = PhysicsModel.GetMotor("FB") as ServoMotor;
                    Radian     FB    = 0;

                    float forward = Intellect.GetControlKeyStrength(GameControlKeys.Forward);
                    leftTrackThrottle  += forward;
                    rightTrackThrottle += forward;

                    float backward = Intellect.GetControlKeyStrength(GameControlKeys.Backward);
                    leftTrackThrottle  -= backward;
                    rightTrackThrottle -= backward;

                    if (Intellect.IsControlKeyPressed(GameControlKeys.Forward))
                    {
                        if (GetRealSpeed() < 0.01)
                        {
                            backlightred = true;
                        }
                        FB++;
                    }
                    else if (Intellect.IsControlKeyPressed(GameControlKeys.Backward))
                    {
                        FB--;
                        if (GetRealSpeed() > 0.5)
                        {
                            backlightred = true;
                        }
                        if (GetRealSpeed() < 0.01)
                        {
                            backlightw = true;
                        }
                    }

                    MathFunctions.Clamp(ref FB,
                                        new Degree(-1.0f).InRadians(), new Degree(1.0f).InRadians());

                    THREF.DesiredAngle = FB;
                    if (ta1 != null)
                    {
                        ta1.Visible = backlightred;
                        ta2.Visible = backlightred;
                        ta3.Visible = backlightw;
                        ta4.Visible = backlightw;
                    }
                }
                {
                    ServoMotor wmotor   = PhysicsModel.GetMotor("wheel") as ServoMotor;
                    ServoMotor wmotor_2 = PhysicsModel.GetMotor("wheel2") as ServoMotor;

                    Radian needAngle = wmotor.DesiredAngle;

                    float left  = Intellect.GetControlKeyStrength(GameControlKeys.Left);
                    float right = Intellect.GetControlKeyStrength(GameControlKeys.Right);

                    if (left > 0)
                    {
                        needAngle -= 0.06f;
                    }
                    else if (right > 0)
                    {
                        needAngle += 0.06f;
                    }
                    else
                    {
                        needAngle = 0f;
                    }

                    float TBaseForce = 0;
                    float Pspeed     = GetRealSpeed();
                    if (Pspeed < 0)
                    {
                        Pspeed = -Pspeed;
                    }
                    TBaseForce = left + (-right);

                    float speedcoef = 1;
                    if (GetRealSpeed() < 10 && GetRealSpeed() > -10)
                    {
                        speedcoef = GetRealSpeed() / 10;
                    }

                    if (speedcoef < 0)
                    {
                        speedcoef = -speedcoef;
                    }

                    if (!Intellect.IsControlKeyPressed(GameControlKeys.Forward) && !Intellect.IsControlKeyPressed(GameControlKeys.Backward) && speedcoef != 1)
                    {
                        TBaseForce = TBaseForce * 1.5f;
                    }

                    if (GetRealSpeed() < 0)
                    {
                        TBaseForce = -TBaseForce;
                    }

                    float SpeedD = 120 / GetRealSpeed();
                    MathFunctions.Clamp(ref SpeedD, 1, 1.6f);
                    float TMainForce = TBaseForce * chassisBody.Mass * SpeedD * 10;

                    if (OnGround)
                    {
                        chassisBody.AddForce(ForceType.LocalTorque, TickDelta,
                                             new Vec3(0, 0, TMainForce * speedcoef * 2), Vec3.Zero);
                    }

                    MathFunctions.Clamp(ref needAngle,
                                        new Degree(-29.0f).InRadians(), new Degree(29.0f).InRadians());

                    if (wmotor != null)
                    {
                        wmotor.DesiredAngle   = needAngle;
                        wmotor_2.DesiredAngle = needAngle;
                    }
                }
            }

            Vec3 localLinearVelocity = chassisBody.LinearVelocity * chassisBody.Rotation.GetInverse();

            //add drive force

            float slopeForwardForceCoeffient;
            float slopeBackwardForceCoeffient;
            float slopeLinearDampingAddition;

            {
                Vec3   dir        = chassisBody.Rotation.GetForward();
                Radian slopeAngle = MathFunctions.ATan(dir.Z, dir.ToVec2().Length());
                Radian maxAngle   = MathFunctions.PI / 4;//new Degree(45)

                slopeForwardForceCoeffient = 1;
                if (slopeAngle > maxAngle)
                {
                    slopeForwardForceCoeffient = 0;
                }

                slopeBackwardForceCoeffient = 1;
                if (slopeAngle < -maxAngle)
                {
                    slopeBackwardForceCoeffient = 0;
                }

                MathFunctions.Clamp(ref slopeForwardForceCoeffient, 0, 1);
                MathFunctions.Clamp(ref slopeBackwardForceCoeffient, 0, 1);

                slopeLinearDampingAddition = localLinearVelocity.X > 0 ? slopeAngle : -slopeAngle;
                //slopeLinearDampingAddition *= 1;
                if (slopeLinearDampingAddition < 0)
                {
                    slopeLinearDampingAddition = 0;
                }
            }

            if (leftTrack.onGround)
            {
                if (leftTrackThrottle > 0 && localLinearVelocity.X < Type.MaxForwardSpeed)
                {
                    float force = localLinearVelocity.X > 0 ? currentGear.GearDriveForwardForce + NOSBoost + DownPower : currentGear.GearBrakeForce;
                    force *= leftTrackThrottle;
                    force *= slopeForwardForceCoeffient;
                    chassisBody.AddForce(ForceType.LocalAtLocalPos, TickDelta,
                                         new Vec3(force, 0, 0), new Vec3(0, tracksPositionYOffset, 0));
                }

                if (leftTrackThrottle < 0 && (-localLinearVelocity.X) < Type.MaxBackwardSpeed)
                {
                    float force = currentGear.GearBrakeForce; //: Type.DriveBackwardForce;
                    force *= leftTrackThrottle;
                    force *= slopeBackwardForceCoeffient;
                    chassisBody.AddForce(ForceType.LocalAtLocalPos, TickDelta,
                                         new Vec3(force, 0, 0), new Vec3(0, tracksPositionYOffset, 0));
                }
            }

            if (rightTrack.onGround)
            {
                if (rightTrackThrottle > 0 && localLinearVelocity.X < Type.MaxForwardSpeed)
                {
                    float force = localLinearVelocity.X > 0 ? currentGear.GearDriveForwardForce + NOSBoost + DownPower : currentGear.GearBrakeForce;
                    force *= rightTrackThrottle;
                    force *= slopeForwardForceCoeffient;
                    chassisBody.AddForce(ForceType.LocalAtLocalPos, TickDelta,
                                         new Vec3(force, 0, 0), new Vec3(0, -tracksPositionYOffset, 0));
                }

                if (rightTrackThrottle < 0 && (-localLinearVelocity.X) < Type.MaxBackwardSpeed)
                {
                    float force = currentGear.GearBrakeForce; //: Type.DriveBackwardForce;
                    force *= rightTrackThrottle;
                    force *= slopeBackwardForceCoeffient;
                    chassisBody.AddForce(ForceType.LocalAtLocalPos, TickDelta,
                                         new Vec3(force, 0, 0), new Vec3(0, -tracksPositionYOffset, 0));
                }
            }

            //LinearVelocity
            if (onGround && localLinearVelocity != Vec3.Zero)
            {
                Vec3 velocity = localLinearVelocity;
                velocity.Y = 0;
                chassisBody.LinearVelocity = chassisBody.Rotation * velocity;
            }

            bool stop = false; // onGround && leftTrackThrottle == 0 && rightTrackThrottle == 0;

            bool noLinearVelocity  = chassisBody.LinearVelocity.Equals(Vec3.Zero, .2f);
            bool noAngularVelocity = chassisBody.AngularVelocity.Equals(Vec3.Zero, .2f);

            //AngularDamping
            if (onGround)
            {
                //LinearDamping
                float linearDamping;
                if (stop)
                {
                    linearDamping = noLinearVelocity ? 1 : 1;
                }
                else
                {
                    linearDamping = .15f;
                }
                chassisBody.LinearDamping = linearDamping + slopeLinearDampingAddition;

                if (stop && noAngularVelocity)
                {
                    chassisBody.AngularDamping = 5;
                }
                else
                {
                    chassisBody.AngularDamping = 1;
                }
            }
            else
            {
                chassisBody.AngularDamping = 0.55f;
                chassisBody.LinearDamping  = 0.05f;
            }
        }
示例#29
0
        private void TickMotorSound()
        {
            bool lastMotorOn = motorOn;

            motorOn = Intellect != null && Intellect.IsActive();

            //sound on, off
            if (motorOn != lastMotorOn)
            {
                if (!firstTick && Health != 0)
                {
                    if (motorOn)
                    {
                        Sound sound = SoundWorld.Instance.SoundCreate(Type.SoundOn, SoundMode.Mode3D);
                        if (sound != null)
                        {
                            soundOnChannel = SoundWorld.Instance.SoundPlay(sound, EngineApp.Instance.DefaultSoundChannelGroup, .7f, true);
                            if (soundOnChannel != null)
                            {
                                soundOnChannel.Position = Position;
                                soundOnChannel.Pause    = false;
                            }
                        }
                        //SoundPlay3D(Type.SoundOn, .7f, true);
                    }
                    else
                    {
                        SoundPlay3D(Type.SoundOff, .7f, true);
                    }
                }
            }

            string needSoundName = null;

            if (motorOn && currentGear != null)
            {
                needSoundName = currentGear.SoundMotor;
            }

            if (needSoundName != currentMotorSoundName)
            {
                //change motor sound

                if (motorSoundChannel != null)
                {
                    motorSoundChannel.Stop();
                    motorSoundChannel = null;
                }

                currentMotorSoundName = needSoundName;

                if (!string.IsNullOrEmpty(needSoundName))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(needSoundName,
                                                                  SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        motorSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, .3f, true);
                        motorSoundChannel.Position = Position;
                        motorSoundChannel.Pause    = false;
                    }
                }
            }

            //update motor channel position and pitch
            if (motorSoundChannel != null)
            {
                Range speedRangeAbs = currentGear.SpeedRange;
                if (speedRangeAbs.Minimum < 0 && speedRangeAbs.Maximum < 0)
                {
                    speedRangeAbs = new Range(-speedRangeAbs.Maximum, -speedRangeAbs.Minimum);
                }
                Range pitchRange = currentGear.SoundMotorPitchRange;

                float speedAbs = Math.Abs(GetTracksSpeed());

                float speedCoef = 0;
                if (speedRangeAbs.Size() != 0)
                {
                    speedCoef = (speedAbs - speedRangeAbs.Minimum) / speedRangeAbs.Size();
                }
                MathFunctions.Clamp(ref speedCoef, 0, 1);

                float carpitch;
                //update channel
                if (!OnGround)
                {
                    if (Intellect.IsControlKeyPressed(GameControlKeys.Arrow_Up))
                    {
                        carpitch = pitchRange.Minimum + pitchRange.Size();
                    }
                    else
                    {
                        carpitch = pitchRange.Minimum;
                    }
                }
                else
                {
                    carpitch = pitchRange.Minimum + speedCoef * pitchRange.Size();
                }
                motorSoundChannel.Pitch    = carpitch;
                motorSoundChannel.Position = Position;
            }
        }
        protected override void OnIntellectCommand(Intellect.Command command)
        {
            base.OnIntellectCommand(command);

            if (EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle())
            {
                if (command.KeyPressed)
                {
                    if (command.Key >= GameControlKeys.Weapon1 && command.Key <= GameControlKeys.Weapon9)
                    {
                        int index = (int)command.Key - (int)GameControlKeys.Weapon1;
                        if (GetActiveWeapon() != index)
                            SetActiveWeapon(index);
                        else
                            SetActiveWeapon(-1);
                    }

                    if (command.Key == GameControlKeys.PreviousWeapon)
                        SetActivePreviousWeapon();
                    if (command.Key == GameControlKeys.NextWeapon)
                        SetActiveNextWeapon();
                    if (command.Key == GameControlKeys.Fire1)
                        WeaponTryFire(false);
                    if (command.Key == GameControlKeys.Fire2)
                        WeaponTryFire(true);
                    if (command.Key == GameControlKeys.Reload)
                        WeaponTryReload();
                }
            }
        }
示例#31
0
        protected override void OnIntellectCommand(Intellect.Command command)
        {
            base.OnIntellectCommand(command);

            if (command.KeyPressed)
            {
                if (command.Key == GameControlKeys.Reload)
                {
                    Reset(true);
                }
            }
        }
示例#32
0
		void TickIntellect( Intellect intellect )
		{
			Vec2 forceVec = GetMovementVectorByControlKeys();
			if( forceVec != Vec2.Zero )
			{
				float speedCoefficient = 1;
				if( FastMoveInfluence != null )
					speedCoefficient = FastMoveInfluence.Type.Coefficient;

				float maxSpeed;
				float force;

				if( IsOnGround() )
				{
					//calcualate maxSpeed and force on ground.

					Vec2 localVec = ( new Vec3( forceVec.X, forceVec.Y, 0 ) * Rotation.GetInverse() ).ToVec2();

					float absSum = Math.Abs( localVec.X ) + Math.Abs( localVec.Y );
					if( absSum > 1 )
						localVec /= absSum;

					bool running = IsNeedRun();

					maxSpeed = 0;
					force = 0;

					if( Math.Abs( localVec.X ) >= .001f )
					{
						//forward and backward
						float speedX;
						if( localVec.X > 0 )
							speedX = running ? Type.RunForwardMaxSpeed : Type.WalkForwardMaxSpeed;
						else
							speedX = running ? Type.RunBackwardMaxSpeed : Type.WalkBackwardMaxSpeed;
						maxSpeed += speedX * Math.Abs( localVec.X );
						force += ( running ? Type.RunForce : Type.WalkForce ) * Math.Abs( localVec.X );
					}

					if( Math.Abs( localVec.Y ) >= .001f )
					{
						//left and right
						maxSpeed += ( running ? Type.RunSideMaxSpeed : Type.WalkSideMaxSpeed ) *
							Math.Abs( localVec.Y );
						force += ( running ? Type.RunForce : Type.WalkForce ) * Math.Abs( localVec.Y );
					}
				}
				else
				{
					//calcualate maxSpeed and force when flying.
					maxSpeed = Type.FlyControlMaxSpeed;
					force = Type.FlyControlForce;
				}

				//speedCoefficient
				maxSpeed *= speedCoefficient;
				force *= speedCoefficient;

				if( GetLinearVelocity().Length() < maxSpeed )
				{
					mainBody.AddForce( ForceType.Global, 0, new Vec3( forceVec.X, forceVec.Y, 0 ) *
						force * TickDelta, Vec3.Zero );
				}
			}

			lastTickForceVector = forceVec;
		}
示例#33
0
文件: Tank.cs 项目: whztt07/SDK
        protected override void OnIntellectCommand( Intellect.Command command )
        {
            base.OnIntellectCommand( command );

            if( EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle() )
            {
                if( command.KeyPressed )
                {
                    if( command.Key == GameControlKeys.Fire1 )
                    {
                        if( GunsTryFire( false ) )
                            AddMainGunRecoilForce();
                    }
                    if( command.Key == GameControlKeys.Fire2 )
                        GunsTryFire( true );
                }
            }
        }
示例#34
0
        private void TickIntellect(Intellect intellect)
        {
            Vec2 forceVec = Vec2.Zero;

            if (forceMoveVectorTimer != 0)
            {
                forceVec = forceMoveVector;
            }
            else
            {
                Vec2 vec = Vec2.Zero;

                vec.X += intellect.GetControlKeyStrength(GameControlKeys.Forward);
                vec.X -= intellect.GetControlKeyStrength(GameControlKeys.Backward);
                vec.Y += intellect.GetControlKeyStrength(GameControlKeys.Left);
                vec.Y -= intellect.GetControlKeyStrength(GameControlKeys.Right);

                forceVec = (new Vec3(vec.X, vec.Y, 0) * Rotation).ToVec2();

                if (forceVec != Vec2.Zero)
                {
                    float length = forceVec.Length();
                    if (length > 1)
                        forceVec /= length;
                }
            }

            if (forceVec != Vec2.Zero)
            {
                float velocityCoefficient = 1;
                if (FastMoveInfluence != null)
                    velocityCoefficient = FastMoveInfluence.Type.Coefficient;

                float maxVelocity;
                float force;

                if (IsOnGround())
                {
                    maxVelocity = Type.WalkMaxVelocity;
                    force = Type.WalkForce;
                }
                else
                {
                    maxVelocity = Type.FlyControlMaxVelocity;
                    force = Type.FlyControlForce;
                }

                maxVelocity *= forceVec.Length();

                //velocityCoefficient
                maxVelocity *= velocityCoefficient;
                force *= velocityCoefficient;

                if (mainBody.LinearVelocity.Length() < maxVelocity)
                    mainBody.AddForce(ForceType.Global, 0, new Vec3(forceVec.X, forceVec.Y, 0) *
                        force * TickDelta, Vec3.Zero);
            }

            if (!Z) return;

            CapsuleShape maincap = mainBody.Shapes[1] as CapsuleShape;
            CapsuleShape downcap = mainBody.Shapes[2] as CapsuleShape;

            if (Intellect.IsControlKeyPressed(GameControlKeys.Croutch))
            {
                croutch = true;
                Type.Height = Type.HeightMax / 3;
            }
            else if (Type.FPSCameraOffset != new Vec3(0, 0, -0.5f))
            {
                Type.Height = Type.HeightMax;
                croutch = false;
            }
            float length2 = Type.Height - Type.Radius * 2 - Type.WalkUpHeight;
            if (croutch)
            {
                Type.FPSCameraOffset = Vec3.Zero;
                Type.WalkMaxVelocity = 3;
                Type.WalkForce = 3000f;
                maincap.Position = new Vec3(0, 0, -0.5f);
                maincap.Length = length2 / 2;

                downcap.Position = new Vec3(0, 0, -0.5f);
                downcap.Length = 1.2f;
            }
            else if (!croutch && Type.FPSCameraOffset != new Vec3(0, 0, -0.5f))
            {
                Type.WalkMaxVelocity = 7;
                Type.WalkForce = 6000f;
                Type.FPSCameraOffset = new Vec3(0, 0, 0.5f);
                maincap.Length = length2;
                maincap.Position = Vec3.Zero;

                downcap.Length = Type.Height - Type.BottomRadius * 2;
                downcap.Position = new Vec3(0, 0,
                    (Type.Height - Type.WalkUpHeight) / 2 - Type.Height / 2);
            }
            TickRun();
            lastTickForceVector = forceVec;

            //Update Run energy
            if (EntitySystemWorld.Instance.IsServer() &&
              Type.NetworkType == EntityNetworkTypes.Synchronized)
            {
                Server_SendUpdateRunEnergyToClients(
                            EntitySystemWorld.Instance.RemoteEntityWorlds);
            }
        }
示例#35
0
        public ServerOrSingle_Player ServerOrSingle_GetPlayer( Intellect intellect )
        {
            if( intellect == null )
                Log.Fatal( "PlayerManager: ServerOrSingle_GetPlayerByIntellect: intellect == null." );

            //it is can be slowly. need to use Dictionary.
            foreach( ServerOrSingle_Player player in serverOrSingle_players )
            {
                if( player.Intellect == intellect )
                    return player;
            }
            return null;
        }
示例#36
0
        private void TickChassis()
        {
            bool onGround = leftTrack.onGround || rightTrack.onGround;

            float leftTrackThrottle  = 0;
            float rightTrackThrottle = 0;

            if (Intellect != null)
            {
                float forward = Intellect.GetControlKeyStrength(GameControlKeys.Forward);
                leftTrackThrottle  += forward;
                rightTrackThrottle += forward;

                float backward = Intellect.GetControlKeyStrength(GameControlKeys.Backward);
                leftTrackThrottle  -= backward;
                rightTrackThrottle -= backward;

                float left = Intellect.GetControlKeyStrength(GameControlKeys.Left);
                leftTrackThrottle  -= left * 2;
                rightTrackThrottle += left * 2;

                float right = Intellect.GetControlKeyStrength(GameControlKeys.Right);
                leftTrackThrottle  += right * 2;
                rightTrackThrottle -= right * 2;

                MathFunctions.Clamp(ref leftTrackThrottle, -1, 1);
                MathFunctions.Clamp(ref rightTrackThrottle, -1, 1);
            }

            //return if no throttle and sleeping
            if (chassisBody.Sleeping && rightTrackThrottle == 0 && leftTrackThrottle == 0)
            {
                return;
            }

            Vec3 localLinearVelocity = chassisBody.LinearVelocity * chassisBody.Rotation.GetInverse();

            //add drive force

            float slopeForwardForceCoeffient;
            float slopeBackwardForceCoeffient;
            float slopeLinearDampingAddition;

            {
                Vec3   dir        = chassisBody.Rotation.GetForward();
                Radian slopeAngle = MathFunctions.ATan(dir.Z, dir.ToVec2().Length());

                Radian maxAngle = MathFunctions.PI / 4;//new Degree(45)

                slopeForwardForceCoeffient = 1;
                if (slopeAngle > maxAngle)
                {
                    slopeForwardForceCoeffient = 0;
                }

                slopeBackwardForceCoeffient = 1;
                if (slopeAngle < -maxAngle)
                {
                    slopeBackwardForceCoeffient = 0;
                }

                MathFunctions.Clamp(ref slopeForwardForceCoeffient, 0, 1);
                MathFunctions.Clamp(ref slopeBackwardForceCoeffient, 0, 1);

                slopeLinearDampingAddition = localLinearVelocity.X > 0 ? slopeAngle : -slopeAngle;
                //slopeLinearDampingAddition *= 1;
                if (slopeLinearDampingAddition < 0)
                {
                    slopeLinearDampingAddition = 0;
                }
            }

            if (leftTrack.onGround)
            {
                if (leftTrackThrottle > 0 && localLinearVelocity.X < Type.MaxForwardSpeed)
                {
                    float force = localLinearVelocity.X > 0 ? Type.DriveForwardForce : Type.BrakeForce;
                    force *= leftTrackThrottle;
                    force *= slopeForwardForceCoeffient;
                    chassisBody.AddForce(ForceType.LocalAtLocalPos, TickDelta,
                                         new Vec3(force, 0, 0), new Vec3(0, tracksPositionYOffset, 0));
                }

                if (leftTrackThrottle < 0 && (-localLinearVelocity.X) < Type.MaxBackwardSpeed)
                {
                    float force = localLinearVelocity.X > 0 ? Type.BrakeForce : Type.DriveBackwardForce;
                    force *= leftTrackThrottle;
                    force *= slopeBackwardForceCoeffient;
                    chassisBody.AddForce(ForceType.LocalAtLocalPos, TickDelta,
                                         new Vec3(force, 0, 0), new Vec3(0, tracksPositionYOffset, 0));
                }
            }

            if (rightTrack.onGround)
            {
                if (rightTrackThrottle > 0 && localLinearVelocity.X < Type.MaxForwardSpeed)
                {
                    float force = localLinearVelocity.X > 0 ? Type.DriveForwardForce : Type.BrakeForce;
                    force *= rightTrackThrottle;
                    force *= slopeForwardForceCoeffient;
                    chassisBody.AddForce(ForceType.LocalAtLocalPos, TickDelta,
                                         new Vec3(force, 0, 0), new Vec3(0, -tracksPositionYOffset, 0));
                }

                if (rightTrackThrottle < 0 && (-localLinearVelocity.X) < Type.MaxBackwardSpeed)
                {
                    float force = localLinearVelocity.X > 0 ? Type.BrakeForce : Type.DriveBackwardForce;
                    force *= rightTrackThrottle;
                    force *= slopeBackwardForceCoeffient;
                    chassisBody.AddForce(ForceType.LocalAtLocalPos, TickDelta,
                                         new Vec3(force, 0, 0), new Vec3(0, -tracksPositionYOffset, 0));
                }
            }

            //LinearVelocity
            if (onGround && localLinearVelocity != Vec3.Zero)
            {
                Vec3 velocity = localLinearVelocity;
                velocity.Y = 0;
                chassisBody.LinearVelocity = chassisBody.Rotation * velocity;
            }

            bool stop = onGround && leftTrackThrottle == 0 && rightTrackThrottle == 0;

            bool noLinearVelocity  = chassisBody.LinearVelocity.Equals(Vec3.Zero, .2f);
            bool noAngularVelocity = chassisBody.AngularVelocity.Equals(Vec3.Zero, .2f);

            //LinearDamping
            float linearDamping;

            if (stop)
            {
                linearDamping = noLinearVelocity ? 5 : 1;
            }
            else
            {
                linearDamping = .15f;
            }
            chassisBody.LinearDamping = linearDamping + slopeLinearDampingAddition;

            //AngularDamping
            if (onGround)
            {
                if (stop && noAngularVelocity)
                {
                    chassisBody.AngularDamping = 5;
                }
                else
                {
                    chassisBody.AngularDamping = 1;
                }
            }
            else
            {
                chassisBody.AngularDamping = .15f;
            }

            //sleeping
            if (!chassisBody.Sleeping && stop && noLinearVelocity && noAngularVelocity)
            {
                chassisSleepTimer += TickDelta;
                if (chassisSleepTimer > 1)
                {
                    chassisBody.Sleeping = true;
                }
            }
            else
            {
                chassisSleepTimer = 0;
            }
        }
示例#37
0
        private void TickIntellect()
        {
            GUIshit();
            MapObjectAttachedParticle JetFire1 = GetFirstAttachedObjectByAlias("JetFire1") as MapObjectAttachedParticle;
            MapObjectAttachedParticle JetFire2 = GetFirstAttachedObjectByAlias("JetFire2") as MapObjectAttachedParticle;
            float speed = GetRealSpeed();

            AKunit akunit = GetPlayerUnit() as AKunit;

            Vec3   dir        = AKVTOLBody.Rotation.GetForward();
            Radian slopeAngle = MathFunctions.ATan(dir.Z, dir.ToVec2().Length());

            MASS = 0;
            foreach (Body body in PhysicsModel.Bodies)
            {
                MASS += body.Mass;
            }

            ShiftBooster();

            AKVTOLOn = Intellect != null && Intellect.IsActive();
            // GUItest();
            ALTray();

            //engine force + sound pitch control
            if (Intellect.IsControlKeyPressed(GameControlKeys.Jump))
            {
                if (akunit != null)
                {
                    akunit.GunsTryFire(false);
                }
            }

            if (Intellect.IsControlKeyPressed(GameControlKeys.Forward))
            {
                force += forceadd;
            }
            else if (Intellect.IsControlKeyPressed(GameControlKeys.Backward))
            {
                force -= forceadd;
            }
            else
            {
            }

            if (Intellect.IsControlKeyPressed(GameControlKeys.VerticleTakeOff_L_EngineUp))
            {
                EngineDir += 2f;
            }
            else if (Intellect.IsControlKeyPressed(GameControlKeys.VerticleTakeOff_L_EngineDown))
            {
                EngineDir -= 2f;
            }
            else
            {
            }

            MathFunctions.Clamp(ref EngineDir, 0, 90);

            EngineApp.Instance.ScreenGuiRenderer.AddText("Throttle: " + force, new Vec2(.6f, .1f));

            if (JetFire1 != null && JetFire2 != null)
            {
                if (force > 85f)
                {
                    JetFire1.Visible = true;
                    JetFire2.Visible = true;
                }
                else
                {
                    JetFire1.Visible = false;
                    JetFire2.Visible = false;
                }
            }

            enpitch = 0.8f + (0.6f * (force / 100));
            MathFunctions.Clamp(ref force, 0.1f, 100);
            MathFunctions.Clamp(ref enpitch, 0.8f, 1.4f);

            //update jet channel position and pitch
            if (rotorSoundChannel != null)
            {
                //update channel
                rotorSoundChannel.Pitch    = enpitch;
                rotorSoundChannel.Volume   = 1;
                rotorSoundChannel.Position = Position;
                //rotorSoundChannel.MinDistance = 10;
            }

            //end of engine force + sound pitch control

            //Forces
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            //start VTOL Pitch (Y turn)
            if (Intellect.IsControlKeyPressed(GameControlKeys.Arrow_Up) || Intellect.IsControlKeyPressed(GameControlKeys.Arrow_Down))
            {
                float AUp   = Intellect.GetControlKeyStrength(GameControlKeys.Arrow_Up) / 2;
                float ADown = Intellect.GetControlKeyStrength(GameControlKeys.Arrow_Down) / 2;
                Hpitch += (AUp - ADown);
                MathFunctions.Clamp(ref Hpitch, -10, 10);
            }
            else
            {
                if (Hpitch != 0)
                {
                    Hpitch -= Hpitch / 5;

                    if ((Hpitch - (Hpitch % 1)) == 0)
                    {
                        Hpitch = 0;
                    }
                }
                else
                {
                    float mammadpitch = (AKVTOLBody.AngularVelocity * AKVTOLBody.Rotation.GetInverse()).Y * 2;

                    MathFunctions.Clamp(ref mammadpitch, -10f, 10);
                    AKVTOLBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta,
                                        AKVTOLBody.Rotation * new Vec3(0, 0, -mammadpitch) * MASS, new Vec3(-8, 0, 0));

                    EngineApp.Instance.ScreenGuiRenderer.AddText("MammadPitch: " + mammadpitch.ToString(), new Vec2(.1f, .2f));
                }
            }

            if (Hpitch != 0)
            {
                AKVTOLBody.AddForce(ForceType.GlobalTorque, TickDelta,
                                    AKVTOLBody.Rotation * new Vec3(0, Hpitch, 0) * MASS, Vec3.Zero);
            }
            //end of VTOL pitch (Y turn)

            //start jet Z turn
            if (Intellect.IsControlKeyPressed(GameControlKeys.Right) || Intellect.IsControlKeyPressed(GameControlKeys.Left))
            {
                float right = Intellect.GetControlKeyStrength(GameControlKeys.Right) / 2;
                float left  = Intellect.GetControlKeyStrength(GameControlKeys.Left) / 2;
                TrunZ += (left - right);
                MathFunctions.Clamp(ref TrunZ, -10, 10);

                AKVTOLBody.AddForce(ForceType.LocalTorque, TickDelta,
                                    new Vec3(0, 0, TrunZ * 2) * MASS, Vec3.Zero);
            }
            else
            {
                TrunZ = 0;
            }
            //end of jet Z turn

            //start jet X turn
            if (Intellect.IsControlKeyPressed(GameControlKeys.Arrow_Right) || Intellect.IsControlKeyPressed(GameControlKeys.Arrow_Left))
            {
                float rightX = Intellect.GetControlKeyStrength(GameControlKeys.Arrow_Right) / 2;
                float leftX  = Intellect.GetControlKeyStrength(GameControlKeys.Arrow_Left) / 2;
                TrunX += (rightX - leftX);
                MathFunctions.Clamp(ref TrunX, -10, 10);

                AKVTOLBody.AddForce(ForceType.GlobalTorque, TickDelta,
                                    AKVTOLBody.Rotation * new Vec3(TrunX * 2, 0, 0) * MASS, Vec3.Zero);
            }
            else
            {
                TrunX = 0;
            }

            float SHOOT = AKVTOLBody.Rotation.GetInverse().ToAngles().Roll; //1 - Rotation.GetUp().Z;

            if (SHOOT < 0)
            {
                SHOOT = -SHOOT;
            }
            if (SHOOT > 90)
            {
                SHOOT = 90 - (SHOOT - 90);
            }

            AKVTOLBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta,
                                AKVTOLBody.Rotation * new Vec3(0, 0, -SHOOT / 180) * MASS, new Vec3(-8, 0, 0));

            //end of jet X turn

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //adding anty  Y movment force
            float Yshit = (AKVTOLBody.LinearVelocity * Rotation.GetInverse()).Y;

            EngineApp.Instance.ScreenGuiRenderer.AddText("Yshit: " + Yshit.ToString(), new Vec2(.6f, .3f));
            EngineApp.Instance.ScreenGuiRenderer.AddText("roll: " + Rotation.ToAngles().Roll, new Vec2(.6f, .35f));
            EngineApp.Instance.ScreenGuiRenderer.AddText("roll: " + (Rotation.GetInverse().ToAngles()).ToString(), new Vec2(.6f, .4f));
            EngineApp.Instance.ScreenGuiRenderer.AddText("Edir: " + EngineDir.ToString(), new Vec2(.1f, .6f));

            //start of adding force

            MathFunctions.Clamp(ref force, 0.1f, 100);

            EngineApp.Instance.ScreenGuiRenderer.AddText("speed: " + GetRealSpeed().ToString(), new Vec2(.6f, .15f));
            GUItest();
            //anti gravity when jet have speed (wings force)

            float antyshityforcy = GetRealSpeed() / 10;

            float slopeangleshit = 1.5f;

            MathFunctions.Clamp(ref antyshityforcy, 0, 10);
            if (slopeAngle > 0)
            {
                slopeangleshit = 1.5f - slopeAngle;
            }
            else
            {
                slopeangleshit = 0.5f;
            }

            if (GetRealSpeed() > 0)
            {
                AKVTOLBody.AddForce(ForceType.LocalAtLocalPos, TickDelta,
                                    new Vec3(0, 0, antyshityforcy * slopeangleshit) * MASS, Vec3.Zero);
            }

            //if Max Alt is not reached add jet motor force
            if (AKVTOLBody.Position.Z < Type.MaxAlt)
            {
                AKVTOLBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta,
                                    AKVTOLBody.Rotation * new Vec3(force / 2f * ((90 - EngineDir) / 90), 0, force / 8f * (EngineDir / 90)) * MASS, Vec3.Zero);
            }

            //dampings
            AKVTOLBody.AngularDamping = 2f + (speed / 60);
            AKVTOLBody.LinearDamping  = 0.6f;

            ServoMotor Lenginem = PhysicsModel.GetMotor("LEngineM") as ServoMotor;
            ServoMotor Renginem = PhysicsModel.GetMotor("REngineM") as ServoMotor;

            if (Lenginem != null && Renginem != null)
            {
                float EngingDirRad = EngineDir * MathFunctions.PI / 180;
                Renginem.DesiredAngle = EngingDirRad;
                Lenginem.DesiredAngle = EngingDirRad;
            }
        }
示例#38
0
        protected override void OnIntellectCommand(Intellect.Command command)
        {
            base.OnIntellectCommand(command);
            /*
                        if (EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle())
                        {
                            //if (command.KeyPressed)
                            //{
                            //    //add special key commands here like jump or turret loading
                            //    if (command.Key == GameControlKeys.UpdatePhysics)
                            //    {
                            //        CheckPhysicsProperties();
                            //    }

                            //    if (command.Key == GameControlKeys.SetMiniTurret)
                            //    {
                            //        if (activeturrets < activeMaxTurrets)
                            //        {
                            //            activeturrets++;
                            //            SetMiniTurret(this as Unit);
                            //        }
                            //    }

                            //    if (command.Key == GameControlKeys.RemoveMiniTurret)
                            //    {
                            //        if (activeturrets <= activeMaxTurrets && turretTimer >= TURRETMAXOUT)
                            //        {
                            //            RemoveMiniTurret(this as Unit);
                            //            turretTimer = 0f; //reset timer
                            //        }
                            //    }
                            //}
                        }
             */
        }
示例#39
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnDeleteSubscribedToDeletionEvent(Entity)"/></summary>
        protected override void OnDeleteSubscribedToDeletionEvent(Entity entity)
        {
            base.OnDeleteSubscribedToDeletionEvent(entity);

            if (intellect == entity)
                intellect = null;
        }
示例#40
0
 public void DoIntellectCommand(Intellect.Command command)
 {
     OnIntellectCommand(command);
 }
示例#41
0
		protected override void OnIntellectCommand( Intellect.Command command )
		{
			base.OnIntellectCommand( command );

			if( EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle() )
			{
				if( Type.JumpSupport && command.KeyPressed && command.Key == GameControlKeys.Jump )
					TryJump();
			}
		}
示例#42
0
 protected virtual void OnIntellectCommand(Intellect.Command command)
 {
 }
示例#43
0
		protected override void OnIntellectCommand( Intellect.Command command )
		{
			base.OnIntellectCommand( command );

			if( ( EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle() ) && physicsVehicle != null )
			{
				bool gearUp = command.KeyPressed && command.Key == GameControlKeys.VehicleGearUp;
				bool gearDown = command.KeyPressed && command.Key == GameControlKeys.VehicleGearDown;
				if( gearUp || gearDown )
				{
					int currentGear = physicsVehicle.GetCurrentGear();
					int targetGear = physicsVehicle.GetTargetGear();

					if( gearUp )
					{
						if( !AutoGear || ( AutoGear && currentGear <= 0 && currentGear == targetGear ) )
							physicsVehicle.StartGearChange( currentGear + 1 );
					}
					if( gearDown )
					{
						if( !AutoGear || ( AutoGear && currentGear >= 0 && currentGear == targetGear ) )
							physicsVehicle.StartGearChange( currentGear - 1 );
					}
				}
			}
		}
示例#44
0
        private void TickIntellect()
        {
            //GUItest();
            JetEngineBooster();

            VSI = AKJetBody.LinearVelocity.Z - (AKJetBody.LinearVelocity.Z % 1);
            float speed = GetRealSpeed();
            float ControlersRatio;

            MapObjectAttachedParticle ENBoosterParticle2 = GetFirstAttachedObjectByAlias("JetFire") as MapObjectAttachedParticle;
            AKunit akunit = GetPlayerUnit() as AKunit;

            Vec3 dir = AKJetBody.Rotation.GetForward();

            AKJetOn = Intellect != null && Intellect.IsActive();

            MASS = 0;
            foreach (Body body in PhysicsModel.Bodies)
            {
                MASS += body.Mass;
            }

            // controlers Ratio
            if (speed > 0)
            {
                ControlersRatio = speed / 80;
                if (ControlersRatio > 1)
                {
                    ControlersRatio = 1;
                }
            }
            else
            {
                ControlersRatio = 0;
            }
            // controlers Ratio

            //////////////////////// WING WING WING WING WING WING WING WING WING WING WING /////////////////////////////////
            //wing General
            Angles BodyAngles = Rotation.GetInverse().ToAngles();

            float normalizeRoll = BodyAngles.Roll;

            if (normalizeRoll < 0)
            {
                normalizeRoll = -normalizeRoll;
            }

            float PitchUp = -BodyAngles.Pitch;

            if (PitchUp < 0)
            {
                PitchUp = 0;
            }

            if (PitchUp > 90)
            {
                PitchUp = 90 - (PitchUp - 90);
            }

            float PitchDown = BodyAngles.Pitch;

            if (PitchDown < 0)
            {
                PitchDown = 0;
            }

            if (PitchDown > 90)
            {
                PitchDown = 90 - (PitchDown - 90);
            }

            //End of Wing GENERAL

            //Wing Anti Gravity Force & Stall
            float WingUpForce;

            if (speed < 40f)
            {
                //stall
                if (VSI < 0 && PitchUp > 35f)
                {
                    Stall = true;
                }
                else
                {
                    Stall = false;
                }

                //force
                WingUpForce = ((speed / 4f) - 0.2f);
            }
            else if (speed > 40f)
            {
                WingUpForce = -PhysicsWorld.Instance.MainScene.Gravity.Z;
                //WingUpForce = 9.8f; //TODO:Incin change to map gravity
            }
            else
            {
                WingUpForce = 0;
            }

            //antigrav
            AKJetBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta,
                               AKJetBody.Rotation * new Vec3(0, 0, WingUpForce) * MASS, Vec3.Zero);

            //antivelo
            AKJetBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta,
                               AKJetBody.Rotation * new Vec3((-WingUpForce * PitchUp / 9) / 4, 0, 0) * MASS, Vec3.Zero);

            //END oF Wing Anit Gravity Force & Stall
            //Wing Decenging Force

            float DecendSpeedForce;

            if (VSI < 0 && PitchUp == 0)
            {
                DecendSpeedForce = (180 - normalizeRoll) + PitchDown;

                AKJetBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta,
                                   AKJetBody.Rotation * new Vec3(DecendSpeedForce / 20, 0, 0) * MASS, Vec3.Zero);
            }

            //End of Wing Decenging Force
            /////// END END END ///OF OF OF/// WING WING WING WING WING WING WING WING WING WING WING //////////////////////////////

            //engine force + sound pitch control
            if (Intellect.IsControlKeyPressed(GameControlKeys.Jump))
            {
                if (akunit != null)
                {
                    akunit.GunsTryFire(false);
                }
            }

            if (Intellect.IsControlKeyPressed(GameControlKeys.Forward))
            {
                force += forceadd;
            }
            if (Intellect.IsControlKeyPressed(GameControlKeys.Backward))
            {
                force -= forceadd;
            }

            if (ENBoosterParticle2 != null)
            {
                if (force > 85f)
                {
                    ENBoosterParticle2.Visible = true;
                }
                else
                {
                    ENBoosterParticle2.Visible = false;
                }
            }

            enpitch = (force / 80f);
            MathFunctions.Clamp(ref force, 0.1f, 100);
            MathFunctions.Clamp(ref enpitch, 0.8f, 1.3f);

            //update jet channel position and pitch
            if (rotorSoundChannel != null)
            {
                //update channel
                rotorSoundChannel.Pitch    = enpitch;
                rotorSoundChannel.Volume   = 1;
                rotorSoundChannel.Position = Position;
                //rotorSoundChannel.MinDistance = 10;
            }

            //end of engine force + sound pitch control

            //Forces
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            //start jet Pitch (Y turn)
            if (Intellect.IsControlKeyPressed(GameControlKeys.Arrow_Up) || Intellect.IsControlKeyPressed(GameControlKeys.Arrow_Down))
            {
                float AUp   = Intellect.GetControlKeyStrength(GameControlKeys.Arrow_Up) / 2;
                float ADown = Intellect.GetControlKeyStrength(GameControlKeys.Arrow_Down) / 2;
                Hpitch += (AUp - ADown);
                MathFunctions.Clamp(ref Hpitch, -10, 10);
            }
            else
            {
                if (Hpitch != 0)
                {
                    Hpitch -= Hpitch / 5;

                    if ((Hpitch - (Hpitch % 1)) == 0)
                    {
                        Hpitch = 0;
                    }
                }
                else
                {
                    float mammadpitch = (AKJetBody.AngularVelocity * AKJetBody.Rotation.GetInverse()).Y * 2;

                    MathFunctions.Clamp(ref mammadpitch, -10f, 10);
                    AKJetBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta,
                                       AKJetBody.Rotation * new Vec3(0, 0, -mammadpitch) * MASS, new Vec3(-8, 0, 0));
                }
            }

            if (Hpitch != 0)
            {
                AKJetBody.AddForce(ForceType.GlobalTorque, TickDelta,
                                   AKJetBody.Rotation * new Vec3(0, ((Hpitch) * ControlersRatio), 0) * MASS, Vec3.Zero);
            }
            //end of jet pitch (Y turn)

            //start jet Z turn
            if (Intellect.IsControlKeyPressed(GameControlKeys.Right) || Intellect.IsControlKeyPressed(GameControlKeys.Left))
            {
                float right = Intellect.GetControlKeyStrength(GameControlKeys.Right) / 2;
                float left  = Intellect.GetControlKeyStrength(GameControlKeys.Left) / 2;
                TrunZ += (left - right);
                MathFunctions.Clamp(ref TrunZ, -10, 10);
            }
            else
            {
                if (TrunZ != 0)
                {
                    TrunZ -= TrunZ / 5;

                    if ((TrunZ - (TrunZ % 1)) == 0)
                    {
                        TrunZ = 0;
                    }
                }
            }

            if (TrunZ != 0)
            {
                AKJetBody.AddForce(ForceType.GlobalTorque, TickDelta,
                                   AKJetBody.Rotation * new Vec3(0, 0, (TrunZ * 2) * ControlersRatio) * MASS, Vec3.Zero);
            }
            //end of jet Z turn

            //start jet X turn
            if (Intellect.IsControlKeyPressed(GameControlKeys.Arrow_Right) || Intellect.IsControlKeyPressed(GameControlKeys.Arrow_Left))
            {
                float rightX = Intellect.GetControlKeyStrength(GameControlKeys.Arrow_Right) / 2;
                float leftX  = Intellect.GetControlKeyStrength(GameControlKeys.Arrow_Left) / 2;
                TrunX += (rightX - leftX);
                MathFunctions.Clamp(ref TrunX, -10, 10);
            }
            else
            {
                if (TrunX != 0)
                {
                    TrunX -= TrunX / 5;

                    if ((TrunX - (TrunX % 1)) == 0)
                    {
                        TrunX = 0;
                    }
                }
            }

            if (TrunX != 0)
            {
                AKJetBody.AddForce(ForceType.GlobalTorque, TickDelta,
                                   AKJetBody.Rotation * new Vec3(((TrunX * 2) * ControlersRatio), 0, 0) * MASS, Vec3.Zero);
            }

            //Pitch on Turn Pitch

            //float TurnPitch = AKJetBody.Rotation.GetInverse().ToAngles().Roll; //1 - Rotation.GetUp().Z;
            //if (TurnPitch < 0) TurnPitch = -TurnPitch;
            //if (TurnPitch > 90) TurnPitch = 90 - (TurnPitch - 90);

            //AKJetBody.AddForce(ForceType.GlobalTorque, TickDelta,
            //       AKJetBody.Rotation * new Vec3(0, ((-TurnPitch /90) * ControlersRatio), 0) * MASS, Vec3.Zero);

            //End of Pitch on Turn
            //end of jet X turn

            //start of adding main Engine force

            MathFunctions.Clamp(ref force, 0.1f, 100);

            //if Max Alt is not reached add jet motor force
            if (AKJetBody.Position.Z < Type.MaxAlt)
            {
                float FinalEngineForce = (force / 2f) - ((PitchUp / 90) * 30);

                AKJetBody.AddForce(ForceType.LocalAtLocalPos, TickDelta,
                                   new Vec3(FinalEngineForce, 0, 0) * MASS, Vec3.Zero);
            }

            //dampings
            AKJetBody.AngularDamping = 2f + (speed / 60);
            AKJetBody.LinearDamping  = 0.4f;
        }