Example #1
0
        public void Draw(int onCount, bool sphereOnCamera)
        {
            _onCount = onCount;

            var renderId    = MyGrid.Render.GetRenderObjectID();
            var percent     = DsState.State.ShieldPercent;
            var reInforce   = DsState.State.ReInforce;
            var hitAnim     = !reInforce && DsSet.Settings.HitWaveAnimation;
            var refreshAnim = !reInforce && DsSet.Settings.RefreshAnimation;

            var activeVisible = DetermineVisualState(reInforce);

            var impactPos = WorldImpactPosition;
            var webEffect = WebDamage && BulletCoolDown > -1 && WebCoolDown < 0;

            _localImpactPosition = Vector3D.NegativeInfinity;
            if (impactPos != Vector3D.NegativeInfinity && (BulletCoolDown < 0 || webEffect))
            {
                if (webEffect)
                {
                    WebCoolDown = 0;
                    HitParticleStart();
                }
                else
                {
                    if (WebDamage)
                    {
                        WebCoolDown = 0;
                    }
                    BulletCoolDown = 0;
                    HitParticleStart();
                    var cubeBlockLocalMatrix   = MyGrid.PositionComp.LocalMatrix;
                    var referenceWorldPosition = cubeBlockLocalMatrix.Translation;
                    var worldDirection         = impactPos - referenceWorldPosition;
                    var localPosition          = Vector3D.TransformNormal(worldDirection, MatrixD.Transpose(cubeBlockLocalMatrix));
                    _localImpactPosition = localPosition;
                }
            }

            WorldImpactPosition = Vector3D.NegativeInfinity;
            WebDamage           = false;

            if (IsWorking)
            {
                var prevlod = _prevLod;
                var lod     = CalculateLod(_onCount);
                if (_shapeChanged || _updateRender || lod != prevlod)
                {
                    Icosphere.CalculateTransform(ShieldShapeMatrix, lod);
                    if (!GridIsMobile)
                    {
                        Icosphere.ReturnPhysicsVerts(DetectionMatrix, ShieldComp.PhysicsOutside);
                    }
                }
                Icosphere.ComputeEffects(ShieldShapeMatrix, _localImpactPosition, _shellPassive, _shellActive, prevlod, percent, activeVisible, refreshAnim);
            }
            if (hitAnim && sphereOnCamera && IsWorking)
            {
                Icosphere.Draw(renderId);
            }

            _updateRender = false;
            _shapeChanged = false;
        }
Example #2
0
        public void Draw(int onCount, bool sphereOnCamera)
        {
            _onCount = onCount;

            var renderId    = MyGrid.Render.GetRenderObjectID();
            var percent     = DsState.State.ShieldPercent;
            var reInforce   = DsState.State.ReInforce;
            var hitAnim     = !reInforce && DsSet.Settings.HitWaveAnimation;
            var refreshAnim = !reInforce && DsSet.Settings.RefreshAnimation;

            Vector3D impactPos;

            lock (HandlerImpact) impactPos = HandlerImpact.Active ? ComputeHandlerImpact() : WorldImpactPosition;
            var intersected = WorldImpactPosition != Vector3D.NegativeInfinity && impactPos != Vector3D.Zero;

            WorldImpactPosition = impactPos;
            var activeVisible = DetermineVisualState(reInforce);

            WorldImpactPosition = Vector3D.NegativeInfinity;

            var kineticHit = EnergyHit == HitType.Kinetic;

            _localImpactPosition = Vector3D.NegativeInfinity;

            if (impactPos != Vector3D.NegativeInfinity && (kineticHit && KineticCoolDown < 0 || EnergyHit == HitType.Energy && EnergyCoolDown < 0))
            {
                if (_isServer && WebDamage && GridIsMobile)
                {
                    Vector3 pointVel;
                    var     gridCenter = MyGrid.PositionComp.WorldAABB.Center;
                    MyGrid.Physics.GetVelocityAtPointLocal(ref gridCenter, out pointVel);
                    impactPos += (Vector3D)pointVel * Session.TwoStep;
                }

                if (kineticHit)
                {
                    KineticCoolDown = 0;
                }
                else if (EnergyHit == HitType.Energy)
                {
                    EnergyCoolDown = 0;
                }

                if (EnergyHit != HitType.Other)
                {
                    HitParticleStart(impactPos, intersected);
                }

                var cubeBlockLocalMatrix   = MyGrid.PositionComp.LocalMatrix;
                var referenceWorldPosition = cubeBlockLocalMatrix.Translation;
                var worldDirection         = impactPos - referenceWorldPosition;
                var localPosition          = Vector3D.TransformNormal(worldDirection, MatrixD.Transpose(cubeBlockLocalMatrix));
                _localImpactPosition = localPosition;
            }

            EnergyHit = HitType.Kinetic;

            if (DsState.State.Online)
            {
                var prevlod = _prevLod;
                var lod     = CalculateLod(_onCount);
                if (_shapeChanged || _updateRender || lod != prevlod)
                {
                    _updateRender = false;
                    _shapeChanged = false;

                    Icosphere.CalculateTransform(ShieldShapeMatrix, lod);
                    if (!GridIsMobile)
                    {
                        Icosphere.ReturnPhysicsVerts(DetectionMatrix, ShieldComp.PhysicsOutside);
                    }
                }
                Icosphere.ComputeEffects(ShieldShapeMatrix, _localImpactPosition, _shellPassive, _shellActive, prevlod, percent, activeVisible, refreshAnim);
            }
            else if (_shapeChanged)
            {
                _updateRender = true;
            }

            if (hitAnim && sphereOnCamera && DsState.State.Online)
            {
                Icosphere.Draw(renderId);
            }
        }
