Skip to content

Commit

Permalink
Merge branch 'main' into pr/9
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauge committed Jul 27, 2024
2 parents f39b37a + 7169c43 commit 383e41f
Show file tree
Hide file tree
Showing 15 changed files with 316 additions and 296 deletions.
190 changes: 91 additions & 99 deletions GrappleHook/Data/Scripts/hook/WeaponControlLayer.cs

Large diffs are not rendered by default.

86 changes: 0 additions & 86 deletions ShrapnelDamageV2/Data/Scripts/shrapnel/Core.cs

This file was deleted.

4 changes: 0 additions & 4 deletions ShrapnelDamageV2/metadata.mod

This file was deleted.

11 changes: 0 additions & 11 deletions ShrapnelDamageV2/modinfo.sbmi

This file was deleted.

Binary file removed ShrapnelDamageV2/thumb.jpg
Binary file not shown.
2 changes: 0 additions & 2 deletions SuiteCombatBalancer/Data/Scripts/hacking/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public override void Init(MyObjectBuilder_SessionComponent sessionComponent)

private void Handler(object target, ref MyDamageInformation info)
{
MyLog.Default.Info(target.ToString());

IMyEntity ent = MyAPIGateway.Entities.GetEntityById(info.AttackerId);
if (ent == null) return; // End: Must be a player character

Expand Down
46 changes: 0 additions & 46 deletions ThermalDynamics/Data/Scripts/Thermodynamics/PlanetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,51 +129,5 @@ public static Planet GetClosestPlanet(Vector3D position)

return current;
}

public static bool IsSolarOccluded(Vector3D observer, Vector3 solarDirection, MyPlanet planet)
{
Vector3D local = observer - planet.PositionComp.WorldMatrixRef.Translation;
double distance = local.Length();
Vector3D localNorm = local / distance;

double dot = Vector3.Dot(localNorm, solarDirection);
return dot < GetLargestOcclusionDotProduct(GetVisualSize(distance, planet.AverageRadius));
}


/// <summary>
/// a number between 0 and 1 representing the side object based on distance
/// </summary>
/// <param name="observer">the local vector between the observer and the target</param>
/// <param name="radius">the size of the target</param>
//public static double GetVisualSize(Vector3D observer, double radius)
//{
// return 2 * Math.Atan(radius / (2 * observer.Length()));
//}

/// <summary>
/// a number between 0 and 1 representing the side object based on distance
/// </summary>
/// <param name="distance">the distance between the observer and the target</param>
/// <param name="radius">the size of the target</param>
public static double GetVisualSize(double distance, double radius)
{
return 2 * Math.Atan(radius / (2 * distance));
}

/// <summary>
/// an equation made by plotting the edge most angle of the occluded sun
/// takes in the current visual size of the planet and produces a number between 0 and -1
/// if the dot product of the planet and sun directions is less than this number it is occluded
/// </summary>
/// <param name="visualSize"></param>
/// <returns></returns>
public static double GetLargestOcclusionDotProduct(double visualSize)
{
return -1 + (0.85 * visualSize * visualSize * visualSize);
}

}


}
94 changes: 66 additions & 28 deletions ThermalDynamics/Data/Scripts/Thermodynamics/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Sandbox.ModAPI;
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using VRage.Game;
using VRage.Game.Components;
Expand Down Expand Up @@ -56,12 +57,15 @@ public Color GetTemperatureColor(float temp)
return new Color(red, 0, blue, 255);
}



