Skip to content

Commit

Permalink
Updated existing mocks to match contribution guidelines.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristian-softtech committed May 8, 2019
1 parent 9675d36 commit 5eef267
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 69 deletions.
20 changes: 8 additions & 12 deletions Mockups/Blocks/MockAirVent.debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ namespace IngameScript.Mockups.Blocks
#endif
public partial class MockAirVent : MockFunctionalBlock, IMyAirVent
{
public float OxygenLevel { get; set; } = 0;
public virtual float OxygenLevel { get; set; } = 0;

public bool CanPressurize { get; set; }
public virtual bool CanPressurize { get; set; } = true;

public bool IsDepressurizing { get; set; }
public virtual bool IsDepressurizing => Enabled && (Status == VentStatus.Depressurizing || Status == VentStatus.Depressurized);

public bool Depressurize { get; set; } = false;
public virtual bool Depressurize { get; set; } = false;

public VentStatus Status { get; set; }
public virtual VentStatus Status { get; set; }

public bool PressurizationEnabled { get; } = true;
public virtual bool PressurizationEnabled { get; } = true;

protected override IEnumerable<ITerminalProperty> CreateTerminalProperties()
{
Expand All @@ -33,12 +33,8 @@ protected override IEnumerable<ITerminalProperty> CreateTerminalProperties()
});
}

public float GetOxygenLevel() => OxygenLevel;
public virtual float GetOxygenLevel() => OxygenLevel;

public void SetCustomName(string text) => CustomName = text;

public void SetCustomName(StringBuilder text) => CustomName = text.ToString();

public bool IsPressurized() => PressurizationEnabled && (Status == VentStatus.Pressurized || Status == VentStatus.Pressurizing);
public virtual bool IsPressurized() => PressurizationEnabled && (Status == VentStatus.Pressurized || Status == VentStatus.Pressurizing);
}
}
2 changes: 1 addition & 1 deletion Mockups/Blocks/MockDoor.debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace IngameScript.Mockups.Blocks
#endif
public partial class MockDoor : MockFunctionalBlock, IMyDoor
{
public bool Open => OpenRatio != 0;
public virtual bool Open => OpenRatio != 0;

public virtual DoorStatus Status { get; set; } = DoorStatus.Closed;

Expand Down
12 changes: 4 additions & 8 deletions Mockups/Blocks/MockInteriorLight.debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@ namespace IngameScript.Mockups.Blocks
#if !MOCKUP_DEBUG
[System.Diagnostics.DebuggerNonUserCode]
#endif
public partial class MockInteriorLight : MockTerminalBlock, IMyInteriorLight
public partial class MockInteriorLight : MockFunctionalBlock, IMyInteriorLight
{
float _offset;
protected float _offset;
public virtual float Radius { get; set; } = 2;

[Obsolete("Use " + nameof(Radius))]
public float ReflectorRadius => Radius;
public virtual float ReflectorRadius => Radius;

public virtual float Intensity { get; set; } = 1;
public virtual float Falloff { get; set; } = 1;
public virtual float BlinkIntervalSeconds { get; set; } = 0;

[Obsolete("Use " + nameof(BlinkLength) + " instead.")]
public float BlinkLenght => BlinkLength;
public virtual float BlinkLenght => BlinkLength;

public virtual float BlinkLength { get; set; } = 0;
public virtual float BlinkOffset { get; set; } = 0;
public virtual Color Color { get; set; } = new Color(255, 255, 255);
public virtual bool Enabled { get; set; } = true;

protected override IEnumerable<ITerminalProperty> CreateTerminalProperties()
{
Expand All @@ -45,8 +44,5 @@ protected override IEnumerable<ITerminalProperty> CreateTerminalProperties()
new MockTerminalProperty<IMyInteriorLight, float>("Offset", b => _offset, (b, v) => _offset = v)
});
}

