Skip to content

Commit

Permalink
Merge pull request #286 from InvalidArgument3/enceladus
Browse files Browse the repository at this point in the history
mostly fixed it was due to jumpaction gonna call taht good enough
  • Loading branch information
InvalidArgument3 authored Dec 7, 2024
2 parents 2598061 + 2797c85 commit 065a150
Show file tree
Hide file tree
Showing 4 changed files with 795 additions and 406 deletions.
42 changes: 14 additions & 28 deletions Ringway/Data/Scripts/TeleportGateway/TeleportBubbleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,40 @@ public static class TeleportBubbleManager
private static readonly object _lock = new object();
private static readonly Color _bubbleColor = new Color(0, 0, 255, 64); // Blue with 25% opacity

public static void CreateOrUpdateBubble(IMyCollector gateway)
{
public static void CreateOrUpdateBubble(IMyCollector gateway, Color color) {
var gatewayLogic = gateway.GameLogic.GetAs<TeleportGateway>();
if (gatewayLogic == null || !gatewayLogic.Settings.ShowSphere)
{
if (gatewayLogic == null || !gatewayLogic.Settings.ShowSphere) {
RemoveBubble(gateway); // Remove the bubble if ShowSphere is false
return;
}

lock (_lock)
{
lock (_lock) {
float sphereRadius = gatewayLogic.Settings.SphereDiameter / 2.0f;
Vector3D position = gateway.GetPosition() + gateway.WorldMatrix.Forward * sphereRadius; // Adjusted to use the sphere radius
Vector3D position = gateway.GetPosition() + gateway.WorldMatrix.Forward * sphereRadius;
_bubblePositions[gateway.EntityId] = position;
}
}

public static void DrawBubble(IMyCollector gateway)
{
try
{
public static void DrawBubble(IMyCollector gateway, Color color) {
try {
// Check if we're on a dedicated server
if (MyAPIGateway.Utilities.IsDedicated)
{
if (MyAPIGateway.Utilities.IsDedicated) {
return;
}

// Check if the Session object is available
if (MyAPIGateway.Session == null)
{
if (MyAPIGateway.Session == null) {
return;
}

var gatewayLogic = gateway.GameLogic.GetAs<TeleportGateway>();
if (gatewayLogic == null || !gatewayLogic.Settings.ShowSphere)
{
if (gatewayLogic == null || !gatewayLogic.Settings.ShowSphere) {
return;
}

Vector3D position;
lock (_lock)
{
if (!_bubblePositions.TryGetValue(gateway.EntityId, out position))
{
lock (_lock) {
if (!_bubblePositions.TryGetValue(gateway.EntityId, out position)) {
return;
}
}
Expand All @@ -66,14 +56,10 @@ public static void DrawBubble(IMyCollector gateway)
MatrixD worldMatrix = gateway.WorldMatrix;
MatrixD adjustedMatrix = MatrixD.CreateWorld(position, worldMatrix.Forward, worldMatrix.Up);

// Create a non-readonly copy of the color
Color bubbleColor = _bubbleColor;

// Draw a solid sphere
MySimpleObjectDraw.DrawTransparentSphere(ref adjustedMatrix, radius, ref bubbleColor, MySimpleObjectRasterizer.Solid, 20, null, MyStringId.GetOrCompute("Square"));
// Use the specified color
MySimpleObjectDraw.DrawTransparentSphere(ref adjustedMatrix, radius, ref color, MySimpleObjectRasterizer.Solid, 20, null, MyStringId.GetOrCompute("Square"));
}
catch (Exception exc)
{
catch (Exception exc) {
MyLog.Default.WriteLineAndConsole($"TeleportBubbleManager: Error drawing bubble: {exc.Message}\n{exc.StackTrace}");
}
}
Expand Down
Loading

0 comments on commit 065a150

Please sign in to comment.