public override void Simulate()
{
{
if (Settings.Debug && !MyAPIGateway.Utilities.IsDedicated)
{
//MyAPIGateway.Utilities.ShowNotification($"[Grid] Frequency: {Settings.Instance.Frequency}", 1, "White");
MatrixD matrix = MyAPIGateway.Session.Camera.WorldMatrix;

Vector3D start = matrix.Translation;
Vector3D end = start + (matrix.Forward * 15);

Expand All @@ -82,32 +86,6 @@ public override void Simulate()
if (c == null)
return;

Vector3D blockPosition;
Matrix blockRotation;

block.ComputeWorldCenter(out blockPosition);
block.Orientation.GetMatrix(out blockRotation);

MatrixD gridRotationMatrix = block.CubeGrid.WorldMatrix;
gridRotationMatrix.Translation = Vector3D.Zero;
blockRotation *= gridRotationMatrix;
MatrixD blockWorldMatrix = MatrixD.CreateWorld(blockPosition, blockRotation.Forward, blockRotation.Up);

float unit = block.CubeGrid.GridSize * 0.5f;
Vector3 halfExtents = new Vector3((float)unit, (float)unit, (float)unit);
BoundingBoxD box = new BoundingBoxD(-halfExtents, halfExtents);

//GetTemperatureColor(c.Temperature);

Color color = ColorExtensions.HSVtoColor(Tools.GetTemperatureColor(c.Temperature));


MySimpleObjectDraw.DrawTransparentBox(ref blockWorldMatrix, ref box, ref color, MySimpleObjectRasterizer.Solid, 1, 0.01f, null, null, true, -1, BlendTypeEnum.AdditiveTop, 1000f);


//MyAPIGateway.Utilities.ShowNotification($"[Grid] {tGrid.Entity.EntityId} Count: {tGrid.Thermals.Count}", 1, "White");


MyAPIGateway.Utilities.ShowNotification($"[Env] " +
$"sim: {Settings.Instance.SimulationSpeed.ToString("n2")} " +
$"freq: {Settings.Instance.Frequency.ToString("n2")} " +
Expand Down Expand Up @@ -154,5 +132,65 @@ public override void Simulate()
//MyAPIGateway.Utilities.ShowNotification($"[External] {tGrid.Mapper.Blocks.Count} EComplete: {tGrid.Mapper.ExternalRoomUpdateComplete} BComplete: {tGrid.ThermalCellUpdateComplete}", 1, "White");
}
}
}

public override void Draw()
{
if (Settings.Debug && !MyAPIGateway.Utilities.IsDedicated)
{
//MyAPIGateway.Utilities.ShowNotification($"[Grid] Frequency: {Settings.Instance.Frequency}", 1, "White");
MatrixD matrix = MyAPIGateway.Session.Camera.WorldMatrix;

Vector3D start = matrix.Translation;
Vector3D end = start + (matrix.Forward * 15);

IHitInfo hit;
MyAPIGateway.Physics.CastRay(start, end, out hit);
MyCubeGrid grid = hit?.HitEntity as MyCubeGrid;
if (grid == null) return;

Vector3I position = grid.WorldToGridInteger(hit.Position + (matrix.Forward * 0.005f));

ThermalGrid g = grid.GameLogic.GetAs<ThermalGrid>();

IMySlimBlock block = grid.GetCubeBlock(position);

if (block == null) return;

ThermalCell c = g.Get(block.Position);

if (c == null) return;

DrawBillboard(c, matrix);
for (int i = 0; i < c.Neighbors.Count; i++)
{
ThermalCell n = c.Neighbors[i];
DrawBillboard(n, matrix);
}
}
}

public void DrawBillboard(ThermalCell c, MatrixD cameraMatrix)
{
Vector3D position;
c.Block.ComputeWorldCenter(out position);

float averageBlockLength = Vector3I.DistanceManhattan(c.Block.Max + 1, c.Block.Min) * 0.33f;

Color color = ColorExtensions.HSVtoColor(Tools.GetTemperatureColor(c.Temperature));

float distance = 0.01f;
position = cameraMatrix.Translation + (position - cameraMatrix.Translation) * distance;
float scaler = 1.2f * c.Grid.Grid.GridSizeHalf * averageBlockLength * distance;

MyTransparentGeometry.AddBillboardOriented(
MyStringId.GetOrCompute("GaugeThermalTexture"), // Texture or material name for the billboard
color, // Color of the billboard
position,
cameraMatrix.Left, // Left direction of the billboard
cameraMatrix.Up, // Up direction of the billboard
scaler, // Width of the billboard
scaler // Height of the billboard
);
}
}
}
1 change: 1 addition & 0 deletions ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class Settings
public const string Filename = "ThermodynamicsConfig.cfg";
public const string Name = "Thermodynamics";
public const bool Debug = true;
public const bool DebugBlockColors = true;

public static Settings Instance;

Expand Down
6 changes: 2 additions & 4 deletions ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ public class ThermalCell
public IMySlimBlock Block;
public ThermalCellDefinition Definition;

private List<ThermalCell> Neighbors = new List<ThermalCell>();
public List<ThermalCell> Neighbors = new List<ThermalCell>();
private List<int> TouchingSerfacesByNeighbor = new List<int>();

public int ExposedSurfaces = 0;
private List<Vector3I> ExposedSurfaceDirections = new List<Vector3I>();


public List<Vector3I> ExposedSurfaceDirections = new List<Vector3I>();

public ThermalCell(ThermalGrid g, IMySlimBlock b)
{
Expand Down
4 changes: 3 additions & 1 deletion ThermalDynamics/Data/Scripts/Thermodynamics/ThermalGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Transactions;
Expand Down Expand Up @@ -371,6 +372,7 @@ public override void UpdateBeforeSimulation()
{
if (!ThermalCellUpdateComplete)
{
//MyLog.Default.Info($"[Thermals] updating serfaces {ExteriorNodes.Count}");
cell.UpdateSurfaces(ref ExteriorNodes, ref neighbors);
}

Expand Down Expand Up @@ -449,7 +451,7 @@ private void PrepareNextSimulationStep()
Vector3D planetDirection = planetLocal / distance;

double dot = Vector3D.Dot(planetDirection, FrameSolarDirection);
double occlusionDot = PlanetManager.GetLargestOcclusionDotProduct(PlanetManager.GetVisualSize(distance, myPlanet.AverageRadius));
double occlusionDot = Tools.GetLargestOcclusionDotProduct(Tools.GetVisualSize(distance, myPlanet.AverageRadius));

if (dot < occlusionDot)
{
Expand Down
Loading

0 comments on commit 383e41f

Please sign in to comment.