public ShieldRenderer(IMySlimBlock block, ShieldRenderMode mode, ShieldColor color, float shieldStatus, bool deformation)
        {
            m_block        = block;
            m_shieldStatus = shieldStatus;

            MyCubeBlockDefinition blockDefinition = block.BlockDefinition as MyCubeBlockDefinition;


            var blockSize = blockDefinition.Size;

            if (blockDefinition.CubeSize == MyCubeSize.Large)
            {
                m_shieldScale.X = blockDefinition.Size.X + 0.1;
                m_shieldScale.Y = blockDefinition.Size.Y + 0.1;
                m_shieldScale.Z = blockDefinition.Size.Z + 0.1;
            }
            else
            {
                m_shieldScale.X = (blockDefinition.Size.X + 0.1) * 0.2d;
                m_shieldScale.Y = (blockDefinition.Size.Y + 0.1) * 0.2d;
                m_shieldScale.Z = (blockDefinition.Size.Z + 0.1) * 0.2d;
            }

            Vector3D shieldPosition;

            if (block.FatBlock == null)
            {
                shieldPosition = block.CubeGrid.GridIntegerToWorld(block.Position);

                m_matrix = MatrixD.CreateFromTransformScale(Quaternion.CreateFromRotationMatrix(block.CubeGrid.WorldMatrix.GetOrientation()), shieldPosition, m_shieldScale);

                if (EnergyShieldsCore.Config.Effects.PlaySound)
                {
                    m_soundEmitter = new MyEntity3DSoundEmitter((MyEntity)block.CubeGrid);
                }
            }
            else
            {
                shieldPosition = block.FatBlock.WorldMatrix.Translation;

                m_matrix = MatrixD.CreateFromTransformScale(Quaternion.CreateFromRotationMatrix(block.FatBlock.WorldMatrix.GetOrientation()), shieldPosition, m_shieldScale);

                if (EnergyShieldsCore.Config.Effects.PlaySound)
                {
                    m_soundEmitter = new MyEntity3DSoundEmitter((MyEntity)block.FatBlock);
                }
            }

            if (EnergyShieldsCore.Config.Effects.PlaySound)
            {
                m_soundEmitter.SetPosition(shieldPosition);

                if (deformation)
                {
                    m_soundEmitter.CustomVolume = 0.05f;
                }

                m_soundEmitter.PlaySound(new MySoundPair(soundNameNormal + "High"));
            }
        }
 /// <exclude />
 private static string Substitute(string url, string subject, string status, ShieldColor? color, ShieldImage? image, ShieldStyle? style)
 {
     var newUrl = url
         .Replace("{subject}", subject as string)
         .Replace("{status}", status as string)
         .Replace("{color}", color.ToStr())
         .Replace("{image}", image.ToStr());
     if (style != ShieldStyle.Flat)
         newUrl += string.Format("?style={0}", style.ToStr());
     return newUrl;
 }
        /// <exclude />
        public static FluentTagBuilder GenerateShieldMarkup(string subject, ShieldType? type = null, string status = null, ShieldColor color = ShieldColor.Green, ShieldStyle style = ShieldStyle.Flat, ShieldImage image = ShieldImage.Png)
        {
            string url;
            subject = subject.Split(' ')[0];
            if (type == null)
                url = Substitute("https://img.shields.io/badge/{subject}-{status}-{color}.{image}", subject.Replace("-", ""), status, color, image, style);
            else
                url = Substitute(GithubForkmeMask[(ShieldType)type], subject, status, color, image, style);

            return new FluentTagBuilder().Tag("img", null, new { src = url });
        }
Exemple #4
0
 public KiteShield([DefaultParameterValue(ShieldColor.Orange)] ShieldColor color)
 {
     this.Color = color;
 }
Exemple #5
0
 public Shield([DefaultParameterValue(ShieldColor.Red)] ShieldColor color)
 {
     this.Color = color;
 }