コード例 #1
0
 private void SaveAndApply(IBlockConfiguration block, IMyTextPanel textPanel, Action <IMyTextPanel> action)
 {
     if (!block.HasStyle)
     {
         SaveAndApply(block, textPanel, 0, action);
         block.SetStyle(nameof(IMyTextPanel.Enabled), textPanel.Enabled);
     }
 }
コード例 #2
0
        private void SaveAndApply(IBlockConfiguration block, IMyRefinery refinery, Action <IMyRefinery> action)
        {
            if (!block.HasStyle)
            {
                block.SetStyle(nameof(IMyRefinery.Enabled), refinery.Enabled);
            }

            action(refinery);
        }
コード例 #3
0
        private void SaveAndApply(IBlockConfiguration block, IMyAssembler assembler, Action <IMyAssembler> action)
        {
            if (!block.HasStyle)
            {
                block.SetStyle(nameof(IMyAssembler.Enabled), assembler.Enabled);
            }

            action(assembler);
        }
コード例 #4
0
 private void Restore(IBlockConfiguration block, IMyLightingBlock lightingBlock)
 {
     lightingBlock.Enabled = block.GetBooleanStyle(nameof(IMyLightingBlock.Enabled), true);
     lightingBlock.BlinkIntervalSeconds = block.GetSingleStyle(nameof(IMyLightingBlock.BlinkIntervalSeconds));
     lightingBlock.BlinkLength          = block.GetSingleStyle(nameof(IMyLightingBlock.BlinkLength));
     lightingBlock.BlinkOffset          = block.GetSingleStyle(nameof(IMyLightingBlock.BlinkOffset));
     lightingBlock.Color     = block.GetColorStyle(nameof(IMyLightingBlock.Color), Colors.White);
     lightingBlock.Falloff   = block.GetSingleStyle(nameof(IMyLightingBlock.Falloff));
     lightingBlock.Intensity = block.GetSingleStyle(nameof(IMyLightingBlock.Intensity));
     lightingBlock.Radius    = block.GetSingleStyle(nameof(IMyLightingBlock.Radius));
 }
コード例 #5
0
 private void Restore(IBlockConfiguration provider, IMyTextSurface surface, Int32 index)
 {
     surface.WriteText(provider.GetStringStyle($"Surface {index} Text"));
     surface.FontSize        = provider.GetSingleStyle($"Surface {index} {nameof(IMyTextSurface.FontSize)}", 1);
     surface.Font            = provider.GetStringStyle($"Surface {index} {nameof(IMyTextSurface.Font)}", "Debug");
     surface.Alignment       = provider.GetEnumStyle <TextAlignment>($"Surface {index} {nameof(IMyTextSurface.Alignment)}", TextAlignment.LEFT);
     surface.FontColor       = provider.GetColorStyle($"Surface {index} {nameof(IMyTextSurface.FontColor)}", Colors.White);
     surface.BackgroundColor = provider.GetColorStyle($"Surface {index} {nameof(IMyTextSurface.BackgroundColor)}", Colors.Black);
     surface.ContentType     = provider.GetEnumStyle <ContentType>($"Surface {index} {nameof(IMyTextSurface.ContentType)}", ContentType.NONE);
     surface.TextPadding     = provider.GetSingleStyle($"Surface {index} {nameof(IMyTextSurface.TextPadding)}", 10);
 }
コード例 #6
0
        private void SaveAndApply(IBlockConfiguration block, IMySoundBlock soundBlock, Action <IMySoundBlock> action)
        {
            if (!block.HasStyle)
            {
                block.SetStyle(nameof(IMySoundBlock.Enabled), soundBlock.Enabled);
                block.SetStyle(nameof(IMySoundBlock.SelectedSound), soundBlock.SelectedSound);
                block.SetStyle(nameof(IMySoundBlock.Volume), soundBlock.Volume);
                block.SetStyle(nameof(IMySoundBlock.Range), soundBlock.Range);
                block.SetStyle(nameof(IMySoundBlock.LoopPeriod), soundBlock.LoopPeriod);
            }

            action(soundBlock);
        }
コード例 #7
0
        private void SaveAndApply(IBlockConfiguration block, IMyWarhead warhead, Action <IMyWarhead> action)
        {
            if (block == null)
            {
                return;
            }

            if (!block.HasStyle)
            {
                block.SetStyle(nameof(IMyWarhead.IsArmed), warhead.IsArmed);
                block.SetStyle(nameof(IMyWarhead.DetonationTime), warhead.DetonationTime);
            }

            action(warhead);
        }
