コード例 #1
0
        private void SidePulseRender()
        {
            if (!_pulseIncrease && _pulseCounter-- <= 0)
            {
                _pulseIncrease = true;
                _pulseCounter  = 0;
            }
            else if (_pulseIncrease && _pulseCounter++ >= 9)
            {
                _pulseIncrease = false;
                _pulseCounter  = 9;
            }

            foreach (var key in RealSideStates)
            {
                var             side    = key.Key;
                var             enabled = key.Value.Redirected;
                MyEntitySubpart part;
                if (ShellActive.TryGetSubpart(Session.Instance.ShieldShuntedSides[side], out part))
                {
                    if (enabled)
                    {
                        part.Render.Transparency = _pulseCounter * 0.1f;
                        part.Render.UpdateTransparency();
                    }
                }
            }
        }
コード例 #2
0
        public void UpdateShieldRedirectVisuals()
        {
            bool shunting = false;

            foreach (var key in RealSideStates)
            {
                var             side    = key.Key;
                var             enabled = key.Value.Redirected;
                MyEntitySubpart part;
                if (ShellActive.TryGetSubpart(Session.Instance.ShieldShuntedSides[side], out part))
                {
                    var shunted = enabled && _toggle;
                    if (shunted)
                    {
                        shunting = true;
                    }

                    RenderingSides[side] = shunted;
                    part.Render.UpdateRenderObject(shunted);
                }
            }
            _sidePulsing = shunting;
        }
コード例 #3
0
ファイル: ShieldInit.cs プロジェクト: wellstat/DefenseShields
        private void InitEntities(bool fullInit)
        {
            if (ShieldEnt != null)
            {
                Session.Instance.IdToBus.Remove(ShieldEnt.EntityId);
                ShieldEnt.Close();
            }
            ShellActive?.Close();
            _shellPassive?.Close();

            if (!fullInit)
            {
                if (Session.Enforced.Debug == 3)
                {
                    Log.Line($"InitEntities: mode: {ShieldMode}, remove complete - ShieldId [{Shield.EntityId}]");
                }
                return;
            }

            SelectPassiveShell();
            var parent = (MyEntity)MyGrid;

            if (!_isDedicated)
            {
                _shellPassive = Spawn.EmptyEntity("dShellPassive", $"{Session.Instance.ModPath()}{_modelPassive}", parent, true);
                _shellPassive.Render.CastShadows = false;
                _shellPassive.IsPreview          = true;
                _shellPassive.Render.Visible     = true;
                _shellPassive.Render.RemoveRenderObjects();
                _shellPassive.Render.UpdateRenderObject(true);
                _shellPassive.Render.UpdateRenderObject(false);
                _shellPassive.Save     = false;
                _shellPassive.SyncFlag = false;
                _shellPassive.RemoveFromGamePruningStructure();

                ShellActive = Spawn.EmptyEntity("dShellActive", $"{Session.Instance.ModPath()}{_modelActive}", parent, true);
                ShellActive.Render.CastShadows = false;
                ShellActive.IsPreview          = true;
                ShellActive.Render.Visible     = true;
                ShellActive.Render.RemoveRenderObjects();
                ShellActive.Render.UpdateRenderObject(true);
                ShellActive.Render.UpdateRenderObject(false);
                ShellActive.Save     = false;
                ShellActive.SyncFlag = false;
                ShellActive.SetEmissiveParts("ShieldEmissiveAlpha", Color.Transparent, 0f);
                ShellActive.SetEmissiveParts("ShieldDamageGlass", Color.Transparent, 0f);
                ShellActive.RemoveFromGamePruningStructure();
            }

            ShieldEnt = Spawn.EmptyEntity("dShield", null, parent);
            ShieldEnt.Render.CastShadows = false;
            ShieldEnt.Render.RemoveRenderObjects();
            ShieldEnt.Render.UpdateRenderObject(true);
            ShieldEnt.Render.Visible = false;
            ShieldEnt.Save           = false;
            _shieldEntRendId         = ShieldEnt.Render.GetRenderObjectID();
            _updateRender            = true;

            if (ShieldEnt != null)
            {
                Session.Instance.IdToBus[ShieldEnt.EntityId] = ShieldComp;
            }

            if (Icosphere == null)
            {
                Icosphere = new Icosphere.Instance(Session.Instance.Icosphere);
            }
            if (Session.Enforced.Debug == 3)
            {
                Log.Line($"InitEntities: mode: {ShieldMode}, spawn complete - ShieldId [{Shield.EntityId}]");
            }
        }