Ejemplo n.º 1
0
        public void Impact(ImpactEvent evt, TankNode tank)
        {
            Rigidbody rigidbody = tank.rigidbody.Rigidbody;
            Vector3   position  = MathUtil.LocalPositionToWorldPosition(evt.LocalHitPoint, rigidbody.gameObject);

            rigidbody.AddForceAtPositionSafe(evt.Force, position);
        }
Ejemplo n.º 2
0
        private void CalculateAndSendSplashImpactEffectByBaseEvent(List <HitTarget> splashTargets, StaticHit staticHit, List <HitTarget> targets, SplashImpactNode weapon, TankPhysicsNode tank)
        {
            SplashImpactComponent splashImpact = weapon.splashImpact;
            SplashWeaponComponent splashWeapon = weapon.splashWeapon;
            Vector3 vector = (staticHit == null) ? targets[0].TargetPosition : staticHit.Position;
            float   impactWeakeningByRange = 1f;

            if (weapon.Entity.HasComponent <DamageWeakeningByDistanceComponent>())
            {
                float magnitude = (tank.rigidBody.Rigidbody.position - vector).magnitude;
                impactWeakeningByRange = base.GetImpactWeakeningByRange(magnitude, weapon.Entity.GetComponent <DamageWeakeningByDistanceComponent>());
            }
            foreach (HitTarget target in splashTargets)
            {
                float       hitDistance = target.HitDistance;
                float       splashImpactWeakeningByRange = this.GetSplashImpactWeakeningByRange(hitDistance, splashWeapon);
                ImpactEvent eventInstance = new ImpactEvent();
                Vector3     vector4       = (Vector3.Normalize(target.HitDirection) * splashImpact.ImpactForce) * WeaponConstants.WEAPON_FORCE_MULTIPLIER;
                eventInstance.Force          = (vector4 * impactWeakeningByRange) * splashImpactWeakeningByRange;
                eventInstance.LocalHitPoint  = target.LocalHitPoint;
                eventInstance.WeakeningCoeff = splashImpactWeakeningByRange;
                Entity[] entities = new Entity[] { weapon.Entity, target.Entity };
                base.NewEvent(eventInstance).AttachAll(entities).Schedule();
            }
        }
Ejemplo n.º 3
0
        protected void PrepareImpactForHitTarget(Entity weaponDamager, HitTarget target, float maxImpactForce, float weakeningCoeff = 1f)
        {
            ImpactEvent eventInstance = new ImpactEvent {
                Force          = ((Vector3.Normalize(target.HitDirection) * maxImpactForce) * WeaponConstants.WEAPON_FORCE_MULTIPLIER) * weakeningCoeff,
                LocalHitPoint  = target.LocalHitPoint,
                WeakeningCoeff = weakeningCoeff
            };

            Entity[] entities = new Entity[] { target.Entity, weaponDamager };
            base.NewEvent(eventInstance).AttachAll(entities).Schedule();
        }
Ejemplo n.º 4
0
        protected void ApplyImpactByTargetWeakening(Entity weaponDamager, List <HitTarget> targets, float forceVal, float weakeningByTargetPercent)
        {
            float num   = 1f;
            float num2  = weakeningByTargetPercent * 0.01f;
            int   count = targets.Count;

            for (int i = 0; i < count; i++)
            {
                HitTarget   target        = targets[i];
                ImpactEvent eventInstance = new ImpactEvent();
                Vector3     vector        = (Vector3.Normalize(target.HitDirection) * forceVal) * WeaponConstants.WEAPON_FORCE_MULTIPLIER;
                eventInstance.Force          = vector * num;
                eventInstance.LocalHitPoint  = target.LocalHitPoint;
                eventInstance.WeakeningCoeff = num;
                num *= num2;
                Entity[] entities = new Entity[] { weaponDamager, target.Entity };
                base.NewEvent(eventInstance).AttachAll(entities).Schedule();
            }
        }
Ejemplo n.º 5
0
        public void EffectAdded(NodeAddedEvent e, JumpEffectNode node, [JoinByTank] TankNode tank)
        {
            GameObject jumpImpactEffect = tank.moduleVisualEffectObjects.JumpImpactEffect;

            if (!jumpImpactEffect.activeInHierarchy)
            {
                jumpImpactEffect.transform.position = tank.rigidbody.RigidbodyTransform.position;
                jumpImpactEffect.SetActive(true);
            }
            Rigidbody   rigidbody     = tank.rigidbody.Rigidbody;
            float       num           = node.jumpEffect.BaseImpact * node.jumpEffectConfig.ForceUpgradeMult;
            float       num2          = !node.jumpEffect.ScaleByMass ? 1f : (rigidbody.mass / 3000f);
            float       num3          = (node.jumpEffect.GravityPenalty * (1f - (Physics.gravity.magnitude / 9.8f))) * num;
            Vector3     vector2       = !node.jumpEffect.AlwaysUp ? ((Vector3)(rigidbody.rotation * Vector3.up)) : Vector3.up;
            ImpactEvent eventInstance = new ImpactEvent {
                LocalHitPoint = rigidbody.centerOfMass,
                Force         = (Vector3)((num2 * (num - num3)) * vector2)
            };

            base.ScheduleEvent(eventInstance, tank);
        }