Skip to content

Commit

Permalink
Add support for Plugin Loader
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachHembree committed Nov 11, 2023
1 parent dc8d2eb commit 0f3f002
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 2 deletions.
7 changes: 7 additions & 0 deletions BuildVision2/Data/Scripts/BuildVision2/BuildVision2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ private void HudInit()

BvConfig.OnConfigLoad += UpdateBindPageVisibility;
UpdateBindPageVisibility();

#if PLUGIN_LOADER
ExceptionHandler.SendChatMessage(
"Build Vision has been launched in client-only mode by the Plugin Loader. " +
"Some functionality will be unavailable."
);
#endif
}
}

Expand Down
2 changes: 2 additions & 0 deletions BuildVision2/Data/Scripts/BuildVision2/Server/BvServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public override void Close()
/// </summary>
public static void SendEntityActionToServer(ServerBlockActions actionID, long entID, Action<byte[]> callback = null, bool uniqueCallback = true)
{
#if !PLUGIN_LOADER
int callbackID = -1;

if ((actionID & ServerBlockActions.RequireReply) == ServerBlockActions.RequireReply)
Expand All @@ -88,6 +89,7 @@ public static void SendEntityActionToServer(ServerBlockActions actionID, long en
}

instance.clientOutgoing.Add(new ClientMessage(actionID, callbackID, entID));
#endif
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public static void GetMechActions(PropertyBlock block, List<BlockMemberBase> mem
List<IMyTerminalAction> terminalActions = new List<IMyTerminalAction>();
block.TBlock.GetActions(terminalActions);

#if !PLUGIN_LOADER
members.Add(GetBlockAction(
// Name
MyTexts.GetString(MySpaceTexts.BlockActionTitle_Attach),
Expand All @@ -114,6 +115,7 @@ public static void GetMechActions(PropertyBlock block, List<BlockMemberBase> mem
members.Add(GetBlockAction(
MyTexts.GetString(MySpaceTexts.BlockActionTitle_Detach), null,
block.MechConnection.DetachHead, block));
#endif

foreach (IMyTerminalAction tAction in terminalActions)
{
Expand Down Expand Up @@ -154,18 +156,28 @@ public static void GetDoorActions(PropertyBlock block, List<BlockMemberBase> mem
/// </summary>
public static void GetWarheadActions(PropertyBlock block, List<BlockMemberBase> members)
{
#if PLUGIN_LOADER
members.Add(GetBlockAction(
// Name
MyTexts.GetString(MySpaceTexts.TerminalControlPanel_Warhead_StartCountdown),
// Status
x =>
null,
block.Warhead.StartCountdown, block));
#else

members.Add(GetBlockAction(
// Name
MyTexts.GetString(MySpaceTexts.TerminalControlPanel_Warhead_StartCountdown),
// Status
x =>
{
x.Clear();
x.Append('(');
x.Append(Math.Truncate(block.Warhead.CountdownTime));
x.Append("s)");
},
block.Warhead.StartCountdown, block));
#endif
members.Add(GetBlockAction(
MyTexts.GetString(MySpaceTexts.TerminalControlPanel_Warhead_StopCountdown), null,
block.Warhead.StopCountdown, block));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ public override void SetProperty(StringBuilder name, ITerminalProperty<float> pr
if (property.Id == "Velocity")
{
if (block.SubtypeId.UsesSubtype(TBlockSubtypes.Rotor))
GetStatusFunc = GetRotorAngleFunc;
{
#if !PLUGIN_LOADER
GetStatusFunc = GetRotorAngleFunc;
#endif
}
else if (block.SubtypeId.UsesSubtype(TBlockSubtypes.Piston))
GetStatusFunc = GetPistonExtensionFunc;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphF
builder.Add(MyTexts.GetString(Depressurize ? MySpaceTexts.SwitchText_On : MySpaceTexts.SwitchText_Off), valueFormat);
builder.Add("\n", valueFormat);

#if !PLUGIN_LOADER
// Oxy pct
builder.Add(MyTexts.GetString(MySpaceTexts.HudInfoOxygen), nameFormat);
builder.Add($"{(OxygenLevel * 100f):F2}%\n", valueFormat);
#endif
}

// Vent status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphF
builder.Add(RotorLock ? MyTexts.GetString(MySpaceTexts.HudInfoOn) : MyTexts.GetString(MySpaceTexts.HudInfoOff), valueFormat);
builder.Add("\n", valueFormat);

#if !PLUGIN_LOADER
builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertiesText_MotorCurrentAngle), nameFormat);
builder.Add($"{Angle.RadiansToDegrees():F2}°\n", valueFormat);
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public string GetLocalizedStatus()

public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat)
{
#if !PLUGIN_LOADER
var buf = block.textBuffer;

builder.Add(MyTexts.GetString(MySpaceTexts.TerminalControlPanel_TimerDelay), nameFormat);
Expand All @@ -100,6 +101,7 @@ public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphF
buf.Append(Math.Truncate(CountdownTime));
buf.Append("s\n");
builder.Add(buf, valueFormat);
#endif

builder.Add(MyTexts.GetString(MySpaceTexts.TerminalStatus), nameFormat);
builder.Add(": ", nameFormat);
Expand Down

0 comments on commit 0f3f002

Please sign in to comment.