Example #3
0
        public void Draw(int onCount, bool sphereOnCamera)
        {
            _onCount = onCount;

            var renderId  = MyGrid.Render.GetRenderObjectID();
            var percent   = DsState.State.ShieldPercent;
            var reInforce = DsState.State.ReInforce;
            //var hitAnim = !reInforce && DsSet.Settings.HitWaveAnimation;

            Vector3D impactPos;

            lock (HandlerImpact) impactPos = HandlerImpact.Active ? ComputeHandlerImpact() : WorldImpactPosition;
            var intersected = WorldImpactPosition != Vector3D.NegativeInfinity && impactPos != Vector3D.Zero;

            WorldImpactPosition = impactPos;
            var activeVisible = DetermineVisualState(reInforce);

            WorldImpactPosition = Vector3D.NegativeInfinity;

            var vanillaHit = EnergyHit != HitType.Other;
            var kineticHit = EnergyHit == HitType.Kinetic;

            _localImpactPosition = Vector3D.NegativeInfinity;

            if (impactPos != Vector3D.NegativeInfinity && (kineticHit && KineticCoolDown < 0 || EnergyHit == HitType.Energy && EnergyCoolDown < 0 || EnergyHit == HitType.Other))
            {
                if (_isServer && WebDamage && GridIsMobile)
                {
                    Vector3 pointVel;
                    var     gridCenter = DetectionCenter;
                    MyGrid.Physics.GetVelocityAtPointLocal(ref gridCenter, out pointVel);
                    impactPos += (Vector3D)pointVel * Session.TwoStep;
                }

                if (kineticHit)
                {
                    KineticCoolDown = 0;
                }
                else if (EnergyHit == HitType.Energy)
                {
                    EnergyCoolDown = 0;
                }

                if (EnergyHit != HitType.Other)
                {
                    HitParticleStart(impactPos, intersected);
                }

                var cubeBlockLocalMatrix   = MyGrid.PositionComp.LocalMatrixRef;
                var referenceWorldPosition = cubeBlockLocalMatrix.Translation;
                var worldDirection         = impactPos - referenceWorldPosition;
                var localPosition          = Vector3D.TransformNormal(worldDirection, MatrixD.Transpose(cubeBlockLocalMatrix));
                _localImpactPosition = localPosition;
            }

            EnergyHit = HitType.Kinetic;

            if (DsState.State.Online)
            {
                var prevlod = _prevLod;
                var lod     = CalculateLod(_onCount);
                if (_shapeChanged || _updateRender || lod != prevlod)
                {
                    _updateRender = false;
                    _shapeChanged = false;

                    Icosphere.CalculateTransform(ShieldShapeMatrix, lod);
                    if (!GridIsMobile)
                    {
                        Icosphere.ReturnPhysicsVerts(DetectionMatrix, ShieldComp.PhysicsOutside);
                    }
                }
                Icosphere.ComputeEffects(this, _localImpactPosition, prevlod, percent, activeVisible);
            }
            else if (_shapeChanged)
            {
                _updateRender = true;
            }

            var startPulse = Session.Instance.Tick20 && _toggle;
            var updated    = Session.Instance.Tick300 || startPulse;
            var wasPulsing = _sidePulsing;

            if (updated && ShellActive != null && RedirectVisualUpdate())
            {
                UpdateShieldRedirectVisuals();
            }

            if (ShellActive != null && _sidePulsing)
            {
                SidePulseRender();
            }

            if (wasPulsing && !_sidePulsing)
            {
                ClearSidePulse();
            }


            if (sphereOnCamera && DsState.State.Online && Session.Instance.Settings.ClientConfig.ShowHitRings || vanillaHit)
            {
                Icosphere.Draw(renderId, this);
            }
        }