diff --git a/.idea/.idea.Aetheria-Economy/.idea/indexLayout.xml b/.idea/.idea.Aetheria-Economy/.idea/indexLayout.xml index 9d93b2a50..71b8dd8fd 100644 --- a/.idea/.idea.Aetheria-Economy/.idea/indexLayout.xml +++ b/.idea/.idea.Aetheria-Economy/.idea/indexLayout.xml @@ -5,6 +5,7 @@ ../NodeGraphProcessor/Assets/com.alelievr.NodeGraphProcessor + Library/PackageCache/com.unity.burst@1.4.3 Library/PackageCache/com.unity.cinemachine@2.6.3 Library/PackageCache/com.unity.ext.nunit@1.0.5 Library/PackageCache/com.unity.ide.rider@2.0.7 @@ -38,7 +39,6 @@ Logs Recordings Server - Temp UserSettings obj diff --git a/Assembly-CSharp-Editor-firstpass.csproj b/Assembly-CSharp-Editor-firstpass.csproj index 584a4d229..7ef9286aa 100644 --- a/Assembly-CSharp-Editor-firstpass.csproj +++ b/Assembly-CSharp-Editor-firstpass.csproj @@ -323,6 +323,9 @@ E:/Projects/Aetheria-Economy/Assets/Allegorithmic/Plugins/Substance/Substance Engine/Editor/Substance.Editor.dll + + E:/Projects/Aetheria-Economy/Library/PackageCache/com.unity.burst@1.4.3/Unity.Burst.Unsafe.dll + C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll @@ -748,6 +751,12 @@ E:/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Recorder.dll + + + E:/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Burst.Editor.dll + + + E:/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Burst.dll diff --git a/Assembly-CSharp-Editor.csproj b/Assembly-CSharp-Editor.csproj index 325863c01..aae970e12 100644 --- a/Assembly-CSharp-Editor.csproj +++ b/Assembly-CSharp-Editor.csproj @@ -387,6 +387,9 @@ E:/Projects/Aetheria-Economy/Assets/Allegorithmic/Plugins/Substance/Substance Engine/Editor/Substance.Editor.dll + + E:/Projects/Aetheria-Economy/Library/PackageCache/com.unity.burst@1.4.3/Unity.Burst.Unsafe.dll + C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll @@ -812,6 +815,12 @@ E:/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Recorder.dll + + + E:/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Burst.Editor.dll + + + E:/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Burst.dll diff --git a/Assembly-CSharp-firstpass.csproj b/Assembly-CSharp-firstpass.csproj index 2ce86ddcb..b8554d973 100644 --- a/Assembly-CSharp-firstpass.csproj +++ b/Assembly-CSharp-firstpass.csproj @@ -384,6 +384,9 @@ E:/Projects/Aetheria-Economy/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll + + E:/Projects/Aetheria-Economy/Library/PackageCache/com.unity.burst@1.4.3/Unity.Burst.Unsafe.dll + C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll @@ -803,6 +806,12 @@ E:/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Recorder.dll + + + E:/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Burst.Editor.dll + + + E:/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Burst.dll diff --git a/Assembly-CSharp.csproj b/Assembly-CSharp.csproj index 36c93d8ee..867a5fe49 100644 --- a/Assembly-CSharp.csproj +++ b/Assembly-CSharp.csproj @@ -1045,6 +1045,9 @@ E:/Projects/Aetheria-Economy/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll + + E:/Projects/Aetheria-Economy/Library/PackageCache/com.unity.burst@1.4.3/Unity.Burst.Unsafe.dll + C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll @@ -1464,6 +1467,12 @@ E:/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Recorder.dll + + + E:/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Burst.Editor.dll + + + E:/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Burst.dll diff --git a/Assets/Scenes/ARPG.unity b/Assets/Scenes/ARPG.unity index cdcd49498..2f5ceee50 100644 --- a/Assets/Scenes/ARPG.unity +++ b/Assets/Scenes/ARPG.unity @@ -17271,7 +17271,7 @@ PrefabInstance: - target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e, type: 3} propertyPath: m_AnchoredPosition.x - value: 0 + value: 55.675 objectReference: {fileID: 0} - target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e, type: 3} @@ -18127,7 +18127,7 @@ PrefabInstance: - target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e, type: 3} propertyPath: m_AnchoredPosition.x - value: 0 + value: 60.98 objectReference: {fileID: 0} - target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e, type: 3} diff --git a/Assets/Scripts/Sector Display/SectorRenderer.cs b/Assets/Scripts/Sector Display/SectorRenderer.cs index c73a9064f..8a8ffb892 100644 --- a/Assets/Scripts/Sector Display/SectorRenderer.cs +++ b/Assets/Scripts/Sector Display/SectorRenderer.cs @@ -62,7 +62,6 @@ public class SectorRenderer : MonoBehaviour private Dictionary _beltObjects = new Dictionary(); private Dictionary _beltMeshes = new Dictionary(); private Dictionary _beltMatrices = new Dictionary(); - private Dictionary _beltAsteroidPositions = new Dictionary(); private Dictionary _projectileManagers = new Dictionary(); private Dictionary _guidedProjectileManagers = new Dictionary(); private Zone _zone; @@ -452,7 +451,6 @@ public class SectorRenderer : MonoBehaviour meshes.RemoveAt(Random.Range(0,meshes.Count)); _beltMeshes[planetData.ID] = meshes.ToArray(); _beltMatrices[planetData.ID] = new Matrix4x4[meshes.Count][]; - _beltAsteroidPositions[planetData.ID] = new float3[beltData.Asteroids.Length]; var count = beltData.Asteroids.Length / meshes.Count; var remainder = beltData.Asteroids.Length - count * meshes.Count; for (int i = 0; i < meshes.Count; i++) @@ -560,25 +558,23 @@ public class SectorRenderer : MonoBehaviour foreach(var belt in _zone.AsteroidBelts) { var meshes = _beltMeshes[belt.Key]; - for (int i = 0; i < _beltAsteroidPositions[belt.Key].Length; i++) - _beltAsteroidPositions[belt.Key][i] = float3(belt.Value.Transforms[i].x, _zone.GetHeight(belt.Value.Transforms[i].xy), belt.Value.Transforms[i].y); - var count = belt.Value.Transforms.Length / meshes.Length; + var count = belt.Value.Positions.Length / meshes.Length; for (int i = 0; i < meshes.Length; i++) { for (int t = 0; t < _beltMatrices[belt.Key][i].Length; t++) { var tx = t + i * count; - _beltMatrices[belt.Key][i][t] = Matrix4x4.TRS(_beltAsteroidPositions[belt.Key][tx], + _beltMatrices[belt.Key][i][t] = Matrix4x4.TRS(belt.Value.Positions[tx], Quaternion.Euler( - cos(belt.Value.Transforms[tx].z + (float) i / meshes.Length) * 100, - sin(belt.Value.Transforms[tx].z + (float) i / meshes.Length) * 100, - (float) tx / belt.Value.Transforms.Length * 360), - Vector3.one * belt.Value.Transforms[tx].w); + cos(belt.Value.Rotations[tx] + (float) i / meshes.Length) * 100, + sin(belt.Value.Rotations[tx] + (float) i / meshes.Length) * 100, + (float) tx / belt.Value.Positions.Length * 360), + Vector3.one * belt.Value.Scales[tx]); } Graphics.DrawMeshInstanced(meshes[i].Mesh, 0, meshes[i].Material, _beltMatrices[belt.Key][i]); } - _beltObjects[belt.Key].Update(_beltAsteroidPositions[belt.Key]); + _beltObjects[belt.Key].Update(belt.Value.Positions); } foreach (var planet in Planets) @@ -762,12 +758,12 @@ public class AsteroidBeltUI var parentPosition = _zone.GetOrbitPosition(_orbitParent); for (var i = 0; i < _belt.Data.Asteroids.Length; i++) { - var rotation = Quaternion.Euler(90, _belt.Transforms[i].z, 0); + var rotation = Quaternion.Euler(90, _belt.Rotations[i], 0); //var position = new Vector3(_belt.Transforms[i].x, _zone.GetHeight(parentPosition), _belt.Transforms[i].y); - _vertices[i * 4] = rotation * new Vector3(-_belt.Transforms[i].w * _scale,-_belt.Transforms[i].w * _scale,0) + (Vector3) positions[i]; - _vertices[i * 4 + 1] = rotation * new Vector3(-_belt.Transforms[i].w * _scale,_belt.Transforms[i].w * _scale,0) + (Vector3) positions[i]; - _vertices[i * 4 + 2] = rotation * new Vector3(_belt.Transforms[i].w * _scale,_belt.Transforms[i].w * _scale,0) + (Vector3) positions[i]; - _vertices[i * 4 + 3] = rotation * new Vector3(_belt.Transforms[i].w * _scale,-_belt.Transforms[i].w * _scale,0) + (Vector3) positions[i]; + _vertices[i * 4] = rotation * new Vector3(-_belt.Scales[i] * _scale,-_belt.Scales[i] * _scale,0) + (Vector3) positions[i]; + _vertices[i * 4 + 1] = rotation * new Vector3(-_belt.Scales[i] * _scale,_belt.Scales[i] * _scale,0) + (Vector3) positions[i]; + _vertices[i * 4 + 2] = rotation * new Vector3(_belt.Scales[i] * _scale,_belt.Scales[i] * _scale,0) + (Vector3) positions[i]; + _vertices[i * 4 + 3] = rotation * new Vector3(_belt.Scales[i] * _scale,-_belt.Scales[i] * _scale,0) + (Vector3) positions[i]; } _mesh.bounds = new Bounds(new Vector3(parentPosition.x, 0, parentPosition.y), Vector3.one * (_size * 2)); diff --git a/Assets/Scripts/ServerShared/Behaviors/MiningTool.cs b/Assets/Scripts/ServerShared/Behaviors/MiningTool.cs index 92c300227..7940b4aaf 100644 --- a/Assets/Scripts/ServerShared/Behaviors/MiningTool.cs +++ b/Assets/Scripts/ServerShared/Behaviors/MiningTool.cs @@ -55,10 +55,10 @@ public class MiningTool : IBehavior public bool Execute(float delta) { Range = Context.Evaluate(_data.Range, Item.EquippableItem, Entity); - var asteroidTransform = Entity.Zone.GetAsteroidTransform(AsteroidBelt, Asteroid); + var belt = Entity.Zone.AsteroidBelts[AsteroidBelt]; if (AsteroidBelt != Guid.Empty && Entity.Zone.AsteroidExists(AsteroidBelt, Asteroid) && - length(Entity.Position.xz - asteroidTransform.xz) - asteroidTransform.w < Range) + length(Entity.Position.xz - belt.Positions[Asteroid].xz) - belt.Scales[Asteroid] < Range) { Entity.Zone.MineAsteroid( Entity, diff --git a/Assets/Scripts/ServerShared/Behaviors/Reactor.cs b/Assets/Scripts/ServerShared/Behaviors/Reactor.cs index 322880467..df6a37f75 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Reactor.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Reactor.cs @@ -75,18 +75,21 @@ public class Reactor : IBehavior, IOrderedBehavior // We have an energy deficit, try to get some energy out of our capacitors first if (Entity.Energy < 0) { - Capacitor[] chargedCapacitors; + int chargedCapacitors = 0; do { var chargeToRemove = -Entity.Energy; - chargedCapacitors = _capacitors.Where(x => x.Charge > 0.01f).ToArray(); - foreach (var cap in chargedCapacitors) + foreach (var cap in _capacitors) { - var chargeRemoved = min(chargeToRemove / chargedCapacitors.Length, cap.Charge); - cap.AddCharge(-chargeRemoved); - Entity.Energy += chargeRemoved; + if(cap.Charge > 0.01f) + { + chargedCapacitors++; + var chargeRemoved = min(chargeToRemove / chargedCapacitors, cap.Charge); + cap.AddCharge(-chargeRemoved); + Entity.Energy += chargeRemoved; + } } - } while (chargedCapacitors.Length > 0 && Entity.Energy < -.01f); + } while (chargedCapacitors > 0 && Entity.Energy < -.01f); } // We still have an energy deficit, have to overload the reactor, run at reduced efficiency diff --git a/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs b/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs index 1f1b134c9..42474759d 100644 --- a/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs +++ b/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs @@ -74,7 +74,7 @@ public class ResourceScanner : IBehavior, IAlwaysUpdatedBehavior { if(Asteroid > -1 && Asteroid < beltData.Asteroids.Length && - length(Entity.Position.xz - Entity.Zone.GetAsteroidTransform(ScanTarget, Asteroid).xy) < Range) + length(Entity.Position.xz - Entity.Zone.AsteroidBelts[ScanTarget].Positions[Asteroid].xz) < Range) { _scanTime += delta; if (_scanTime > ScanDuration) diff --git a/Assets/Scripts/ServerShared/Behaviors/SurveyController.cs b/Assets/Scripts/ServerShared/Behaviors/SurveyController.cs index 5fec5bf24..767c45a2d 100644 --- a/Assets/Scripts/ServerShared/Behaviors/SurveyController.cs +++ b/Assets/Scripts/ServerShared/Behaviors/SurveyController.cs @@ -118,7 +118,7 @@ public class SurveyController : ControllerBase, IBehavior, IPersistentBe if (planet is AsteroidBeltData) { if(asteroid == -1) asteroid = Zone.NearestAsteroid(planet.ID, Entity.Position.xz); - return Zone.GetAsteroidTransform(planet.ID, asteroid).xy; + return Zone.AsteroidBelts[planet.ID].Positions[asteroid].xz; } return Zone.GetOrbitPosition(planet.Orbit); } @@ -128,7 +128,7 @@ public class SurveyController : ControllerBase, IBehavior, IPersistentBe if (planet is AsteroidBeltData) { if(asteroid == -1) asteroid = Zone.NearestAsteroid(planet.ID, Entity.Position.xz); - return Zone.GetAsteroidVelocity(planet.ID, asteroid); + return Zone.AsteroidBelts[planet.ID].Velocities[asteroid]; } return Zone.GetOrbitVelocity(planet.Orbit); } diff --git a/Assets/Scripts/ServerShared/Entity.cs b/Assets/Scripts/ServerShared/Entity.cs index 445093668..b6950b840 100644 --- a/Assets/Scripts/ServerShared/Entity.cs +++ b/Assets/Scripts/ServerShared/Entity.cs @@ -28,6 +28,7 @@ public abstract class Entity public float2 Velocity; public float[,] Temperature; + public float[,] NewTemperature; public bool2[,] HullConductivity; public float[,] ThermalMass; public float Energy; @@ -122,6 +123,7 @@ public abstract class Entity Equipment.Add(new EquippedItem(ItemManager, Hull, int2.zero, this)); Mass = hullData.Mass; Temperature = new float[hullData.Shape.Width, hullData.Shape.Height]; + NewTemperature = new float[hullData.Shape.Width, hullData.Shape.Height]; HullConductivity = new bool2[hullData.Shape.Width,hullData.Shape.Height]; ThermalMass = new float[hullData.Shape.Width, hullData.Shape.Height]; Armor = new float[hullData.Shape.Width, hullData.Shape.Height]; @@ -511,7 +513,7 @@ public abstract class Entity public virtual void Update(float delta) { var hullData = ItemManager.GetData(Hull) as HullData; - float[,] newTemp = new float[hullData.Shape.Width,hullData.Shape.Height]; + //float[,] newTemp = new float[hullData.Shape.Width,hullData.Shape.Height]; var radiation = 0f; foreach (var v in hullData.Shape.Coordinates) { @@ -542,23 +544,25 @@ public abstract class Entity (GearOccupancy[v.x, v.y + 1]?.Conductivity ?? 1) * (HullConductivity[v.x, v.y].y ? hullData.Conductivity : 1 / hullData.Conductivity); - newTemp[v.x, v.y] = Temperature[v.x, v.y] + heatTransfer * min(ItemManager.GameplaySettings.HeatConductionMultiplier * delta,1) / ThermalMass[v.x,v.y]; + NewTemperature[v.x, v.y] = Temperature[v.x, v.y] + heatTransfer * min(ItemManager.GameplaySettings.HeatConductionMultiplier * delta,1) / ThermalMass[v.x,v.y]; // For all cells on the border of the entity, radiate some heat into space, increasing the visibility of the ship if (Parent==null && !hullData.InteriorCells[v]) { - var rad = pow(newTemp[v.x, v.y], ItemManager.GameplaySettings.HeatRadiationExponent) * + var rad = pow(NewTemperature[v.x, v.y], ItemManager.GameplaySettings.HeatRadiationExponent) * ItemManager.GameplaySettings.HeatRadiationMultiplier; - newTemp[v.x, v.y] -= rad * delta; + NewTemperature[v.x, v.y] -= rad * delta; radiation += rad; } - if(float.IsNaN(newTemp[v.x, v.y]) || newTemp[v.x, v.y] < 0) + if(float.IsNaN(NewTemperature[v.x, v.y]) || NewTemperature[v.x, v.y] < 0) ItemManager.Log("HOUSTON, WE HAVE A PROBLEM!"); } VisibilitySources[this] = radiation; - Temperature = newTemp; + var swap = Temperature; + Temperature = NewTemperature; + NewTemperature = swap; if (Active) { diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs index 503e79138..d7da60ff5 100644 --- a/Assets/Scripts/ServerShared/ItemManager.cs +++ b/Assets/Scripts/ServerShared/ItemManager.cs @@ -221,7 +221,14 @@ public class ItemManager { if (StatQuality.ContainsKey((stat, item))) return StatQuality[(stat, item)]; - + + var quality = CalcQuality(stat, item); + StatQuality[(stat, item)] = quality; + return quality; + } + + private float CalcQuality(PerformanceStat stat, EquippableItem item) + { var itemData = GetData(item); var blueprint = ItemData.Get(item.Blueprint); var activeEffects = blueprint.StatEffects.Where(x => GetAffectedStat(blueprint, x) == stat).ToArray(); @@ -249,7 +256,6 @@ public class ItemManager quality = sum / ingredients.Length; } - StatQuality[(stat, item)] = quality; return quality; } diff --git a/Assets/Scripts/ServerShared/Zone.cs b/Assets/Scripts/ServerShared/Zone.cs index 8fe6784e9..a40d3d40a 100644 --- a/Assets/Scripts/ServerShared/Zone.cs +++ b/Assets/Scripts/ServerShared/Zone.cs @@ -6,6 +6,8 @@ using System; using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Threading; +using System.Threading.Tasks; using UniRx; using Unity.Mathematics; using static Unity.Mathematics.math; @@ -30,6 +32,7 @@ public class Zone private Random _random; public ZoneData Data { get; } + private List BeltUpdates = new List(); public Zone(PlanetSettings settings, ZonePack pack) { @@ -84,6 +87,9 @@ public class Zone { _time = time; _updatedOrbits.Clear(); + foreach (var t in BeltUpdates) + t.Wait(); + BeltUpdates.Clear(); foreach (var orbit in Orbits) { orbit.Value.PreviousPosition = orbit.Value.Position; @@ -91,8 +97,14 @@ public class Zone orbit.Value.Velocity = (orbit.Value.Position - orbit.Value.PreviousPosition) / deltaTime; } - foreach (var asteroids in AsteroidBelts.Keys) - UpdateAsteroidTransforms(asteroids); + foreach (var belt in AsteroidBelts) + { + Array.Copy(belt.Value.NewPositions, belt.Value.Positions, belt.Value.Positions.Length); + Array.Copy(belt.Value.NewVelocities, belt.Value.Velocities, belt.Value.Velocities.Length); + Array.Copy(belt.Value.NewScales, belt.Value.Scales, belt.Value.Scales.Length); + Array.Copy(belt.Value.NewRotations, belt.Value.Rotations, belt.Value.Rotations.Length); + BeltUpdates.Add(Task.Run(() => UpdateAsteroidTransformsAsync(belt.Key))); + } foreach (var entity in Entities) entity.Update(deltaTime); } @@ -144,13 +156,13 @@ public class Zone { var beltData = Planets[planetDataID] as AsteroidBeltData; - var asteroidPositions = GetAsteroidTransforms(planetDataID); + var asteroidPositions = AsteroidBelts[planetDataID].Positions; int nearest = 0; float nearestDistance = Single.MaxValue; for (int i = 0; i < beltData.Asteroids.Length; i++) { - var dist = lengthsq(asteroidPositions[i].xy - position); + var dist = lengthsq(asteroidPositions[i].xz - position); if (AsteroidExists(planetDataID, i) && dist < nearestDistance) { nearest = i; @@ -163,28 +175,11 @@ public class Zone public bool AsteroidExists(Guid planetDataID, int asteroid) => ((AsteroidBeltData) Planets[planetDataID]).Asteroids.Length > asteroid && asteroid >= 0; - public float2 GetAsteroidVelocity(Guid planetDataID, int asteroid) - { - return (AsteroidBelts[planetDataID].Transforms[asteroid].xy - AsteroidBelts[planetDataID].PreviousTransforms[asteroid].xy); - } - - public float4 GetAsteroidTransform(Guid planetDataID, int asteroid) - { - return AsteroidBelts[planetDataID].Transforms[asteroid]; - } - - public float4[] GetAsteroidTransforms(Guid planetDataID) - { - return AsteroidBelts[planetDataID].Transforms; - } - - private void UpdateAsteroidTransforms(Guid planetDataID) + private void UpdateAsteroidTransformsAsync(Guid planetDataID) { var beltData = Planets[planetDataID] as AsteroidBeltData; var belt = AsteroidBelts[planetDataID]; - - Array.Copy(belt.Transforms, belt.PreviousTransforms, beltData.Asteroids.Length); var orbitData = Orbits[beltData.Orbit].Data; var orbitPosition = GetOrbitPosition(orbitData.Parent); @@ -199,11 +194,13 @@ public class Zone size = Settings.AsteroidSize.Evaluate(damage * beltData.Asteroids[i].Size); } else size = Settings.AsteroidSize.Evaluate(beltData.Asteroids[i].Size); - - belt.Transforms[i] = float4( - OrbitData.Evaluate((float) frac(_time / Settings.OrbitPeriod.Evaluate(beltData.Asteroids[i].Distance) + - beltData.Asteroids[i].Phase)) * beltData.Asteroids[i].Distance + orbitPosition, - (float) (_time * beltData.Asteroids[i].RotationSpeed % (PI * 2)), size); + + belt.NewRotations[i] = _time * beltData.Asteroids[i].RotationSpeed % (PI * 2); + belt.NewScales[i] = size; + var pos = OrbitData.Evaluate(frac(_time / Settings.OrbitPeriod.Evaluate(beltData.Asteroids[i].Distance) + + beltData.Asteroids[i].Phase)) * beltData.Asteroids[i].Distance + orbitPosition; + belt.NewVelocities[i] = pos - belt.Positions[i].xz; + belt.NewPositions[i] = float3(pos.x, GetHeight(pos), pos.y); } } @@ -232,7 +229,7 @@ public class Zone { var beltData = Planets[asteroidBelt] as AsteroidBeltData; var belt = AsteroidBelts[asteroidBelt]; - var asteroidTransform = belt.Transforms[asteroid]; + //var asteroidTransform = belt.Transforms[asteroid]; var size = beltData.Asteroids[asteroid].Size; var asteroidHitpoints = Settings.AsteroidHitpoints.Evaluate(size); @@ -272,7 +269,7 @@ public class Zone float result = -PowerPulse(length(position)/(Data.Radius*2), Settings.ZoneDepthExponent) * Settings.ZoneDepth; foreach (var body in PlanetInstances.Values) { - var p = (position - body.Orbit.Position); //GetOrbitPosition(body.BodyData.Orbit) + var p = position - body.Orbit.Position; //GetOrbitPosition(body.BodyData.Orbit) var distSqr = lengthsq(p); var gravityRadius = body.GravityWellRadius.Value; if (distSqr < gravityRadius*gravityRadius) @@ -389,8 +386,14 @@ public class GasGiant : Planet public class AsteroidBelt { public AsteroidBeltData Data; - public float4[] Transforms; // x, y, rotation, scale - public float4[] PreviousTransforms; // x, y, rotation, scale + public float3[] Positions; // x, y, rotation, scale + public float3[] NewPositions; // x, y, rotation, scale + public float2[] Velocities; + public float2[] NewVelocities; + public float[] Rotations; + public float[] NewRotations; + public float[] Scales; + public float[] NewScales; public Dictionary RespawnTimers = new Dictionary(); public Dictionary Damage = new Dictionary(); public Dictionary<(Entity, int), float> MiningAccumulator = new Dictionary<(Entity, int), float>(); @@ -398,8 +401,14 @@ public class AsteroidBelt public AsteroidBelt(AsteroidBeltData data) { Data = data; - Transforms = new float4[data.Asteroids.Length]; - PreviousTransforms = new float4[data.Asteroids.Length]; + Positions = new float3[data.Asteroids.Length]; + NewPositions = new float3[data.Asteroids.Length]; + Velocities = new float2[data.Asteroids.Length]; + NewVelocities = new float2[data.Asteroids.Length]; + Rotations = new float[data.Asteroids.Length]; + NewRotations = new float[data.Asteroids.Length]; + Scales = new float[data.Asteroids.Length]; + NewScales = new float[data.Asteroids.Length]; } } diff --git a/Economy.Shared.Unity.csproj b/Economy.Shared.Unity.csproj index bd12f6228..a244e809a 100644 --- a/Economy.Shared.Unity.csproj +++ b/Economy.Shared.Unity.csproj @@ -560,6 +560,9 @@ E:/Projects/Aetheria-Economy/Assets/Allegorithmic/Plugins/Substance/Substance Engine/Editor/Substance.Editor.dll + + E:/Projects/Aetheria-Economy/Library/PackageCache/com.unity.burst@1.4.3/Unity.Burst.Unsafe.dll + C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll diff --git a/MessagePack.csproj b/MessagePack.csproj index 784e2be15..04cadb7db 100644 --- a/MessagePack.csproj +++ b/MessagePack.csproj @@ -417,6 +417,9 @@ E:/Projects/Aetheria-Economy/Assets/Allegorithmic/Plugins/Substance/Substance Engine/Editor/Substance.Editor.dll + + E:/Projects/Aetheria-Economy/Library/PackageCache/com.unity.burst@1.4.3/Unity.Burst.Unsafe.dll + C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll diff --git a/Packages/manifest.json b/Packages/manifest.json index 160f89c8b..d770a7f7c 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -2,6 +2,7 @@ "dependencies": { "com.unity.2d.sprite": "1.0.0", "com.unity.2d.tilemap": "1.0.0", + "com.unity.burst": "1.4.3", "com.unity.cinemachine": "2.6.3", "com.unity.ide.rider": "2.0.7", "com.unity.ide.visualstudio": "2.0.5", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 8bb9b7c99..ef98e52eb 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -12,6 +12,15 @@ "source": "builtin", "dependencies": {} }, + "com.unity.burst": { + "version": "1.4.3", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.mathematics": "1.2.1" + }, + "url": "https://packages.unity.com" + }, "com.unity.cinemachine": { "version": "2.6.3", "depth": 0, diff --git a/Substance.EditorHelper.csproj b/Substance.EditorHelper.csproj index 14c467c96..2333b536b 100644 --- a/Substance.EditorHelper.csproj +++ b/Substance.EditorHelper.csproj @@ -321,6 +321,9 @@ E:/Projects/Aetheria-Economy/Assets/Allegorithmic/Plugins/Substance/Substance Engine/Editor/Substance.Editor.dll + + E:/Projects/Aetheria-Economy/Library/PackageCache/com.unity.burst@1.4.3/Unity.Burst.Unsafe.dll + C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll diff --git a/Substance.Platform.csproj b/Substance.Platform.csproj index ba6cea1f8..058a04302 100644 --- a/Substance.Platform.csproj +++ b/Substance.Platform.csproj @@ -321,6 +321,9 @@ E:/Projects/Aetheria-Economy/Assets/Allegorithmic/Plugins/Substance/Substance Engine/Editor/Substance.Editor.dll + + E:/Projects/Aetheria-Economy/Library/PackageCache/com.unity.burst@1.4.3/Unity.Burst.Unsafe.dll + C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll diff --git a/UniRx.csproj b/UniRx.csproj index 0b006e6ba..46ef4e74f 100644 --- a/UniRx.csproj +++ b/UniRx.csproj @@ -560,6 +560,9 @@ E:/Projects/Aetheria-Economy/Assets/Allegorithmic/Plugins/Substance/Substance Engine/Editor/Substance.Editor.dll + + E:/Projects/Aetheria-Economy/Library/PackageCache/com.unity.burst@1.4.3/Unity.Burst.Unsafe.dll + C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll