Skip to content

Commit

Permalink
applied visual heat indication to the extingisher
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauge committed Dec 8, 2024
1 parent f729d26 commit 8b67555
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 30 deletions.
47 changes: 22 additions & 25 deletions ThermalDynamics/Data/Scripts/Thermodynamics/Session.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
using Draygo.BlockExtensionsAPI;
using Sandbox.Game;
using Sandbox.Game.Entities;
using Sandbox.Game.Entities.Cube;
using Sandbox.Game.EntityComponents;
using Sandbox.Game.SessionComponents;
using Sandbox.ModAPI;
using Sandbox.ModAPI.Weapons;
using SENetworkAPI;
using System;
using System.Collections.Generic;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using VRage.Game;
using VRage.Game.Components;
Expand Down Expand Up @@ -49,27 +43,13 @@ protected override void UnloadData()
base.UnloadData();
}

public Color GetTemperatureColor(float temp)
{
float max = 500f;
// Clamp the temperature to the range 0-100
float t = Math.Max(0, Math.Min(max, temp));



// Calculate the red and blue values using a linear scale
float red = (t / max);

float blue = (1f - (t / max));

return new Color(red, 0, blue, 255);
}



public override void Simulate()
{
if (Settings.Instance.Debug && !MyAPIGateway.Utilities.IsDedicated)
if (MyAPIGateway.Utilities.IsDedicated) return;

if (Settings.Instance.Debug)
{
//MyAPIGateway.Utilities.ShowNotification($"[Grid] Frequency: {Settings.Instance.Frequency}", 1, "White");
MatrixD matrix = MyAPIGateway.Session.Camera.WorldMatrix;
Expand Down Expand Up @@ -131,9 +111,26 @@ public override void Simulate()
}
}

private bool UsingExtinguisherTool()
{
IMyCharacter character = MyAPIGateway.Session?.Player?.Controller?.ControlledEntity as IMyCharacter;

if (character == null || character.EquippedTool == null) return false;

IMyAutomaticRifleGun extinguisher = character.EquippedTool as IMyAutomaticRifleGun;
if (extinguisher != null && extinguisher.DefinitionId.SubtypeId.ToString() == "ExtinguisherGun")
{
return true;
}

return false;
}

public override void Draw()
{
if (Settings.DebugTextureColors && !MyAPIGateway.Utilities.IsDedicated)
if (MyAPIGateway.Utilities.IsDedicated) return;

if (UsingExtinguisherTool())
{
//MyAPIGateway.Utilities.ShowNotification($"[Grid] Frequency: {Settings.Instance.Frequency}", 1, "White");
MatrixD matrix = MyAPIGateway.Session.Camera.WorldMatrix;
Expand Down
6 changes: 3 additions & 3 deletions ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Settings
public const string Name = "Thermodynamics";


public const bool DebugTextureColors = false;
public const bool DebugTextureColors = true;

public static Settings Instance;

Expand Down Expand Up @@ -94,10 +94,10 @@ public static Settings GetDefaults()
EnableSolarHeat = true,
EnablePlanets = true,
EnableDamage = true,
Frequency = 2,
Frequency = 60,
SimulationSpeed = 1,
VacuumTemperature = 2.7f,
SolarEnergy = 500f,
SolarEnergy = 1000f,
PresurizedAtmoConductivity = 0.026f,
PresurizedAtmoSpecificHeat = 1005,
};
Expand Down
4 changes: 2 additions & 2 deletions ThermalDynamics/Data/Scripts/Thermodynamics/ThermalGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private void Unpack(string data)
int f = bytes[i + 4];
f |= bytes[i + 5] << 8;

MyLog.Default.Info($"[{Settings.Name}] [Unpack] {id} {PositionToIndex[id]} {Thermals.ItemArray[PositionToIndex[id]].Block.BlockDefinition.Id} - T: {f}");
//MyLog.Default.Info($"[{Settings.Name}] [Unpack] {id} {PositionToIndex[id]} {Thermals.ItemArray[PositionToIndex[id]].Block.BlockDefinition.Id} - T: {f}");

Thermals.ItemArray[PositionToIndex[id]].Temperature = f;
}
Expand Down Expand Up @@ -201,7 +201,7 @@ private void UnpackLoops(string data)
int f = bytes[i+1];
f |= bytes[i+2] << 8;

MyLog.Default.Info($"[{Settings.Name}] [UnpackLoops] {id} - T: {f}");
//MyLog.Default.Info($"[{Settings.Name}] [UnpackLoops] {id} - T: {f}");

ThermalLoops[id].Temperature = f;
}
Expand Down
Binary file modified ThermalDynamics/Textures/Particles/GaugeThermalTexture.dds
Binary file not shown.

0 comments on commit 8b67555

Please sign in to comment.