[Obsolete("Use " + nameof(Enabled) + " instead.")]
public void RequestEnable(bool enable) => Enabled = enable;
}
}
4 changes: 2 additions & 2 deletions Mockups/Blocks/MockMotorRotor.debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace IngameScript.Mockups.Blocks
#endif
public partial class MockMotorRotor : MockCubeBlock, IMyMotorRotor
{
public bool IsAttached => Base != null;
public IMyMechanicalConnectionBlock Base { get; set; }
public virtual bool IsAttached => Base != null;
public virtual IMyMechanicalConnectionBlock Base { get; set; }
}
}
44 changes: 22 additions & 22 deletions Mockups/Blocks/MockMotorStator.debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,63 +10,63 @@ namespace IngameScript.Mockups.Blocks
#endif
public partial class MockMotorStator : MockFunctionalBlock, IMyMotorStator
{
public float Angle { get; set; } = 0;
public float Torque { get; set; }
public float BrakingTorque { get; set; }
public float TargetVelocityRad
public virtual float Angle { get; set; } = 0;
public virtual float Torque { get; set; }
public virtual float BrakingTorque { get; set; }
public virtual float TargetVelocityRad
{
get { return Convert.ToSingle(2 * Math.PI) / 60 * TargetVelocityRPM; }
set { TargetVelocityRPM = value / Convert.ToSingle(2 * Math.PI) * 60; }
}
public float TargetVelocityRPM { get; set; }
public float LowerLimitRad
public virtual float LowerLimitRad
{
get { return ToRads(LowerLimitDeg); }
set { LowerLimitDeg = FromRads(value); }
}

public float LowerLimitDeg { get; set; } = -1;
public float UpperLimitRad
public virtual float LowerLimitDeg { get; set; } = -1;
public virtual float UpperLimitRad
{
get { return ToRads(LowerLimitDeg); }
set { LowerLimitDeg = FromRads(value); }
}

public float UpperLimitDeg { get; set; } = -1;
public float Displacement { get; set; } = 0f;
public bool RotorLock { get; set; } = false;
public virtual float UpperLimitDeg { get; set; } = -1;
public virtual float Displacement { get; set; } = 0f;
public virtual bool RotorLock { get; set; } = false;

public IMyCubeGrid TopGrid => Top?.CubeGrid;
public virtual IMyCubeGrid TopGrid => Top?.CubeGrid;

public IMyAttachableTopBlock Top { get; private set; }
public virtual IMyAttachableTopBlock Top { get; private set; }

public float SafetyLockSpeed { get; set; }
public bool SafetyLock { get; set; }
public virtual float SafetyLockSpeed { get; set; }
public virtual bool SafetyLock { get; set; }

public bool IsLocked { get; set; } = false;
public virtual bool IsLocked { get; set; } = false;

public bool IsAttached => Top != null;
public bool PendingAttachment => MockPendingAttachment != null;
public virtual bool IsAttached => Top != null;
public virtual bool PendingAttachment => MockPendingAttachment != null;

public IMyAttachableTopBlock MockPendingAttachment { get; set; }
public virtual IMyAttachableTopBlock MockPendingAttachment { get; set; }

private float FromRads(float value)
protected float FromRads(float value)
{
if (value == -1)
return -1;

return value * 180 / Convert.ToSingle(Math.PI);
}

private float ToRads(float value)
protected float ToRads(float value)
{
if (value == -1)
return -1;

return Convert.ToSingle(Math.PI) * value / 180;
}

public void Attach()
public virtual void Attach()
{
if (PendingAttachment && !IsAttached)
{
Expand All @@ -84,7 +84,7 @@ public void Attach()
}
}

public void Detach()
public virtual void Detach()
{
MockPendingAttachment = Top;
Top = null;
Expand Down
6 changes: 3 additions & 3 deletions Mockups/Blocks/MockProgrammableBlock.debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ namespace IngameScript.Mockups.Blocks
#endif
public partial class MockProgrammableBlock : MockFunctionalBlock, IMyProgrammableBlock
{
string _storage = string.Empty;
readonly IMyTextSurface _primary = new MockTextSurface(new VRageMath.Vector2(512, 512), new VRageMath.Vector2(512, 512));
readonly IMyTextSurface _keyboard = new MockTextSurface(new VRageMath.Vector2(512, 256), new VRageMath.Vector2(512, 256));
protected string _storage = string.Empty;
protected readonly IMyTextSurface _primary = new MockTextSurface(new VRageMath.Vector2(512, 512), new VRageMath.Vector2(512, 512));
protected readonly IMyTextSurface _keyboard = new MockTextSurface(new VRageMath.Vector2(512, 256), new VRageMath.Vector2(512, 256));

public virtual int SurfaceCount { get; } = 1;

Expand Down
42 changes: 21 additions & 21 deletions Mockups/Blocks/MockTextPanel.debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace IngameScript.Mockups.Blocks
#endif
public partial class MockTextPanel : MockFunctionalBlock, IMyTextPanel
{
readonly MockTextSurface _surface = new MockTextSurface(new Vector2(512, 512), new Vector2(512, 512));
readonly StringBuilder _publicTitle = new StringBuilder();
protected readonly MockTextSurface _surface = new MockTextSurface(new Vector2(512, 512), new Vector2(512, 512));
protected readonly StringBuilder _publicTitle = new StringBuilder();
TextAlignmentEnum _alignment = TextAlignmentEnum.Align_Left;

public virtual string CurrentlyShownImage
Expand All @@ -30,7 +30,7 @@ public virtual string CurrentlyShownImage
[Obsolete("This property no has meaning in-game. If you need a secondary storage, use CustomData")]
public virtual ShowTextOnScreenFlag ShowOnScreen { get; set; } = ShowTextOnScreenFlag.PUBLIC;

public bool ShowText => _surface.ContentType == ContentType.TEXT_AND_IMAGE;
public virtual bool ShowText => _surface.ContentType == ContentType.TEXT_AND_IMAGE;

public virtual float FontSize
{
Expand Down Expand Up @@ -62,57 +62,57 @@ public virtual string Font
set { _surface.Font = value; }
}

public byte BackgroundAlpha
public virtual byte BackgroundAlpha
{
get { return _surface.BackgroundAlpha; }
set { _surface.BackgroundAlpha = value; }
}

public TextAlignment Alignment
public virtual TextAlignment Alignment
{
get { return _surface.Alignment; }
set { _surface.Alignment = value; }
}

public string Script
public virtual string Script
{
get { return _surface.Script; }
set { _surface.Script = value; }
}

public ContentType ContentType
public virtual ContentType ContentType
{
get { return _surface.ContentType; }
set { _surface.ContentType = value; }
}

public bool PreserveAspectRatio
public virtual bool PreserveAspectRatio
{
get { return _surface.PreserveAspectRatio; }
set { _surface.PreserveAspectRatio = value; }
}

public float TextPadding
public virtual float TextPadding
{
get { return _surface.TextPadding; }
set { _surface.TextPadding = value; }
}

public Color ScriptBackgroundColor
public virtual Color ScriptBackgroundColor
{
get { return _surface.ScriptBackgroundColor; }
set { _surface.ScriptBackgroundColor = value; }
}

public Color ScriptForegroundColor
public virtual Color ScriptForegroundColor
{
get { return _surface.ScriptForegroundColor; }
set { _surface.ScriptForegroundColor = value; }
}

public Vector2 SurfaceSize => _surface.SurfaceSize;
public virtual Vector2 SurfaceSize => _surface.SurfaceSize;

public Vector2 TextureSize => _surface.TextureSize;
public virtual Vector2 TextureSize => _surface.TextureSize;

protected override IEnumerable<ITerminalProperty> CreateTerminalProperties()
{
Expand Down Expand Up @@ -235,13 +235,13 @@ public virtual bool WritePublicTitle(string value, bool append = false)
return true;
}

public bool WriteText(string value, bool append = false) => _surface.WriteText(value, append);
public string GetText() => _surface.GetText();
public bool WriteText(StringBuilder value, bool append = false) => _surface.WriteText(value, append);
public void ReadText(StringBuilder buffer, bool append = false) => _surface.ReadText(buffer, append);
public void GetSprites(List<string> sprites) => _surface.GetSprites(sprites);
public void GetScripts(List<string> scripts) => _surface.GetScripts(scripts);
public MySpriteDrawFrame DrawFrame() => _surface.DrawFrame();
public Vector2 MeasureStringInPixels(StringBuilder text, string font, float scale) => _surface.MeasureStringInPixels(text, font, scale);
public virtual bool WriteText(string value, bool append = false) => _surface.WriteText(value, append);
public virtual string GetText() => _surface.GetText();
public virtual bool WriteText(StringBuilder value, bool append = false) => _surface.WriteText(value, append);
public virtual void ReadText(StringBuilder buffer, bool append = false) => _surface.ReadText(buffer, append);
public virtual void GetSprites(List<string> sprites) => _surface.GetSprites(sprites);
public virtual void GetScripts(List<string> scripts) => _surface.GetScripts(scripts);
public virtual MySpriteDrawFrame DrawFrame() => _surface.DrawFrame();
public virtual Vector2 MeasureStringInPixels(StringBuilder text, string font, float scale) => _surface.MeasureStringInPixels(text, font, scale);
}
}

0 comments on commit 5eef267

Please sign in to comment.