Esempio n. 1
0
        public void UpdateTankFalling(FixedUpdateEvent evt, FallingTankNode tank)
        {
            TankFallingComponent   tankFalling   = tank.tankFalling;
            TrackComponent         track         = tank.track;
            RigidbodyComponent     rigidbody     = tank.rigidbody;
            TankCollisionComponent tankCollision = tank.tankCollision;
            ChassisConfigComponent chassisConfig = tank.chassisConfig;
            Entity  tankEntity        = tank.Entity;
            int     trackContacts     = this.GetTrackContacts(track);
            int     collisionContacts = this.GetCollisionContacts(tankCollision);
            int     num5 = collisionContacts - tankFalling.PreviousCollisionContactsCount;
            int     deltaTrackContacts = trackContacts - tankFalling.PreviousTrackContactsCount;
            Vector3 previousVelocity   = tankFalling.PreviousVelocity;

            tankFalling.PreviousCollisionContactsCount = collisionContacts;
            tankFalling.PreviousTrackContactsCount     = trackContacts;
            tankFalling.PreviousVelocity = rigidbody.Rigidbody.velocity;
            if (deltaTrackContacts > 0)
            {
                this.ApplyFall(tankEntity, previousVelocity, tankFalling, track, chassisConfig, tankCollision, rigidbody, true);
            }
            else if ((num5 > 0) && (trackContacts == 0))
            {
                this.ApplyFall(tankEntity, previousVelocity, tankFalling, track, chassisConfig, tankCollision, rigidbody, false);
            }
            else
            {
                this.UpdateGroundedStatus(tankFalling, deltaTrackContacts, collisionContacts, trackContacts);
            }
        }
Esempio n. 2
0
 private void UpdateRigidbody(Movement move, RigidbodyComponent rigidbody)
 {
     if (rigidbody.Rigidbody)
     {
         rigidbody.RigidbodyTransform.SetPositionSafe(move.Position);
         rigidbody.RigidbodyTransform.SetRotationSafe(move.Orientation);
         rigidbody.Rigidbody.SetVelocitySafe(move.Velocity);
         rigidbody.Rigidbody.SetAngularVelocitySafe(move.AngularVelocity);
     }
 }
Esempio n. 3
0
        public void Instantiate(NodeAddedEvent e, SingleNode <PreloadedModuleEffectsComponent> mapEffect, SingleNode <MapInstanceComponent> map, [Combine] DroneLoadedNode drone, [Context, JoinByUser] TankNode tank, [JoinByTank] SingleNode <TankIncarnationComponent> incarnation, [JoinByUser] Optional <SingleNode <UserAvatarComponent> > avatar)
        {
            string     str      = (!avatar.IsPresent() || (avatar.Get().component.Id != "457e8f5f-953a-424c-bd97-67d9e116ab7a")) ? "drone" : "droneHolo";
            GameObject original = mapEffect.component.PreloadedEffects[str];

            if (original)
            {
                GameObject gameObject = Object.Instantiate <GameObject>(original, null);
                gameObject.SetActive(true);
                Rigidbody          rigidbody = gameObject.GetComponent <Rigidbody>();
                RigidbodyComponent component = new RigidbodyComponent {
                    Rigidbody = rigidbody
                };
                drone.Entity.AddComponent(component);
                rigidbody.GetComponent <EntityBehaviour>().BuildEntity(drone.Entity);
                DroneOwnerComponent component2 = new DroneOwnerComponent {
                    Incarnation = incarnation.Entity,
                    Rigidbody   = tank.rigidbody.Rigidbody
                };
                drone.Entity.AddComponent(component2);
                drone.Entity.AddComponent(new EffectInstanceComponent(gameObject));
            }
        }
Esempio n. 4
0
 private void ApplyFall(Entity tankEntity, Vector3 previousVelocity, TankFallingComponent tankFalling, TrackComponent track, ChassisConfigComponent chassisConfig, TankCollisionComponent tankCollision, RigidbodyComponent rigidbody, bool fallingByTrack)
 {
     if ((tankFalling != null) && (!tankFalling.IsGrounded && rigidbody.Rigidbody))
     {
         bool            flag;
         Vector3         planeNormal   = this.GetFallingNrm(fallingByTrack, track, chassisConfig, tankCollision, out flag);
         Vector3         vector2       = Vector3.ProjectOnPlane(previousVelocity, planeNormal);
         Vector3         position      = rigidbody.Rigidbody.transform.position;
         TankFallingType type          = this.DefineFallingCollisionMode(flag, fallingByTrack, planeNormal);
         TankFallEvent   eventInstance = new TankFallEvent {
             FallingPower = (previousVelocity - vector2).sqrMagnitude,
             FallingType  = type,
             Velocity     = previousVelocity
         };
         if ((type == TankFallingType.SLOPED_STATIC_WITH_COLLISION) && this.CheckTankCollisionNotNull(tankCollision))
         {
             eventInstance.FallingTransform = tankCollision.Collision.transform;
         }
         base.ScheduleEvent(eventInstance, tankEntity);
         tankFalling.IsGrounded = true;
     }
 }