コード例 #8
0
        private void Restore(IBlockConfiguration block, IMySoundBlock soundBlock)
        {
            soundBlock.Enabled = block.GetBooleanStyle(nameof(IMySoundBlock.Enabled), true);
            // TODO: Currently assuming that sound blocks are off by default.
            // https://support.keenswh.com/spaceengineers/general/topic/improvements-to-imysoundblock-interface
            var selectedSound = block.GetStringStyle(nameof(IMySoundBlock.SelectedSound));

            if (selectedSound != soundBlock.SelectedSound)
            {
                soundBlock.Stop();
                soundBlock.SelectedSound = selectedSound;
            }
            soundBlock.Volume     = block.GetSingleStyle(nameof(IMySoundBlock.Volume), 1);
            soundBlock.Range      = block.GetSingleStyle(nameof(IMySoundBlock.Range), 1);
            soundBlock.LoopPeriod = block.GetSingleStyle(nameof(IMySoundBlock.LoopPeriod));
        }
コード例 #9
0
        private void SaveAndApply(IBlockConfiguration block, IMyLightingBlock lightingBlock, Action <IMyLightingBlock> action)
        {
            if (!block.HasStyle)
            {
                block.SetStyle(nameof(IMyLightingBlock.Enabled), lightingBlock.Enabled);
                block.SetStyle(nameof(IMyLightingBlock.BlinkIntervalSeconds), lightingBlock.BlinkIntervalSeconds);
                block.SetStyle(nameof(IMyLightingBlock.BlinkLength), lightingBlock.BlinkLength);
                block.SetStyle(nameof(IMyLightingBlock.BlinkOffset), lightingBlock.BlinkOffset);
                block.SetStyle(nameof(IMyLightingBlock.Color), lightingBlock.Color);
                block.SetStyle(nameof(IMyLightingBlock.Falloff), lightingBlock.Falloff);
                block.SetStyle(nameof(IMyLightingBlock.Intensity), lightingBlock.Intensity);
                block.SetStyle(nameof(IMyLightingBlock.Radius), lightingBlock.Radius);
            }

            action(lightingBlock);
        }
コード例 #10
0
        private void SaveAndApply <T>(IBlockConfiguration provider, T surface, Int32 index, Action <T> action = null)
            where T : IMyTextSurface
        {
            if (!provider.HasStyle)
            {
                provider.SetStyle($"Surface {index} Text", surface.GetText());
                provider.SetStyle($"Surface {index} {nameof(IMyTextSurface.FontSize)}", surface.FontSize);
                provider.SetStyle($"Surface {index} {nameof(IMyTextSurface.Font)}", surface.Font);
                provider.SetStyle($"Surface {index} {nameof(IMyTextSurface.Alignment)}", surface.Alignment.ToString());
                provider.SetStyle($"Surface {index} {nameof(IMyTextSurface.FontColor)}", surface.FontColor);
                provider.SetStyle($"Surface {index} {nameof(IMyTextSurface.BackgroundColor)}", surface.BackgroundColor);
                provider.SetStyle($"Surface {index} {nameof(IMyTextSurface.ContentType)}", surface.ContentType.ToString());
                provider.SetStyle($"Surface {index} {nameof(IMyTextSurface.TextPadding)}", surface.TextPadding);
            }

            action?.Invoke(surface);
        }
コード例 #11
0
        private void SaveAndApply(IBlockConfiguration block, IMyDoor door, Action <IMyDoor> action)
        {
            if (!block.HasStyle)
            {
                block.SetStyle(nameof(IMyDoor.Enabled), door.Enabled);

                switch (door.Status)
                {
                case DoorStatus.Open:
                case DoorStatus.Opening:
                    block.SetStyle("Open", true);
                    break;

                default:
                    block.SetStyle("Open", false);
                    break;
                }
            }

            action(door);
        }
コード例 #12
0
 private void Restore(IBlockConfiguration block, IMyRefinery refinery)
 => refinery.Enabled = block.GetBooleanStyle(nameof(IMyRefinery.Enabled), true);
コード例 #13
0
 private void Restore(IBlockConfiguration block, IMyAssembler assembler)
 => assembler.Enabled = block.GetBooleanStyle(nameof(IMyAssembler.Enabled), true);
コード例 #14
0
 private void Restore(IBlockConfiguration block, IMyDoor door)
 => door.Enabled = block.GetBooleanStyle(nameof(IMyDoor.Enabled), true);
コード例 #15
0
 private void Restore(IBlockConfiguration block, IMyTextPanel textPanel)
 {
     Restore(block, textPanel, 0);
     textPanel.Enabled = block.GetBooleanStyle(nameof(IMyTextPanel.Enabled), true);
 }
コード例 #16
0
 private void Restore(IBlockConfiguration block, IMyWarhead warhead)
 {
     warhead.IsArmed        = block.GetBooleanStyle(nameof(IMyWarhead.IsArmed));
     warhead.DetonationTime = block.GetSingleStyle(nameof(IMyWarhead.DetonationTime), Countdown);
 }