Bugfixes & Reactive Refactor
Added credits display to trade screen Fixed bug in inventory screen where a failed drag from a cargo bay would make the item disappear until a refresh is triggered Changed behavior of Escape key to exit menu if a menu is open Fixed zone map gravity isolines to correctly track maximum gravity depth Refactored orbit and planet data to replace reactive variables with regular ones
This commit is contained in:
parent
7561c09edc
commit
6b0860b178
43 changed files with 1833 additions and 728 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using static Unity.Mathematics.math;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static UnityEditor.EditorGUILayout;
|
||||
|
|
@ -14,6 +15,18 @@ public class IntInspector : BaseInspector<int>
|
|||
}
|
||||
}
|
||||
|
||||
public class UintInspector : BaseInspector<uint>
|
||||
{
|
||||
public override uint Inspect(string label, uint value, object parent, DatabaseInspector inspectorWindow)
|
||||
{
|
||||
using (new HorizontalScope())
|
||||
{
|
||||
GUILayout.Label(label, GUILayout.Width(width));
|
||||
return (uint) max(DelayedIntField((int)value), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class RangedIntInspector : BaseInspector<int, InspectableRangedIntAttribute>
|
||||
{
|
||||
public override int Inspect(string label, int value, object parent, DatabaseInspector inspectorWindow, InspectableRangedIntAttribute attribute)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ using UnityEngine.Rendering.PostProcessing;
|
|||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
using Unity.Mathematics;
|
||||
using UnityEditor.Localization.Plugins.XLIFF.V12;
|
||||
using UnityEngine.EventSystems;
|
||||
using static Unity.Mathematics.math;
|
||||
using float2 = Unity.Mathematics.float2;
|
||||
|
|
@ -326,7 +325,13 @@ public class ActionGameManager : MonoBehaviour
|
|||
else Undock();
|
||||
};
|
||||
|
||||
Input.Global.MainMenu.performed += context => ToggleFullscreenMenu(MainMenu.gameObject);
|
||||
Input.Global.MainMenu.performed += context =>
|
||||
{
|
||||
if(Menu.gameObject.activeSelf)
|
||||
ToggleMenuTab(Menu.CurrentTab);
|
||||
else
|
||||
ToggleFullscreenMenu(MainMenu.gameObject);
|
||||
};
|
||||
|
||||
Input.Global.InputScreen.performed += context => ToggleFullscreenMenu(HelpScreen);
|
||||
|
||||
|
|
@ -427,7 +432,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
slot.PointerEnterTrigger.OnPointerEnterAsObservable().Subscribe(_ =>
|
||||
{
|
||||
Debug.Log($"Pointer entered action bar slot {controlPath}");
|
||||
//Debug.Log($"Pointer entered action bar slot {controlPath}");
|
||||
RegisterDragTarget(dragAction =>
|
||||
{
|
||||
//Debug.Log("Registering binding!");
|
||||
|
|
@ -504,7 +509,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
ConsoleController.AddCommand("trackmissile",
|
||||
_ =>
|
||||
{
|
||||
foreach (var missileManager in FindObjectsOfType<GuidedProjectileManager>())
|
||||
foreach (var missileManager in FindObjectsByType<GuidedProjectileManager>(FindObjectsSortMode.None))
|
||||
{
|
||||
missileManager.OnFireGuided.Where(x => x.source == _currentEntity).Take(1).Subscribe(x =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -716,7 +716,7 @@ public abstract class Entity
|
|||
|
||||
public EquippedDockingBay TryDock(Ship ship)
|
||||
{
|
||||
if (!IsDockingPermitted(ship.GetFactionRelationship(Faction), CurrentSecurityLevel.Value)) return null;
|
||||
//if (!IsDockingPermitted(ship.GetFactionRelationship(Faction), CurrentSecurityLevel.Value)) return null;
|
||||
|
||||
var bay = DockingBays.FirstOrDefault(x => x.DockedShip == null);
|
||||
if (bay != null)
|
||||
|
|
@ -1368,7 +1368,7 @@ public class EquippedCargoBay : EquippedItem
|
|||
|
||||
public readonly Dictionary<Guid, List<ItemInstance>> ItemsOfType = new Dictionary<Guid, List<ItemInstance>>();
|
||||
|
||||
public readonly CargoBayData Data;
|
||||
public new readonly CargoBayData Data;
|
||||
|
||||
public float Mass { get; private set; }
|
||||
public float ThermalMass { get; private set; }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
|
@ -165,10 +165,10 @@ public class Zone
|
|||
{
|
||||
var orbit = Orbits[orbitID];
|
||||
float2 pos = float2.zero;
|
||||
if (orbit.Period.Value > .01f)
|
||||
if (orbit.Period > .01f)
|
||||
{
|
||||
var phase = (float) frac(_time / orbit.Period.Value);
|
||||
pos = OrbitData.Evaluate(frac(phase + orbit.Data.Phase)) * orbit.Data.Distance.Value;
|
||||
var phase = (float) frac(_time / orbit.Period);
|
||||
pos = OrbitData.Evaluate(frac(phase + orbit.Data.Phase)) * orbit.Data.Distance;
|
||||
|
||||
if (float.IsNaN(pos.x))
|
||||
{
|
||||
|
|
@ -258,7 +258,7 @@ public class Zone
|
|||
var orbit = new OrbitData
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Distance = new ReactiveProperty<float>(distance),
|
||||
Distance = distance,
|
||||
Parent = parent,
|
||||
Phase = storedPhase
|
||||
};
|
||||
|
|
@ -330,21 +330,21 @@ public class Zone
|
|||
{
|
||||
var p = position - body.Orbit.Position; //GetOrbitPosition(body.BodyData.Orbit)
|
||||
var distSqr = lengthsq(p);
|
||||
var gravityRadius = body.GravityWellRadius.Value;
|
||||
var gravityRadius = body.GravityWellRadius;
|
||||
if (distSqr < gravityRadius*gravityRadius)
|
||||
{
|
||||
var depth = body.GravityWellDepth.Value;
|
||||
result -= PowerPulse(sqrt(distSqr) / gravityRadius, body.BodyData.GravityDepthExponent.Value) * depth;
|
||||
var depth = body.GravityWellDepth;
|
||||
result -= PowerPulse(sqrt(distSqr) / gravityRadius, body.BodyData.GravityDepthExponent) * depth;
|
||||
}
|
||||
|
||||
if (body is GasGiant gas)
|
||||
{
|
||||
var waveRadius = gas.GravityWavesRadius.Value;
|
||||
var waveRadius = gas.GravityWavesRadius;
|
||||
if(distSqr < waveRadius*waveRadius)
|
||||
{
|
||||
var depth = gas.GravityWavesDepth.Value;
|
||||
var frequency = Settings.WaveFrequency.Evaluate(body.BodyData.Mass.Value);
|
||||
var speed = gas.GravityWavesSpeed.Value;
|
||||
var depth = gas.GravityWavesDepth;
|
||||
var frequency = Settings.WaveFrequency.Evaluate(body.BodyData.Mass);
|
||||
var speed = gas.GravityWavesSpeed;
|
||||
result -= RadialWaves(sqrt(distSqr) / waveRadius, 8, 1.25f, frequency, (float) (_time * speed)) * depth;
|
||||
}
|
||||
}
|
||||
|
|
@ -362,7 +362,7 @@ public class Zone
|
|||
{
|
||||
var p = position - body.Orbit.Position;
|
||||
var distSqr = lengthsq(p);
|
||||
var lightRadius = sun.LightRadius.Value;
|
||||
var lightRadius = sun.LightRadius;
|
||||
if (distSqr < lightRadius * lightRadius)
|
||||
{
|
||||
light += PowerPulse(sqrt(distSqr) / lightRadius, 8);
|
||||
|
|
@ -377,7 +377,7 @@ public class Zone
|
|||
{
|
||||
var normal = GetNormal(position);
|
||||
var f = new float2(normal.x, normal.z);
|
||||
return f * Settings.GravityStrength * lengthsq(f);// * Mathf.Abs(GetHeight(position));
|
||||
return f * Settings.GravityStrength * lengthsq(f);
|
||||
}
|
||||
|
||||
public static float PowerPulse(float x, float exponent)
|
||||
|
|
@ -409,58 +409,65 @@ public class Zone
|
|||
public class Planet
|
||||
{
|
||||
public Orbit Orbit;
|
||||
protected readonly PlanetSettings Settings;
|
||||
public BodyData BodyData;
|
||||
public ReadOnlyReactiveProperty<float> GravityWellDepth;
|
||||
public ReadOnlyReactiveProperty<float> GravityWellRadius;
|
||||
public ReadOnlyReactiveProperty<float> BodyRadius;
|
||||
public float GravityWellDepth;
|
||||
public float GravityWellRadius;
|
||||
public float BodyRadius;
|
||||
|
||||
public Planet(PlanetSettings settings, BodyData data, Orbit orbit)
|
||||
{
|
||||
Settings = settings;
|
||||
Orbit = orbit;
|
||||
BodyData = data;
|
||||
BodyRadius = new ReadOnlyReactiveProperty<float>(
|
||||
data.Mass.CombineLatest(data.BodyRadiusMultiplier,
|
||||
(mass, radius) => settings.BodyRadius.Evaluate(mass) * radius));
|
||||
GravityWellRadius = new ReadOnlyReactiveProperty<float>(
|
||||
data.Mass.CombineLatest(data.GravityRadiusMultiplier,
|
||||
(mass, radius) => settings.GravityRadius.Evaluate(mass) * radius));
|
||||
GravityWellDepth = new ReadOnlyReactiveProperty<float>(
|
||||
data.Mass.CombineLatest(data.GravityDepthMultiplier,
|
||||
(mass, depth) => settings.GravityDepth.Evaluate(mass) * depth));
|
||||
CalculateProperties();
|
||||
}
|
||||
|
||||
public void CalculateProperties()
|
||||
{
|
||||
BodyRadius = Settings.BodyRadius.Evaluate(BodyData.Mass) * BodyData.BodyRadiusMultiplier;
|
||||
GravityWellRadius = Settings.GravityRadius.Evaluate(BodyData.Mass) * BodyData.GravityRadiusMultiplier;
|
||||
GravityWellDepth = Settings.GravityDepth.Evaluate(BodyData.Mass) * BodyData.GravityDepthMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
public class GasGiant : Planet
|
||||
{
|
||||
public GasGiantData GasGiantData;
|
||||
public ReadOnlyReactiveProperty<float> GravityWavesDepth;
|
||||
public ReadOnlyReactiveProperty<float> GravityWavesRadius;
|
||||
public ReadOnlyReactiveProperty<float> GravityWavesSpeed;
|
||||
public float GravityWavesDepth;
|
||||
public float GravityWavesRadius;
|
||||
public float GravityWavesSpeed;
|
||||
|
||||
public GasGiant(PlanetSettings settings, GasGiantData data, Orbit orbit) : base(settings, data, orbit)
|
||||
{
|
||||
GasGiantData = data;
|
||||
GravityWavesDepth = new ReadOnlyReactiveProperty<float>(
|
||||
data.Mass.CombineLatest(data.WaveDepthMultiplier,
|
||||
(mass, depth) => settings.WaveDepth.Evaluate(mass) * depth));
|
||||
GravityWavesRadius = new ReadOnlyReactiveProperty<float>(
|
||||
data.Mass.CombineLatest(data.WaveRadiusMultiplier,
|
||||
(mass, radius) => settings.WaveRadius.Evaluate(mass) * radius));
|
||||
GravityWavesSpeed = new ReadOnlyReactiveProperty<float>(
|
||||
data.Mass.CombineLatest(data.WaveSpeedMultiplier,
|
||||
(mass, speed) => settings.WaveSpeed.Evaluate(mass) * speed));
|
||||
CalculateProperties();
|
||||
}
|
||||
|
||||
public new void CalculateProperties()
|
||||
{
|
||||
base.CalculateProperties();
|
||||
GravityWavesDepth = Settings.WaveDepth.Evaluate(BodyData.Mass) * GasGiantData.WaveDepthMultiplier;
|
||||
GravityWavesRadius = Settings.WaveRadius.Evaluate(BodyData.Mass) * GasGiantData.WaveRadiusMultiplier;
|
||||
GravityWavesSpeed = Settings.WaveSpeed.Evaluate(BodyData.Mass) * GasGiantData.WaveSpeedMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
public class Sun : GasGiant
|
||||
{
|
||||
public ReadOnlyReactiveProperty<float> LightRadius;
|
||||
|
||||
public SunData SunData;
|
||||
public float LightRadius;
|
||||
|
||||
public Sun(PlanetSettings settings, SunData data, Orbit orbit) : base(settings, data, orbit)
|
||||
{
|
||||
LightRadius = new ReadOnlyReactiveProperty<float>(
|
||||
data.Mass.CombineLatest(data.LightRadiusMultiplier,
|
||||
(mass, radius) => settings.LightRadius.Evaluate(mass) * radius));
|
||||
SunData = data;
|
||||
CalculateProperties();
|
||||
}
|
||||
|
||||
public new void CalculateProperties()
|
||||
{
|
||||
base.CalculateProperties();
|
||||
LightRadius = Settings.LightRadius.Evaluate(BodyData.Mass) * SunData.LightRadiusMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -491,11 +498,11 @@ public class Orbit
|
|||
public float2 Velocity = float2.zero;
|
||||
public float2 Position = float2.zero;
|
||||
public float2 PreviousPosition = float2.zero;
|
||||
public ReadOnlyReactiveProperty<float> Period;
|
||||
public float Period;
|
||||
|
||||
public Orbit(PlanetSettings settings, OrbitData data)
|
||||
{
|
||||
Data = data;
|
||||
Period = new ReadOnlyReactiveProperty<float>(data.Distance.Select(f => settings.OrbitPeriod.Evaluate(f)));
|
||||
Period = settings.OrbitPeriod.Evaluate(data.Distance);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,33 +78,33 @@ public class ZonePack
|
|||
public abstract class BodyData : DatabaseEntry, INamedEntry
|
||||
{
|
||||
[JsonProperty("name"), Key(1)]
|
||||
public ReactiveProperty<string> Name = new ReactiveProperty<string>("");
|
||||
public string Name = "";
|
||||
|
||||
[JsonProperty("orbit"), Key(2)]
|
||||
public Guid Orbit;
|
||||
|
||||
[JsonProperty("mass"), Key(3)]
|
||||
public ReactiveProperty<float> Mass = new ReactiveProperty<float>(0);
|
||||
public float Mass = 0;
|
||||
|
||||
[JsonProperty("resources"), Key(4)]
|
||||
public Dictionary<Guid, float> Resources = new Dictionary<Guid, float>();
|
||||
|
||||
[JsonProperty("bodyRadiusMul")] [Key(5)]
|
||||
public ReactiveProperty<float> BodyRadiusMultiplier = new ReactiveProperty<float>(1);
|
||||
public float BodyRadiusMultiplier = 1;
|
||||
|
||||
[JsonProperty("gravRadiusMul")] [Key(6)]
|
||||
public ReactiveProperty<float> GravityRadiusMultiplier = new ReactiveProperty<float>(1);
|
||||
public float GravityRadiusMultiplier = 1;
|
||||
|
||||
[JsonProperty("depthMul")] [Key(7)]
|
||||
public ReactiveProperty<float> GravityDepthMultiplier = new ReactiveProperty<float>(1);
|
||||
public float GravityDepthMultiplier = 1;
|
||||
|
||||
[JsonProperty("depthExp")] [Key(8)]
|
||||
public ReactiveProperty<float> GravityDepthExponent = new ReactiveProperty<float>(16);
|
||||
public float GravityDepthExponent = 16;
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
{
|
||||
get => Name.Value;
|
||||
set => Name.Value = value;
|
||||
get => Name;
|
||||
set => Name = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -125,49 +125,49 @@ public class AsteroidBeltData : BodyData
|
|||
public class GasGiantData : BodyData
|
||||
{
|
||||
[JsonProperty("firstOffsetDomainRotationSpeed"), Key(9)]
|
||||
public ReactiveProperty<float> FirstOffsetDomainRotationSpeed = new ReactiveProperty<float>(1);
|
||||
public float FirstOffsetDomainRotationSpeed = 1;
|
||||
|
||||
[JsonProperty("firstOffsetRotationSpeed"), Key(10)]
|
||||
public ReactiveProperty<float> FirstOffsetRotationSpeed = new ReactiveProperty<float>(1);
|
||||
public float FirstOffsetRotationSpeed = 1;
|
||||
|
||||
[JsonProperty("secondOffsetDomainRotationSpeed"), Key(11)]
|
||||
public ReactiveProperty<float> SecondOffsetDomainRotationSpeed = new ReactiveProperty<float>(1);
|
||||
public float SecondOffsetDomainRotationSpeed = 1;
|
||||
|
||||
[JsonProperty("secondOffsetRotationSpeed"), Key(12)]
|
||||
public ReactiveProperty<float> SecondOffsetRotationSpeed = new ReactiveProperty<float>(1);
|
||||
public float SecondOffsetRotationSpeed = 1;
|
||||
|
||||
[JsonProperty("albedoRotationSpeed"), Key(13)]
|
||||
public ReactiveProperty<float> AlbedoRotationSpeed = new ReactiveProperty<float>(1);
|
||||
public float AlbedoRotationSpeed = 1;
|
||||
|
||||
[JsonProperty("gravRadiusMul")] [Key(14)]
|
||||
public ReactiveProperty<float> WaveRadiusMultiplier = new ReactiveProperty<float>(1);
|
||||
public float WaveRadiusMultiplier = 1;
|
||||
|
||||
[JsonProperty("depthMul")] [Key(15)]
|
||||
public ReactiveProperty<float> WaveDepthMultiplier = new ReactiveProperty<float>(1);
|
||||
public float WaveDepthMultiplier = 1;
|
||||
|
||||
[JsonProperty("depthExp")] [Key(16)]
|
||||
public ReactiveProperty<float> WaveDepthExponent = new ReactiveProperty<float>(8);
|
||||
public float WaveDepthExponent = 8;
|
||||
|
||||
[JsonProperty("depthExp")] [Key(17)]
|
||||
public ReactiveProperty<float> WaveSpeedMultiplier = new ReactiveProperty<float>(8);
|
||||
public float WaveSpeedMultiplier = 8;
|
||||
|
||||
[JsonProperty("materialOverrides"), Key(18)]
|
||||
public List<string> MaterialOverrides = new List<string>();
|
||||
|
||||
[JsonProperty("colors"), Key(19)]
|
||||
public ReactiveProperty<float4[]> Colors = new ReactiveProperty<float4[]>();
|
||||
public float4[] Colors = new float4[0];
|
||||
}
|
||||
|
||||
public class SunData : GasGiantData
|
||||
{
|
||||
[JsonProperty("lightColor"), Key(20)]
|
||||
public ReactiveProperty<float3> LightColor = new ReactiveProperty<float3>(float3.zero);
|
||||
public float3 LightColor = float3.zero;
|
||||
|
||||
[JsonProperty("fogTintColor"), Key(21)]
|
||||
public ReactiveProperty<float3> FogTintColor = new ReactiveProperty<float3>(float3.zero);
|
||||
public float3 FogTintColor = float3.zero;
|
||||
|
||||
[JsonProperty("lightRadiusMul")] [Key(22)]
|
||||
public ReactiveProperty<float> LightRadiusMultiplier = new ReactiveProperty<float>(1);
|
||||
public float LightRadiusMultiplier = 1;
|
||||
}
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
|
|
@ -193,7 +193,7 @@ public class OrbitData : DatabaseEntry
|
|||
public Guid Parent;
|
||||
|
||||
[JsonProperty("distance"), Key(2)]
|
||||
public ReactiveProperty<float> Distance;
|
||||
public float Distance;
|
||||
|
||||
[JsonProperty("phase"), Key(3)]
|
||||
public float Phase;
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ public static class ZoneGenerator
|
|||
var data = new OrbitData
|
||||
{
|
||||
FixedPosition = planet.FixedPosition,
|
||||
Distance = new ReactiveProperty<float>(planet.Distance),
|
||||
Distance = planet.Distance,
|
||||
//Period = planet.Period,
|
||||
Phase = planet.Phase
|
||||
};
|
||||
|
|
@ -158,17 +158,17 @@ public static class ZoneGenerator
|
|||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
planetData.Mass.Value = planet.Mass;
|
||||
planetData.Mass = planet.Mass;
|
||||
planetData.Orbit = orbitMap[planet].ID;
|
||||
// planetData.Resources = planetResources;
|
||||
planetData.Name.Value = planetData.ID.ToString().Substring(0, 8);
|
||||
planetData.Name = planetData.ID.ToString().Substring(0, 8);
|
||||
if (planetData is AsteroidBeltData beltData)
|
||||
{
|
||||
beltData.Asteroids =
|
||||
Enumerable.Range(0, (int) (zoneSettings.AsteroidCount.Evaluate(beltData.Mass.Value * orbitMap[planet].Distance.Value)))
|
||||
Enumerable.Range(0, (int) zoneSettings.AsteroidCount.Evaluate(beltData.Mass * orbitMap[planet].Distance))
|
||||
.Select(_ => new Asteroid
|
||||
{
|
||||
Distance = orbitMap[planet].Distance.Value + random.NextFloat()*(random.NextFloat()-.5f)*zoneSettings.AsteroidBeltWidth.Evaluate(orbitMap[planet].Distance.Value),
|
||||
Distance = orbitMap[planet].Distance + random.NextFloat()*(random.NextFloat()-.5f)*zoneSettings.AsteroidBeltWidth.Evaluate(orbitMap[planet].Distance),
|
||||
Phase = random.NextFloat(),
|
||||
Size = random.NextFloat(),
|
||||
RotationSpeed = zoneSettings.AsteroidRotationSpeed.Evaluate(random.NextFloat())
|
||||
|
|
@ -182,14 +182,14 @@ public static class ZoneGenerator
|
|||
{
|
||||
float primary = random.NextFloat();
|
||||
float secondary = frac(primary + 1 + zoneSettings.SunSecondaryColorDistance * (random.NextFloat() > .5 ? 1 : -1));
|
||||
gas.Colors.Value = new []
|
||||
gas.Colors = new []
|
||||
{
|
||||
float4(ColorMath.HsvToRgb(float3(primary, zoneSettings.SunColorSaturation, .5f)), 0),
|
||||
float4(ColorMath.HsvToRgb(float3(secondary, zoneSettings.SunColorSaturation, 1)), 1)
|
||||
};
|
||||
sun.FogTintColor.Value = ColorMath.HsvToRgb(float3(primary, zoneSettings.SunFogTintSaturation, 1));
|
||||
sun.LightColor.Value = ColorMath.HsvToRgb(float3(primary, zoneSettings.SunLightSaturation, 1));
|
||||
gas.FirstOffsetDomainRotationSpeed.Value = 5;
|
||||
sun.FogTintColor = ColorMath.HsvToRgb(float3(primary, zoneSettings.SunFogTintSaturation, 1));
|
||||
sun.LightColor = ColorMath.HsvToRgb(float3(primary, zoneSettings.SunLightSaturation, 1));
|
||||
gas.FirstOffsetDomainRotationSpeed = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -205,19 +205,19 @@ public static class ZoneGenerator
|
|||
|
||||
// Each band has a chance of being either the primary or one of the adjacent hues
|
||||
// Saturation and Value are random with curves applied
|
||||
gas.Colors.Value = times
|
||||
gas.Colors = times
|
||||
.Select(time => float4(ColorMath.HsvToRgb(float3(
|
||||
random.NextFloat() > zoneSettings.GasGiantBandAltColorChance ? primary : (random.NextFloat() > .5f ? right : left),
|
||||
zoneSettings.GasGiantBandSaturation.Evaluate(random.NextFloat()),
|
||||
zoneSettings.GasGiantBandSaturation.Evaluate(random.NextFloat()))),time))
|
||||
.ToArray();
|
||||
|
||||
gas.FirstOffsetDomainRotationSpeed.Value = 0;
|
||||
gas.FirstOffsetDomainRotationSpeed = 0;
|
||||
}
|
||||
gas.AlbedoRotationSpeed.Value = -3;
|
||||
gas.FirstOffsetRotationSpeed.Value = 5;
|
||||
gas.SecondOffsetRotationSpeed.Value = 10;
|
||||
gas.SecondOffsetDomainRotationSpeed.Value = -25;
|
||||
gas.AlbedoRotationSpeed = -3;
|
||||
gas.FirstOffsetRotationSpeed = 5;
|
||||
gas.SecondOffsetRotationSpeed = 10;
|
||||
gas.SecondOffsetDomainRotationSpeed = -25;
|
||||
}
|
||||
return planetData;
|
||||
}).ToList();
|
||||
|
|
@ -255,7 +255,7 @@ public static class ZoneGenerator
|
|||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Parent = baseOrbit.Parent,
|
||||
Distance = new ReactiveProperty<float>(baseOrbit.Distance.Value),
|
||||
Distance = baseOrbit.Distance,
|
||||
Phase = baseOrbit.Phase + PI / 3 * sign(random.NextFloat() - .5f)
|
||||
};
|
||||
pack.Orbits.Add(lagrangeOrbit);
|
||||
|
|
@ -264,13 +264,13 @@ public static class ZoneGenerator
|
|||
|
||||
void PlaceTurret(OrbitData orbit, LoadoutGenerator loadoutGenerator, int distanceMultiplier)
|
||||
{
|
||||
var phase = 20f * distanceMultiplier / orbit.Distance.Value;
|
||||
var phase = 20f * distanceMultiplier / orbit.Distance;
|
||||
|
||||
var turretOrbit = new OrbitData
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Parent = orbit.Parent,
|
||||
Distance = new ReactiveProperty<float>(orbit.Distance.Value),
|
||||
Distance = orbit.Distance,
|
||||
Phase = orbit.Phase + phase
|
||||
};
|
||||
pack.Orbits.Add(turretOrbit);
|
||||
|
|
|
|||
|
|
@ -115,10 +115,10 @@ public class ConsoleView : MonoBehaviour {
|
|||
if(visible)
|
||||
{
|
||||
_playerInputPreviouslyEnabled = GameManager.Input.Player.enabled;
|
||||
_previousCursorLockMode = Cursor.lockState;
|
||||
GameManager.Input.Global.Disable();
|
||||
GameManager.DisablePlayerInput();
|
||||
GameManager.Input.UI.Disable();
|
||||
_previousCursorLockMode = Cursor.lockState;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -442,10 +442,10 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
itemInstanceDragObject.OriginInventory.Remove(itemInstanceDragObject.Item);
|
||||
|
||||
FakeOccupancy = null;
|
||||
entity.TryEquip(equippableItem, placementPosition);
|
||||
var success = entity.TryEquip(equippableItem, placementPosition);
|
||||
RefreshCells();
|
||||
// TODO: SFX: Equip
|
||||
return false;
|
||||
return success;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -625,6 +625,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
foreach(var dragObject in _dragCells)
|
||||
Destroy(dragObject.gameObject);
|
||||
_dragCells = null;
|
||||
RefreshCells();
|
||||
});
|
||||
cell.PointerEnterTrigger.OnPointerEnterAsObservable()
|
||||
.Subscribe(data =>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public class TradeMenu : MonoBehaviour
|
|||
public Spreadsheet Spreadsheet;
|
||||
public TextMeshProUGUI TargetCargoLabel;
|
||||
public Button FoldoutButton;
|
||||
public TextMeshProUGUI CreditsLabel;
|
||||
|
||||
private EquippedCargoBay _targetCargo;
|
||||
private (ItemFilter filter, HardpointType type) _hardpointFilter;
|
||||
|
|
@ -38,6 +39,7 @@ public class TradeMenu : MonoBehaviour
|
|||
_targetCargo = GameManager.DockingBay;
|
||||
TargetCargoLabel.text = "Docking Bay";
|
||||
Properties.GameManager = GameManager;
|
||||
UpdateCreditsLabel();
|
||||
|
||||
MinimumSizeFilter.Width.onEndEdit.RemoveAllListeners();
|
||||
MinimumSizeFilter.Width.onEndEdit.AddListener(_ => Populate());
|
||||
|
|
@ -353,6 +355,14 @@ public class TradeMenu : MonoBehaviour
|
|||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void UpdateCreditsLabel()
|
||||
{
|
||||
if (CreditsLabel != null)
|
||||
{
|
||||
CreditsLabel.text = GameManager.Credits.ToString("N0");
|
||||
}
|
||||
}
|
||||
|
||||
private void Buy(CraftedItemInstance item)
|
||||
{
|
||||
|
|
@ -363,15 +373,17 @@ public class TradeMenu : MonoBehaviour
|
|||
if (data is HullData hullData)
|
||||
{
|
||||
if (hullData.HullType != HullType.Ship) throw new ArgumentException("Attempted to buy non-ship hull from station, WTF are you doing?!");
|
||||
|
||||
var ship = new Ship(GameManager.ItemManager, GameManager.Zone, item as EquippableItem, GameManager.NewEntitySettings) {IsPlayerShip = true};
|
||||
|
||||
var ship = new Ship(GameManager.ItemManager, GameManager.Zone, item as EquippableItem, GameManager.NewEntitySettings) { IsPlayerShip = true };
|
||||
ship.SetParent(GameManager.DockedEntity);
|
||||
|
||||
|
||||
GameManager.Credits -= data.Price;
|
||||
UpdateCreditsLabel();
|
||||
}
|
||||
else if (Inventory.TryTransferItem(_targetCargo, item))
|
||||
{
|
||||
GameManager.Credits -= price;
|
||||
UpdateCreditsLabel();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -406,6 +418,7 @@ public class TradeMenu : MonoBehaviour
|
|||
if (Inventory.TryTransferItem(_targetCargo, simpleCommodity, quantity))
|
||||
{
|
||||
GameManager.Credits -= q * data.Price;
|
||||
UpdateCreditsLabel();
|
||||
remaining -= q;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
Transform dragObject = null;
|
||||
weaponGroups.OnBeginDragAsObservable().Subscribe(x =>
|
||||
{
|
||||
Debug.Log($"Began dragging weapon group {x.group}");
|
||||
//Debug.Log($"Began dragging weapon group {x.group}");
|
||||
GameManager.BeginDrag(new WeaponGroupDragObject(x.group));
|
||||
dragObject = Instantiate(weaponGroups.Groups[x.group], DragParent, true).transform;
|
||||
dragOffset = (Vector2)dragObject.position - x.pointerEventData.position;
|
||||
|
|
@ -477,7 +477,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
});
|
||||
weaponGroups.OnEndDragAsObservable().Subscribe(x =>
|
||||
{
|
||||
Debug.Log($"Ended dragging weapon group {x.group}");
|
||||
//Debug.Log($"Ended dragging weapon group {x.group}");
|
||||
GameManager.EndDrag();
|
||||
Destroy(dragObject.gameObject);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
private Dictionary<Guid, InstancedMesh[]> _beltMeshes = new Dictionary<Guid, InstancedMesh[]>();
|
||||
private Dictionary<Guid, Matrix4x4[][]> _beltMatrices = new Dictionary<Guid, Matrix4x4[][]>();
|
||||
private float _viewDistance;
|
||||
private float _maxDepth;
|
||||
//private float _maxDepth;
|
||||
private float _minimapDistance;
|
||||
|
||||
private int _tourIndex = -1;
|
||||
|
|
@ -183,7 +183,6 @@ public class ZoneRenderer : MonoBehaviour
|
|||
public void LoadZone(Zone zone)
|
||||
{
|
||||
ClearZone();
|
||||
_maxDepth = 0;
|
||||
Zone = zone;
|
||||
SectorBrushes.localScale = zone.Pack.Radius * 2 * Vector3.one;
|
||||
SlimeGravityCamera.orthographicSize = zone.Pack.Radius;
|
||||
|
|
@ -370,34 +369,31 @@ public class ZoneRenderer : MonoBehaviour
|
|||
planet = Instantiate(Sun, ZoneRoot);
|
||||
var sunObject = (SunObject) planet;
|
||||
var sun = Zone.PlanetInstances[planetData.ID] as Sun;
|
||||
sunData.LightColor.Subscribe(c => sunObject.Light.color = c.ToColor());
|
||||
sun.LightRadius.Subscribe(r =>
|
||||
{
|
||||
sunObject.Light.range = r;
|
||||
sunObject.FogTint.transform.localScale = r * Vector3.one;
|
||||
});
|
||||
sunData.FogTintColor.Subscribe(c => sunObject.FogTint.material.SetColor("_Color", c.ToColor()));
|
||||
sunObject.Light.color = sunData.LightColor.ToColor();
|
||||
sunObject.Light.range = sun.LightRadius;
|
||||
sunObject.FogTint.transform.localScale = sun.LightRadius * Vector3.one;
|
||||
sunObject.FogTint.material.SetColor("_Color", sunData.FogTintColor.ToColor());
|
||||
}
|
||||
else planet = Instantiate(GasGiant, ZoneRoot);
|
||||
|
||||
var gas = (GasGiantObject) planet;
|
||||
var gasGiant = Zone.PlanetInstances[planetData.ID] as GasGiant;
|
||||
gasGiantData.Colors.Subscribe(c => gas.Body.material.SetTexture("_ColorRamp", c.ToGradient(!(planetData is SunData)).ToTexture()));
|
||||
gas.Body.material.SetTexture("_ColorRamp", gasGiantData.Colors.ToGradient(!(planetData is SunData)).ToTexture());
|
||||
// gasGiantData.AlbedoRotationSpeed.Subscribe(f => gas.SunMaterial.AlbedoRotationSpeed = f);
|
||||
// gasGiantData.FirstOffsetRotationSpeed.Subscribe(f => gas.SunMaterial.FirstOffsetRotationSpeed = f);
|
||||
// gasGiantData.SecondOffsetRotationSpeed.Subscribe(f => gas.SunMaterial.SecondOffsetRotationSpeed = f);
|
||||
// gasGiantData.FirstOffsetDomainRotationSpeed.Subscribe(f => gas.SunMaterial.FirstOffsetDomainRotationSpeed = f);
|
||||
// gasGiantData.SecondOffsetDomainRotationSpeed.Subscribe(f => gas.SunMaterial.SecondOffsetDomainRotationSpeed = f);
|
||||
gasGiant.GravityWavesRadius.Subscribe(f => gas.GravityWaves.transform.localScale = f * Vector3.one);
|
||||
gasGiant.GravityWavesDepth.Subscribe(f => gas.GravityWaves.material.SetFloat("_Depth", f));
|
||||
planetData.Mass.Subscribe(f => gas.GravityWaves.material.SetFloat("_Frequency", Settings.PlanetSettings.WaveFrequency.Evaluate(f)));
|
||||
gas.GravityWaves.transform.localScale = gasGiant.GravityWavesRadius * Vector3.one;
|
||||
gas.GravityWaves.material.SetFloat("_Depth", gasGiant.GravityWavesDepth);
|
||||
gas.GravityWaves.material.SetFloat("_Frequency", Settings.PlanetSettings.WaveFrequency.Evaluate(planetData.Mass));
|
||||
//gas.WaveScroll.Speed = Properties.GravitySettings.WaveSpeed.Evaluate(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
planet = Instantiate(Planet, ZoneRoot);
|
||||
var possibleSettings = Settings.BodySettingsCollections
|
||||
.Where(p => p.MinimumMass < planetData.Mass.Value)
|
||||
.Where(p => p.MinimumMass < planetData.Mass)
|
||||
.MaxBy(p => p.MinimumMass).BodySettings;
|
||||
planet.Generator.body = possibleSettings[Random.Range(0, possibleSettings.Length)];
|
||||
//Debug.Log($"Generating planet with {planetData.Mass} mass! Choosing {planet.Generator.body.name} settings!");
|
||||
|
|
@ -405,15 +401,13 @@ public class ZoneRenderer : MonoBehaviour
|
|||
}
|
||||
|
||||
var planetInstance = Zone.PlanetInstances[planetData.ID];
|
||||
planetInstance.BodyRadius.Subscribe(f => { planet.Body.transform.localScale = f * Vector3.one; });
|
||||
planetInstance.GravityWellRadius.Subscribe(f => planet.GravityWell.transform.localScale = f * Vector3.one);
|
||||
planetInstance.GravityWellDepth.Subscribe(f =>
|
||||
{
|
||||
if (f > _maxDepth) _maxDepth = f;
|
||||
planet.GravityWell.material.SetFloat("_Depth", f);
|
||||
planet.Icon.transform.position = new Vector3(0, -f, 0);
|
||||
});
|
||||
planetInstance.BodyData.Mass.Subscribe(f => planet.Icon.transform.localScale = Settings.IconSize.Evaluate(f) * Vector3.one);
|
||||
planet.Body.transform.localScale = planetInstance.BodyRadius * Vector3.one;
|
||||
planet.GravityWell.transform.localScale = planetInstance.GravityWellRadius * Vector3.one;
|
||||
// var depth = planetInstance.GravityWellDepth;
|
||||
// if (depth > _maxDepth) _maxDepth = depth;
|
||||
planet.GravityWell.material.SetFloat("_Depth", planetInstance.GravityWellDepth);
|
||||
planet.Icon.transform.position = new Vector3(0, -planetInstance.GravityWellDepth, 0);
|
||||
planet.Icon.transform.localScale = Settings.IconSize.Evaluate(planetInstance.BodyData.Mass) * Vector3.one;
|
||||
|
||||
|
||||
Planets[planetData.ID] = planet;
|
||||
|
|
@ -454,6 +448,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
|
||||
void Update()
|
||||
{
|
||||
var maxDepth = 0f;
|
||||
foreach (var loot in _loot)
|
||||
{
|
||||
loot.ViewOrigin = PerspectiveEntity.Position;
|
||||
|
|
@ -508,12 +503,14 @@ public class ZoneRenderer : MonoBehaviour
|
|||
{
|
||||
var planetInstance = Zone.PlanetInstances[planet.Key];
|
||||
var p = Zone.GetOrbitPosition(planetInstance.BodyData.Orbit);
|
||||
var height = Zone.GetHeight(p);
|
||||
if (-height > maxDepth) maxDepth = -height;
|
||||
planet.Value.transform.position = new Vector3(p.x, 0, p.y);
|
||||
planet.Value.Body.transform.localPosition = new Vector3(0, Zone.GetHeight(p) + planetInstance.BodyRadius.Value * 2, 0);
|
||||
planet.Value.Body.transform.localPosition = new Vector3(0, height + planetInstance.BodyRadius * 2, 0);
|
||||
if (planet.Value is GasGiantObject gasGiantObject)
|
||||
{
|
||||
gasGiantObject.GravityWaves.material.SetFloat("_Phase",
|
||||
Zone.Time * ((GasGiant) Zone.PlanetInstances[planet.Key]).GravityWavesSpeed.Value);
|
||||
Zone.Time * ((GasGiant) Zone.PlanetInstances[planet.Key]).GravityWavesSpeed);
|
||||
if (!(planet.Value is SunObject))
|
||||
{
|
||||
var toParent = normalize(Zone.GetOrbitPosition(Zone.Orbits[planetInstance.BodyData.Orbit].Data.Parent) - p);
|
||||
|
|
@ -551,7 +548,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
SectorBoundaryBrush.material.SetFloat("_Depth", Settings.PlanetSettings.ZoneDepth + Settings.PlanetSettings.ZoneBoundaryFog);
|
||||
var startDepth = Zone.PowerPulse(Settings.MinimapZoneGravityRange, Settings.PlanetSettings.ZoneDepthExponent) *
|
||||
Settings.PlanetSettings.ZoneDepth;
|
||||
var depthRange = Settings.PlanetSettings.ZoneDepth - startDepth + _maxDepth;
|
||||
var depthRange = Settings.PlanetSettings.ZoneDepth - startDepth + maxDepth;
|
||||
foreach (var mat in MapGravityMaterials)
|
||||
{
|
||||
mat.SetFloat("_StartDepth", startDepth);
|
||||
|
|
@ -576,7 +573,8 @@ public class ZoneRenderer : MonoBehaviour
|
|||
SimpleCommodity _ => Instantiate(SimpleCommodityPickup),
|
||||
CompoundCommodity _ => Instantiate(CompoundCommodityPickup),
|
||||
EquippableItem equippableItem when ItemManager.GetData(equippableItem) is WeaponItemData => Instantiate(WeaponPickup),
|
||||
EquippableItem _ => Instantiate(GearPickup)
|
||||
EquippableItem _ => Instantiate(GearPickup),
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
var t = gridObject.transform;
|
||||
t.parent = ZoneRoot;
|
||||
|
|
|
|||
Loading…
Reference in a new issue