diff --git a/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml b/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml
index 847167c23..8cb05b259 100644
--- a/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml
+++ b/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml
@@ -1439,8 +1439,8 @@
-
+
@@ -1464,6 +1464,7 @@
+
@@ -1870,6 +1871,7 @@
+
diff --git a/.idea/.idea.Economy/.idea/contentModel.xml b/.idea/.idea.Economy/.idea/contentModel.xml
index f4a8b2486..5c786ed7d 100644
--- a/.idea/.idea.Economy/.idea/contentModel.xml
+++ b/.idea/.idea.Economy/.idea/contentModel.xml
@@ -9,8 +9,8 @@
-
+
@@ -33,6 +33,7 @@
+
@@ -439,6 +440,7 @@
+
diff --git a/Aetheria-Economy.sln b/Aetheria-Economy.sln
index c422ea2e1..0e57f1069 100644
--- a/Aetheria-Economy.sln
+++ b/Aetheria-Economy.sln
@@ -1,9 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Economy.Shared.Unity", "Economy.Shared.Unity.csproj", "{A62B36C2-E9DE-B992-0779-F5FCF5968986}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{29B684F0-E616-CD9C-EFF8-10A39DB37A52}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Economy.Shared.Unity", "Economy.Shared.Unity.csproj", "{A62B36C2-E9DE-B992-0779-F5FCF5968986}"
+EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagePack", "MessagePack.csproj", "{21EF11C5-27DC-3D88-B027-9A4B6F36BAE4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-firstpass", "Assembly-CSharp-firstpass.csproj", "{7D8742A4-0DFC-5667-0A98-3CA4312F9253}"
@@ -16,14 +16,14 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {A62B36C2-E9DE-B992-0779-F5FCF5968986}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A62B36C2-E9DE-B992-0779-F5FCF5968986}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A62B36C2-E9DE-B992-0779-F5FCF5968986}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A62B36C2-E9DE-B992-0779-F5FCF5968986}.Release|Any CPU.Build.0 = Release|Any CPU
{29B684F0-E616-CD9C-EFF8-10A39DB37A52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{29B684F0-E616-CD9C-EFF8-10A39DB37A52}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29B684F0-E616-CD9C-EFF8-10A39DB37A52}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29B684F0-E616-CD9C-EFF8-10A39DB37A52}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A62B36C2-E9DE-B992-0779-F5FCF5968986}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A62B36C2-E9DE-B992-0779-F5FCF5968986}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A62B36C2-E9DE-B992-0779-F5FCF5968986}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A62B36C2-E9DE-B992-0779-F5FCF5968986}.Release|Any CPU.Build.0 = Release|Any CPU
{21EF11C5-27DC-3D88-B027-9A4B6F36BAE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21EF11C5-27DC-3D88-B027-9A4B6F36BAE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21EF11C5-27DC-3D88-B027-9A4B6F36BAE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity
index 7b829e803..7ac15fd1d 100644
--- a/Assets/Scenes/Main.unity
+++ b/Assets/Scenes/Main.unity
@@ -503,17 +503,17 @@ PrefabInstance:
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchorMin.y
- value: 0
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchorMax.y
- value: 0
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchoredPosition.y
- value: 0
+ value: -26.586945
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
@@ -523,7 +523,7 @@ PrefabInstance:
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_SizeDelta.y
- value: 0
+ value: 45.17389
objectReference: {fileID: 0}
- target: {fileID: 7200536746924797989, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
@@ -4593,13 +4593,13 @@ MonoBehaviour:
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_textInfo:
textComponent: {fileID: 258993626}
- characterCount: 0
+ characterCount: 13
spriteCount: 0
- spaceCount: 0
- wordCount: 0
+ spaceCount: 2
+ wordCount: 2
linkCount: 0
- lineCount: 0
- pageCount: 0
+ lineCount: 1
+ pageCount: 1
materialCount: 1
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
@@ -11572,17 +11572,17 @@ PrefabInstance:
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchorMin.y
- value: 0
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchorMax.y
- value: 0
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchoredPosition.y
- value: 0
+ value: -26.586945
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
@@ -11592,7 +11592,7 @@ PrefabInstance:
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_SizeDelta.y
- value: 0
+ value: 45.17389
objectReference: {fileID: 0}
- target: {fileID: 7200536746924797989, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
@@ -12623,17 +12623,17 @@ PrefabInstance:
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchorMin.y
- value: 0
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchorMax.y
- value: 0
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchoredPosition.y
- value: 0
+ value: -26.586945
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
@@ -12643,7 +12643,7 @@ PrefabInstance:
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_SizeDelta.y
- value: 0
+ value: 45.17389
objectReference: {fileID: 0}
- target: {fileID: 7200536746924797989, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
@@ -17573,13 +17573,13 @@ MonoBehaviour:
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_textInfo:
textComponent: {fileID: 904172350}
- characterCount: 0
+ characterCount: 2
spriteCount: 0
spaceCount: 0
- wordCount: 0
+ wordCount: 1
linkCount: 0
- lineCount: 0
- pageCount: 0
+ lineCount: 1
+ pageCount: 1
materialCount: 1
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
@@ -24811,17 +24811,17 @@ PrefabInstance:
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchorMin.y
- value: 0
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchorMax.y
- value: 0
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchoredPosition.y
- value: 0
+ value: -26.586945
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
@@ -24831,7 +24831,7 @@ PrefabInstance:
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_SizeDelta.y
- value: 0
+ value: 45.17389
objectReference: {fileID: 0}
- target: {fileID: 7200536746924797989, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
@@ -38696,17 +38696,17 @@ PrefabInstance:
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchorMin.y
- value: 0
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchorMax.y
- value: 0
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchoredPosition.y
- value: 0
+ value: -26.586945
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
@@ -38716,7 +38716,7 @@ PrefabInstance:
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_SizeDelta.y
- value: 0
+ value: 45.17389
objectReference: {fileID: 0}
- target: {fileID: 7200536746924797989, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
@@ -43789,17 +43789,17 @@ PrefabInstance:
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchorMin.y
- value: 0
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchorMax.y
- value: 0
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_AnchoredPosition.y
- value: 0
+ value: -26.586945
objectReference: {fileID: 0}
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
@@ -43809,7 +43809,7 @@ PrefabInstance:
- target: {fileID: 6493174789768221420, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
propertyPath: m_SizeDelta.y
- value: 0
+ value: 45.17389
objectReference: {fileID: 0}
- target: {fileID: 7200536746924797989, guid: b93e36d73a071274d8e9225e077ce92a,
type: 3}
diff --git a/Assets/Scripts/Editor/DatabaseInspector.cs b/Assets/Scripts/Editor/DatabaseInspector.cs
index dd32ccf91..ed6f12ccb 100644
--- a/Assets/Scripts/Editor/DatabaseInspector.cs
+++ b/Assets/Scripts/Editor/DatabaseInspector.cs
@@ -784,7 +784,7 @@ public class DatabaseInspector : EditorWindow
{
using (new VerticalScope())
{
- var behaviorNames = item.Behaviors.Select(b => b.GetType().Name).ToArray();
+ var behaviorNames = new []{item.Name}.Concat(item.Behaviors.Select(b => b.GetType().Name)).ToArray();
var selectedBehaviorIndex = Array.IndexOf(behaviorNames, effect.Behavior);
if (selectedBehaviorIndex == -1)
{
@@ -794,42 +794,32 @@ public class DatabaseInspector : EditorWindow
using (new HorizontalScope())
{
GUILayout.Label("Behavior", GUILayout.Width(width));
- if(behaviorNames.Length==0)
- GUILayout.Label("No Behaviors!");
- else
- {
- var newSelection = Popup(selectedBehaviorIndex, behaviorNames);
- if (newSelection != selectedBehaviorIndex)
- GUI.changed = true;
- effect.Behavior = behaviorNames[newSelection];
- }
+ var newSelection = Popup(selectedBehaviorIndex, behaviorNames);
+ if (newSelection != selectedBehaviorIndex)
+ GUI.changed = true;
+ effect.Behavior = behaviorNames[newSelection];
}
using (new HorizontalScope())
{
GUILayout.Label("Stat", GUILayout.Width(width));
- if(behaviorNames.Length==0)
- GUILayout.Label("No Behaviors!");
+ var stats = (selectedBehaviorIndex == 0 ? item.GetType() : item.Behaviors[selectedBehaviorIndex-1].GetType()).GetFields()
+ .Where(f => f.FieldType == typeof(PerformanceStat)).ToArray();
+ if(stats.Length==0)
+ GUILayout.Label("No Stats!");
else
{
- var stats = item.Behaviors[selectedBehaviorIndex].GetType().GetFields()
- .Where(f => f.FieldType == typeof(PerformanceStat)).ToArray();
- if(stats.Length==0)
- GUILayout.Label("No Stats!");
- else
+ var statNames = stats.Select(s => s.Name).ToArray();
+ var selectedStatIndex = Array.IndexOf(statNames, effect.Stat);
+ if (selectedStatIndex == -1)
{
- var statNames = stats.Select(s => s.Name).ToArray();
- var selectedStatIndex = Array.IndexOf(statNames, effect.Stat);
- if (selectedStatIndex == -1)
- {
- selectedStatIndex = 0;
- GUI.changed = true;
- }
- var newSelection = Popup(selectedStatIndex, statNames);
- if (newSelection != selectedStatIndex)
- GUI.changed = true;
- effect.Stat = statNames[newSelection];
+ selectedStatIndex = 0;
+ GUI.changed = true;
}
+ var newSelection = Popup(selectedStatIndex, statNames);
+ if (newSelection != selectedStatIndex)
+ GUI.changed = true;
+ effect.Stat = statNames[newSelection];
}
}
}
diff --git a/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs b/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs
index 4ee3f6aee..ad05255fb 100644
--- a/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs
+++ b/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs
@@ -31,7 +31,7 @@ public interface IAnalogBehavior : IBehavior
}
[InspectableField,
- Union(0, typeof(CannonData)),
+ Union(0, typeof(ProjectileWeaponData)),
Union(1, typeof(LauncherData)),
Union(2, typeof(ReactorData)),
Union(3, typeof(RadiatorData)),
diff --git a/Assets/Scripts/ServerShared/Behaviors/Cannon.cs b/Assets/Scripts/ServerShared/Behaviors/ProjectileWeapon.cs
similarity index 57%
rename from Assets/Scripts/ServerShared/Behaviors/Cannon.cs
rename to Assets/Scripts/ServerShared/Behaviors/ProjectileWeapon.cs
index 815173f4c..c813f2e19 100644
--- a/Assets/Scripts/ServerShared/Behaviors/Cannon.cs
+++ b/Assets/Scripts/ServerShared/Behaviors/ProjectileWeapon.cs
@@ -2,7 +2,7 @@ using MessagePack;
using Newtonsoft.Json;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
-public class CannonData : WeaponData, IBehaviorData
+public class ProjectileWeaponData : WeaponData, IBehaviorData
{
[InspectablePrefab, JsonProperty("bullet"), Key(9)]
public string BulletPrefab;
@@ -18,31 +18,31 @@ public class CannonData : WeaponData, IBehaviorData
public IBehavior CreateInstance(GameContext context, Entity entity, Gear item)
{
- return new Cannon(context, this, entity, item);
+ return new ProjectileWeapon(context, this, entity, item);
}
}
-public class Cannon : IActivatedBehavior
+public class ProjectileWeapon : IActivatedBehavior
{
private bool _firing;
private float _cooldown; // normalized
- private CannonData _cannon;
+ private ProjectileWeaponData _projectileWeapon;
public Entity Entity { get; }
public Gear Item { get; }
public GameContext Context { get; }
private float _firingVisibility;
- public Cannon(GameContext context, CannonData c, Entity entity, Gear item)
+ public ProjectileWeapon(GameContext context, ProjectileWeaponData c, Entity entity, Gear item)
{
Context = context;
- _cannon = c;
+ _projectileWeapon = c;
Entity = entity;
Item = item;
}
public void Activate()
{
-// Debug.Log("Activating Cannon");
+// Debug.Log("Activating ProjectileWeapon");
// _firing = true;
// Observable.EveryUpdate().TakeWhile(_ => _firing).Subscribe(_ =>
// {
@@ -51,8 +51,8 @@ public class Cannon : IActivatedBehavior
// {
// _cooldown = 1;
// Fire(0);
-// if(_cannon.BurstCount>1)
-// Observable.Interval(TimeSpan.FromSeconds(_cannon.BurstTime.Evaluate(Hardpoint) / (_cannon.BurstCount-1))).Take(_cannon.BurstCount-1)
+// if(_projectileWeapon.BurstCount>1)
+// Observable.Interval(TimeSpan.FromSeconds(_projectileWeapon.BurstTime.Evaluate(Hardpoint) / (_projectileWeapon.BurstCount-1))).Take(_projectileWeapon.BurstCount-1)
// .Subscribe(l => Fire(l+1));
// }
// });
@@ -60,19 +60,19 @@ public class Cannon : IActivatedBehavior
private void Fire(long b)
{
- // _firingVisibility += _cannon.Visibility.Evaluate(Hardpoint);
- // Hardpoint.Temperature += _cannon.Heat.Evaluate(Hardpoint) / Hardpoint.HeatCapacity;
- // var inst = GameObject.Instantiate(_cannon.BulletPrefab).transform;
+ // _firingVisibility += _projectileWeapon.Visibility.Evaluate(Hardpoint);
+ // Hardpoint.Temperature += _projectileWeapon.Heat.Evaluate(Hardpoint) / Hardpoint.HeatCapacity;
+ // var inst = GameObject.Instantiate(_projectileWeapon.BulletPrefab).transform;
// Physics.IgnoreCollision(Hardpoint.Ship.Ship.GetComponent(), inst.GetComponent());
// var bullet = inst.GetComponent();
// bullet.Target = Hardpoint.Ship.Ship.Target;
// bullet.Source = Hardpoint.Ship.Ship.Hitpoints;
- // bullet.Lifetime = _cannon.Range.Evaluate(Hardpoint) / _cannon.Velocity.Evaluate(Hardpoint);
- // bullet.Damage = _cannon.Damage.Evaluate(Hardpoint);
+ // bullet.Lifetime = _projectileWeapon.Range.Evaluate(Hardpoint) / _projectileWeapon.Velocity.Evaluate(Hardpoint);
+ // bullet.Damage = _projectileWeapon.Damage.Evaluate(Hardpoint);
// inst.position = Hardpoint.Proxy.position;
// inst.rotation = Hardpoint.Proxy.rotation;
- // inst.GetComponent().velocity = _cannon.Velocity.Evaluate(Hardpoint) * Vector3.RotateTowards(-inst.forward, Hardpoint.Ship.Ship.Direction, _cannon.Deflection * Mathf.Deg2Rad, 1);
- // Hardpoint.Ship.Ship.AudioSource.PlayOneShot(_cannon.Sounds.RandomElement());
+ // inst.GetComponent().velocity = _projectileWeapon.Velocity.Evaluate(Hardpoint) * Vector3.RotateTowards(-inst.forward, Hardpoint.Ship.Ship.Direction, _projectileWeapon.Deflection * Mathf.Deg2Rad, 1);
+ // Hardpoint.Ship.Ship.AudioSource.PlayOneShot(_projectileWeapon.Sounds.RandomElement());
// Debug.Log($"Firing bullet {b}");
}
@@ -87,9 +87,9 @@ public class Cannon : IActivatedBehavior
public void Update(float delta)
{
- _cooldown -= delta / Context.Evaluate(_cannon.Cooldown, Item, Entity);
+ _cooldown -= delta / Context.Evaluate(_projectileWeapon.Cooldown, Item, Entity);
- _firingVisibility *= Context.Evaluate(_cannon.VisibilityDecay, Item, Entity);
+ _firingVisibility *= Context.Evaluate(_projectileWeapon.VisibilityDecay, Item, Entity);
if (_firingVisibility < 0.01f)
{
@@ -97,5 +97,5 @@ public class Cannon : IActivatedBehavior
}
}
- public IBehaviorData Data => _cannon;
+ public IBehaviorData Data => _projectileWeapon;
}
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/Behaviors/Cannon.cs.meta b/Assets/Scripts/ServerShared/Behaviors/ProjectileWeapon.cs.meta
similarity index 100%
rename from Assets/Scripts/ServerShared/Behaviors/Cannon.cs.meta
rename to Assets/Scripts/ServerShared/Behaviors/ProjectileWeapon.cs.meta
diff --git a/Assets/Scripts/ServerShared/Behaviors/Weapon.cs b/Assets/Scripts/ServerShared/Behaviors/Weapon.cs
index cc5a6f0e5..5ebe0525d 100644
--- a/Assets/Scripts/ServerShared/Behaviors/Weapon.cs
+++ b/Assets/Scripts/ServerShared/Behaviors/Weapon.cs
@@ -1,7 +1,7 @@
using MessagePack;
using Newtonsoft.Json;
-[Union(0, typeof(CannonData)),
+[Union(0, typeof(ProjectileWeaponData)),
Union(1, typeof(LauncherData))]
public abstract class WeaponData
{
diff --git a/Assets/Scripts/ServerShared/DatabaseItems.cs b/Assets/Scripts/ServerShared/DatabaseItems.cs
index c833829fb..9f024fe9e 100644
--- a/Assets/Scripts/ServerShared/DatabaseItems.cs
+++ b/Assets/Scripts/ServerShared/DatabaseItems.cs
@@ -30,7 +30,7 @@ public interface INamedEntry
Union(11, typeof(Player)),
Union(12, typeof(Corporation)),
Union(13, typeof(Ship)),
- Union(14, typeof(Station)),
+ Union(14, typeof(StationData)),
Union(15, typeof(OrbitData)),
Union(16, typeof(PlanetData)),
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter))]
diff --git a/Assets/Scripts/ServerShared/Entity.cs b/Assets/Scripts/ServerShared/Entity.cs
index 1e51fc5f3..fc1579ce4 100644
--- a/Assets/Scripts/ServerShared/Entity.cs
+++ b/Assets/Scripts/ServerShared/Entity.cs
@@ -14,6 +14,7 @@ public class Entity
public float Energy;
public float2 Position;
public float2 Direction;
+ public float2 Velocity;
protected readonly GameContext Context;
protected readonly List Behaviors;
diff --git a/Assets/Scripts/ServerShared/GameContext.cs b/Assets/Scripts/ServerShared/GameContext.cs
index 7575e7c67..ab1c761b5 100644
--- a/Assets/Scripts/ServerShared/GameContext.cs
+++ b/Assets/Scripts/ServerShared/GameContext.cs
@@ -7,23 +7,87 @@ using static Unity.Mathematics.math;
public class GameContext
{
private Action _logger;
- private DatabaseCache _cache;
-
- public GlobalData GlobalData => _cache.GetAll().FirstOrDefault();
-
+
+ private Dictionary AffectedStats =
+ new Dictionary();
+
+ private double _time;
+ private float _deltaTime;
+
+ public GlobalData GlobalData => Cache.GetAll().FirstOrDefault();
+ public DatabaseCache Cache { get; }
+
+ public double Time
+ {
+ get => _time;
+ set
+ {
+ _deltaTime = (float) (value - _time);
+ _time = value;
+ }
+ }
+
+ private Dictionary> ZoneContents = new Dictionary>();
+
// private readonly Dictionary Tier = new Dictionary();
public GameContext(DatabaseCache cache, Action logger)
{
- _cache = cache;
+ Cache = cache;
_logger = logger;
- var globalData = _cache.GetAll().FirstOrDefault();
+ var globalData = Cache.GetAll().FirstOrDefault();
if (globalData == null)
{
globalData = new GlobalData();
- _cache.Add(globalData);
+ Cache.Add(globalData);
}
}
+
+ public void Log(string s)
+ {
+ _logger(s);
+ }
+
+ public Dictionary InitializeZone(Guid zoneID)
+ {
+ var contents = new Dictionary();
+
+ var zoneData = Cache.Get(zoneID);
+
+ var planetsData = zoneData.Planets.Select(id => Cache.Get(id)).ToArray();
+ var planetEntities = planetsData.ToDictionary(p => p,
+ p => new OrbitalEntity(this, Enumerable.Empty(), Enumerable.Empty(), p.Orbit));
+ foreach(var kvp in planetEntities)
+ contents.Add(kvp.Key, kvp.Value);
+
+ var stationsData = zoneData.Stations.Select(id => Cache.Get(id));
+ var stationEntities = stationsData.ToDictionary(s => s,
+ s => new OrbitalEntity(this, Enumerable.Empty(), Enumerable.Empty(), s.Parent));
+ foreach(var kvp in stationEntities)
+ contents.Add(kvp.Key, kvp.Value);
+
+ ZoneContents.Add(zoneData, contents);
+
+ return contents;
+ }
+
+ public void Update()
+ {
+ foreach (var kvp in ZoneContents)
+ {
+ var zone = kvp.Key;
+ var entities = kvp.Value.Values;
+ foreach (var entity in entities)
+ {
+ entity.Update(_deltaTime);
+ }
+ }
+ }
+
+ public void UnloadZone(ZoneData zone)
+ {
+ ZoneContents.Remove(zone);
+ }
// public int ItemTier(CraftedItemData itemData)
// {
@@ -36,22 +100,22 @@ public class GameContext
public ItemData GetData(ItemInstance item)
{
- return _cache.Get(item.Data);
+ return Cache.Get(item.Data);
}
public SimpleCommodityData GetData(SimpleCommodity item)
{
- return _cache.Get(item.Data);
+ return Cache.Get(item.Data);
}
public CraftedItemData GetData(CraftedItemInstance item)
{
- return _cache.Get(item.Data);
+ return Cache.Get(item.Data);
}
public EquippableItemData GetData(Gear gear)
{
- return _cache.Get(gear.Data);
+ return Cache.Get(gear.Data);
}
public float GetMass(ItemInstance item)
@@ -82,16 +146,13 @@ public class GameContext
return 0;
}
- private Dictionary AffectedStats =
- new Dictionary();
-
public PerformanceStat GetAffectedStat(BlueprintData blueprint, BlueprintStatEffect effect)
{
// We've already cached this effect's stat, return it directly
if (AffectedStats.ContainsKey(effect)) return AffectedStats[effect];
// Get the data for the item the blueprint is for, return null if not found or not equippable
- var blueprintItem = _cache.Get(blueprint.Item);
+ var blueprintItem = Cache.Get(blueprint.Item);
if (blueprintItem == null)
{
_logger($"Attempted to get stat effect but Blueprint {blueprint.ID} is not for an equippable item!");
@@ -99,25 +160,25 @@ public class GameContext
}
// Get the first behavior of the type specified in the blueprint stat effect, return null if not found
- var effectBehavior =
+ var effectObject = effect.StatReference.Behavior == blueprintItem.Name ? (object) blueprintItem :
blueprintItem.Behaviors.FirstOrDefault(b => b.GetType().Name == effect.StatReference.Behavior);
- if (effectBehavior == null)
+ if (effectObject == null)
{
_logger($"Attempted to get stat effect for Blueprint {blueprint.ID} but stat references missing behavior \"{effect.StatReference.Behavior}\"!");
return AffectedStats[effect] = null;
}
// Get the first field in the behavior matching the name specified in the stat effect, return null if not found
- var type = effectBehavior.GetType();
+ var type = effectObject.GetType();
var field = type.GetField(effect.StatReference.Stat);
if (field == null)
{
- _logger($"Attempted to get stat effect for Blueprint {blueprint.ID} but behavior {effect.StatReference.Behavior} does not have a stat named \"{effect.StatReference.Stat}\"!");
+ _logger($"Attempted to get stat effect for Blueprint {blueprint.ID} but object {effect.StatReference.Behavior} does not have a stat named \"{effect.StatReference.Stat}\"!");
return AffectedStats[effect] = null;
}
// Finally we've confirmed the stat effect is valid, return the affected stat
- return AffectedStats[effect] = field.GetValue(effectBehavior) as PerformanceStat;
+ return AffectedStats[effect] = field.GetValue(effectObject) as PerformanceStat;
}
// Determine quality of either the item itself or the specific ingredient this stat depends on
@@ -170,7 +231,7 @@ public class GameContext
var itemData = GetData(item);
var heat = !stat.HeatDependent ? 1 : pow(itemData.Performance(entity.Temperature), Evaluate(itemData.HeatExponent,item));
- var durability = !stat.DurabilityDependent ? 1 : pow(item.Durability / itemData.Durability, Evaluate(itemData.DurabilityExponent,item));
+ var durability = !stat.DurabilityDependent ? 1 : pow(item.Durability / Evaluate(itemData.Durability, item), Evaluate(itemData.DurabilityExponent,item));
var quality = pow(Quality(stat, item), stat.QualityExponent);
var scaleModifier = stat.GetScaleModifiers(entity).Values.Aggregate(1.0f, (current, mod) => current * mod);
@@ -185,7 +246,7 @@ public class GameContext
public SimpleCommodity CreateInstance(Guid data, int count)
{
- var item = _cache.Get(data);
+ var item = Cache.Get(data);
if (item != null)
return new SimpleCommodity
{
@@ -200,14 +261,14 @@ public class GameContext
public CraftedItemInstance CreateInstance(Guid data, float quality)
{
- var item = _cache.Get(data);
+ var item = Cache.Get(data);
if (item == null)
{
_logger("Attempted to create crafted item instance using missing or incorrect item id!");
return null;
}
- var blueprint = _cache.GetAll().FirstOrDefault(b => b.Item == data);
+ var blueprint = Cache.GetAll().FirstOrDefault(b => b.Item == data);
if (blueprint == null)
{
_logger("Attempted to create crafted item instance which has no blueprint!");
@@ -216,7 +277,7 @@ public class GameContext
var ingredients = blueprint.Ingredients.SelectMany(ci =>
{
- var ingredient = _cache.Get(ci.Key);
+ var ingredient = Cache.Get(ci.Key);
return ingredient is SimpleCommodityData
? (IEnumerable) new[] {CreateInstance(ci.Key, ci.Value)}
: Enumerable.Range(0, ci.Value).Select(i => CreateInstance(ci.Key, quality));
@@ -225,15 +286,16 @@ public class GameContext
if (item is EquippableItemData equippableItemData)
{
- return new Gear
+ var newGear = new Gear
{
Context = this,
Data = data,
- Durability = equippableItemData.Durability,
ID = Guid.NewGuid(),
Ingredients = ingredients,
Quality = quality
};
+ newGear.Durability = Evaluate(equippableItemData.Durability, newGear);
+ return newGear;
}
return new CompoundCommodity
@@ -245,4 +307,4 @@ public class GameContext
Quality = quality
};
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/ItemData.cs b/Assets/Scripts/ServerShared/ItemData.cs
index 613a46c1d..ead467c67 100644
--- a/Assets/Scripts/ServerShared/ItemData.cs
+++ b/Assets/Scripts/ServerShared/ItemData.cs
@@ -87,8 +87,8 @@ public abstract class EquippableItemData : CraftedItemData
[TemperatureInspectable, JsonProperty("maxTemp"), Key(9)]
public float MaximumTemperature;
- [InspectableField, JsonProperty("durability"), Key(10)]
- public float Durability;
+ [InspectableField, JsonProperty("durabilityStat"), Key(10)]
+ public PerformanceStat Durability = new PerformanceStat();
[InspectableField, JsonProperty("durabilityExponent"), Key(11)]
public PerformanceStat DurabilityExponent = new PerformanceStat();
diff --git a/Assets/Scripts/ServerShared/Locomotion.cs b/Assets/Scripts/ServerShared/Locomotion.cs
new file mode 100644
index 000000000..1699e8ba7
--- /dev/null
+++ b/Assets/Scripts/ServerShared/Locomotion.cs
@@ -0,0 +1,17 @@
+using System.Collections;
+using System.Collections.Generic;
+
+public class Locomotion
+{
+ // Start is called before the first frame update
+ void Start()
+ {
+
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+
+ }
+}
diff --git a/Assets/Scripts/ServerShared/Locomotion.cs.meta b/Assets/Scripts/ServerShared/Locomotion.cs.meta
new file mode 100644
index 000000000..b9865e02d
--- /dev/null
+++ b/Assets/Scripts/ServerShared/Locomotion.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c3af5050375d08242a52bdf7f7de558e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/ServerShared/OrbitalEntity.cs b/Assets/Scripts/ServerShared/OrbitalEntity.cs
new file mode 100644
index 000000000..b82a70510
--- /dev/null
+++ b/Assets/Scripts/ServerShared/OrbitalEntity.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using Unity.Mathematics;
+using static Unity.Mathematics.math;
+using float2 = Unity.Mathematics.float2;
+
+public class OrbitalEntity : Entity
+{
+ private Guid _orbitData;
+ private static Dictionary _orbitPositions = new Dictionary();
+
+ public OrbitalEntity(GameContext context, IEnumerable items, IEnumerable cargo, Guid orbit) : base(context, items, cargo)
+ {
+ _orbitData = orbit;
+ }
+
+ public static void ClearOrbits()
+ {
+ _orbitPositions.Clear();
+ }
+
+ // Determine orbital position recursively, caching parent positions to avoid repeated calculations
+ private float2 GetOrbitPosition(Guid orbit)
+ {
+ // Root orbit is fixed at center
+ if(orbit==Guid.Empty)
+ return float2.zero;
+
+ if (!_orbitPositions.ContainsKey(orbit))
+ {
+ var orbitData = Context.Cache.Get(orbit);
+ _orbitPositions[orbit] = GetOrbitPosition(orbitData.Parent) + (orbitData.Period < .01f ? float2.zero :
+ OrbitData.Evaluate((float) (Context.Time / -orbitData.Period + orbitData.Phase)) *
+ orbitData.Distance);
+ }
+
+ var position = _orbitPositions[orbit];
+ if (float.IsNaN(position.x))
+ {
+ Context.Log("Orbit position is NaN, something went very wrong!");
+ return float2.zero;
+ }
+ return _orbitPositions[orbit];
+ }
+
+ public override void Update(float delta)
+ {
+ var newPosition = GetOrbitPosition(_orbitData);
+ Velocity = (newPosition - Position) / delta;
+ Position = newPosition;
+ base.Update(delta);
+ }
+}
diff --git a/Assets/Scripts/ServerShared/OrbitalEntity.cs.meta b/Assets/Scripts/ServerShared/OrbitalEntity.cs.meta
new file mode 100644
index 000000000..212ccaab0
--- /dev/null
+++ b/Assets/Scripts/ServerShared/OrbitalEntity.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f27ff1f1a3592a446ac8e200a46f7bc0
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/ServerShared/Ship.cs b/Assets/Scripts/ServerShared/Ship.cs
index 0715853a0..0398f16bb 100644
--- a/Assets/Scripts/ServerShared/Ship.cs
+++ b/Assets/Scripts/ServerShared/Ship.cs
@@ -20,10 +20,8 @@ public class Ship : Entity
// [IgnoreMember] public Dictionary Contacts = new Dictionary();
// [IgnoreMember] public Targetable Target;
- [IgnoreMember] public float2 Velocity;
private HullData _hullData;
-
public Ship(GameContext context, IEnumerable items, IEnumerable cargo) : base(context, items, cargo)
{
diff --git a/Assets/Scripts/ServerShared/ZoneData.cs b/Assets/Scripts/ServerShared/ZoneData.cs
index 1968d7152..88fff4987 100644
--- a/Assets/Scripts/ServerShared/ZoneData.cs
+++ b/Assets/Scripts/ServerShared/ZoneData.cs
@@ -41,7 +41,7 @@ public class ZoneData : DatabaseEntry, INamedEntry
}
[RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
-public class Station : DatabaseEntry, INamedEntry
+public class StationData : DatabaseEntry, INamedEntry
{
[JsonProperty("name"), Key(1)]
public string Name;
@@ -90,7 +90,7 @@ public class PlanetData : DatabaseEntry, INamedEntry
[JsonProperty("belt"), Key(5)]
public bool Belt;
- [JsonProperty("resources"), Key(5)]
+ [JsonProperty("resources"), Key(6)]
public Dictionary Resources = new Dictionary();
// [JsonProperty("radius")] [Key(5)]
diff --git a/Assets/Scripts/StrategyGameManager.cs b/Assets/Scripts/StrategyGameManager.cs
index 3c70de4c1..427ceb97e 100644
--- a/Assets/Scripts/StrategyGameManager.cs
+++ b/Assets/Scripts/StrategyGameManager.cs
@@ -34,6 +34,7 @@ public class StrategyGameManager : MonoBehaviour
public float ZoneMassPower = .5f;
public MeshRenderer ZoneBackground;
public MeshRenderer ZoneBoundary;
+ public bool TestMode;
private DatabaseCache _cache;
private GameContext _context;
@@ -43,13 +44,11 @@ public class StrategyGameManager : MonoBehaviour
private Guid _populatedZone;
private Guid _selectedZone;
private GalaxyZone _selectedGalaxyZone;
- private ZoneResponseMessage _zoneResponse;
private Dictionary _galaxyResponseZones;
private Dictionary _galaxyZoneObjects = new Dictionary();
- private Dictionary _zoneObjects = new Dictionary();
- private Dictionary _zoneBelts = new Dictionary();
+ private Dictionary _zoneObjects = new Dictionary();
+ private Dictionary _zoneBelts = new Dictionary();
private List _wormholes = new List();
- private Dictionary _orbitPositions = new Dictionary();
private Vector3 _galaxyCameraPos = -Vector3.forward;
private float _galaxyOrthoSize = 50;
private Material _boundaryMaterial;
@@ -60,36 +59,41 @@ public class StrategyGameManager : MonoBehaviour
{
_galaxyOrthoSize = GalaxyScale / 2;
_cache = new DatabaseCache();
-
- // Request galaxy description from the server
- CultClient.Send(new GalaxyRequestMessage());
-
- // Request blueprints from the server
- CultClient.Send(new BlueprintsRequestMessage());
-
- // Listen for the server's galaxy description
- CultClient.AddMessageListener(galaxy =>
+
+ if (TestMode)
{
- _galaxy = galaxy;
- _galaxyResponseZones = _galaxy.Zones.ToDictionary(z => z.ZoneID);
- _cache.Add(_galaxy.GlobalData, true);
- _context = new GameContext(_cache, Debug.Log);
- if (_currentTab == GalaxyTabButton && !_galaxyPopulated) PopulateGalaxy();
- });
-
- CultClient.AddMessageListener(response => _cache.AddAll(response.Blueprints, true));
-
- // Listen for zone descriptions from the server
- CultClient.AddMessageListener(zone =>
+
+ }
+ else
{
- _zoneResponse = zone;
+ // Request galaxy description from the server
+ CultClient.Send(new GalaxyRequestMessage());
+
+ // Request blueprints from the server
+ CultClient.Send(new BlueprintsRequestMessage());
+
+ // Listen for the server's galaxy description
+ CultClient.AddMessageListener(galaxy =>
+ {
+ _galaxy = galaxy;
+ _galaxyResponseZones = _galaxy.Zones.ToDictionary(z => z.ZoneID);
+ _cache.Add(_galaxy.GlobalData, true);
+ _context = new GameContext(_cache, Debug.Log);
+ if (_currentTab == GalaxyTabButton && !_galaxyPopulated) PopulateGalaxy();
+ });
+
+ CultClient.AddMessageListener(response => _cache.AddAll(response.Blueprints, true));
+
+ // Listen for zone descriptions from the server
+ CultClient.AddMessageListener(zone =>
+ {
+ // Cache zone data and contents
+ _cache.Add(zone.Zone);
+ foreach (var entry in zone.Contents) _cache.Add(entry);
- // Cache zone data and contents
- _cache.Add(zone.Zone);
- foreach (var entry in zone.Contents) _cache.Add(entry);
-
- if (_currentTab == ZoneTabButton && _populatedZone != zone.Zone.ID) PopulateZone();
- });
+ if (_currentTab == ZoneTabButton && _populatedZone != zone.Zone.ID) PopulateZone();
+ });
+ }
PrimaryTabGroup.OnTabChange += button =>
{
@@ -103,7 +107,7 @@ public class StrategyGameManager : MonoBehaviour
if (_currentTab == ZoneTabButton)
{
- if (_populatedZone != _selectedZone && _zoneResponse?.Zone.ID == _selectedZone)
+ if (_populatedZone != _selectedZone)
PopulateZone();
Camera.transform.position = -Vector3.forward;
}
@@ -112,6 +116,7 @@ public class StrategyGameManager : MonoBehaviour
{
if (!_techLayoutGenerated)
{
+ TechTree.Initialize();
TechTree.Blueprints = _cache.GetAll().ToArray();
TechTree.GenerateTechs();
}
@@ -124,6 +129,8 @@ public class StrategyGameManager : MonoBehaviour
private void Update()
{
+ _context.Time = Time.time;
+ _context.Update();
if (_currentTab == GalaxyTabButton)
{
_galaxyCameraPos = Camera.transform.position;
@@ -131,47 +138,18 @@ public class StrategyGameManager : MonoBehaviour
}
if (_currentTab == ZoneTabButton && _populatedZone == _selectedZone)
{
- _orbitPositions.Clear();
foreach (var planet in _zoneObjects)
{
- var planetData = _cache.Get(planet.Key);
-
- planet.Value.transform.position = (Vector2) GetOrbitPosition(planetData.Orbit) * ZoneSizeScale;
+ planet.Value.transform.position = (Vector2) planet.Key.Position * ZoneSizeScale;
}
foreach (var belt in _zoneBelts)
{
- var planetData = _cache.Get(belt.Key);
-
- belt.Value.transform.position = float3(GetOrbitPosition(_cache.Get(planetData.Orbit).Parent) * ZoneSizeScale, .15f);
+ belt.Value.transform.position = float3(belt.Key.Position * ZoneSizeScale, .15f);
}
}
}
- // Determine orbital position recursively, caching parent positions to avoid repeated calculations
- private float2 GetOrbitPosition(Guid orbit)
- {
- // Root orbit is fixed at center
- if(orbit==Guid.Empty)
- return float2.zero;
-
- if (!_orbitPositions.ContainsKey(orbit))
- {
- var orbitData = _cache.Get(orbit);
- _orbitPositions[orbit] = GetOrbitPosition(orbitData.Parent) + (orbitData.Period < .01f ? float2.zero :
- OrbitData.Evaluate(Time.time / -orbitData.Period + orbitData.Phase) *
- orbitData.Distance);
- }
-
- var position = _orbitPositions[orbit];
- if (float.IsNaN(position.x))
- {
- Debug.Log("Orbit position is NaN, something went very wrong!");
- return float2.zero;
- }
- return _orbitPositions[orbit];
- }
-
void PopulateGalaxy()
{
_galaxyPopulated = true;
@@ -240,40 +218,48 @@ public class StrategyGameManager : MonoBehaviour
foreach (var belt in _zoneBelts.Values) Destroy(belt.gameObject);
_zoneBelts.Clear();
+ if(_populatedZone!=Guid.Empty)
+ _context.UnloadZone(_cache.Get(_populatedZone));
+
_populatedZone = _selectedZone;
+ var zoneData = _cache.Get(_populatedZone);
+ var zoneContents = _context.InitializeZone(_populatedZone);
+
float zoneDepth = 0;
- foreach (var entry in _zoneResponse.Contents)
+
+ foreach (var kvp in zoneContents)
{
- if (entry is PlanetData planet)
+ var entity = kvp.Value;
+ if (kvp.Key is PlanetData planetData)
{
- if (!planet.Belt)
+ if (!planetData.Belt)
{
var planetObject = Instantiate(ZoneObjectPrefab, ZoneRoot);
- _zoneObjects[planet.ID] = planetObject;
- planetObject.Label.text = planet.Name;
+ _zoneObjects[entity as OrbitalEntity] = planetObject;
+ planetObject.Label.text = planetData.Name;
planetObject.GravityMesh.gameObject.SetActive(true);
planetObject.GravityMesh.transform.localScale =
- Vector3.one * (pow(planet.Mass, _context.GlobalData.GravityRadiusExponent) *
+ Vector3.one * (pow(planetData.Mass, _context.GlobalData.GravityRadiusExponent) *
_context.GlobalData.GravityRadiusMultiplier * 2 * ZoneSizeScale);
- var depth = pow(planet.Mass, ZoneMassPower) * ZoneMassScale;
+ var depth = pow(planetData.Mass, ZoneMassPower) * ZoneMassScale;
if (depth > zoneDepth)
zoneDepth = depth;
planetObject.GravityMesh.material.SetFloat("_Depth", depth);
planetObject.Icon.material.SetTexture("_MainTex",
- planet.Mass > _context.GlobalData.SunMass ? SunSprite :
- planet.Mass > _context.GlobalData.GasGiantMass ? GasGiantSprite :
+ planetData.Mass > _context.GlobalData.SunMass ? SunSprite :
+ planetData.Mass > _context.GlobalData.GasGiantMass ? GasGiantSprite :
PlanetSprite);
}
else
{
var beltObject = Instantiate(BeltPrefab, ZoneRoot);
- _zoneBelts[planet.ID] = beltObject;
- var orbit = _cache.Get(planet.Orbit);
+ var orbit = _cache.Get(planetData.Orbit);
+ _zoneBelts[entity as OrbitalEntity] = beltObject;
var beltEmission = beltObject.emission;
beltEmission.rateOverTime =
new ParticleSystem.MinMaxCurve(
- pow(planet.Mass,_context.GlobalData.BeltMassExponent)
+ pow(planetData.Mass,_context.GlobalData.BeltMassExponent)
/ _context.GlobalData.BeltMassRatio * orbit.Distance);
var beltShape = beltObject.shape;
beltShape.radius = orbit.Distance * ZoneSizeScale;
@@ -285,18 +271,19 @@ public class StrategyGameManager : MonoBehaviour
}
}
}
- var radius = (_zoneResponse.Zone.Radius * ZoneSizeScale * 2);
+
+ var radius = (zoneData.Radius * ZoneSizeScale * 2);
_backgroundMaterial.SetFloat("_ClipDistance", radius);
_backgroundMaterial.SetFloat("_HeightRange", zoneDepth + _boundaryMaterial.GetFloat("_Depth"));
ZoneBoundary.transform.localScale = Vector3.one * radius;
- foreach (var wormhole in _zoneResponse.Zone.Wormholes)
+ foreach (var wormhole in zoneData.Wormholes)
{
var otherZone = _galaxyResponseZones[wormhole];
var wormholeObject = Instantiate(ZoneObjectPrefab, ZoneRoot);
_wormholes.Add(wormholeObject);
- var direction = otherZone.Position - _zoneResponse.Zone.Position;
- wormholeObject.transform.position = (Vector2) (normalize(direction) * _zoneResponse.Zone.Radius * .95f * ZoneSizeScale);
+ var direction = otherZone.Position - zoneData.Position;
+ wormholeObject.transform.position = (Vector2) (normalize(direction) * zoneData.Radius * .95f * ZoneSizeScale);
wormholeObject.GravityMesh.gameObject.SetActive(false);
wormholeObject.Icon.material.SetTexture("_MainTex", WormholeSprite);
wormholeObject.Label.text = otherZone.Name;
diff --git a/Assets/Scripts/TechTreeMsagl.cs b/Assets/Scripts/TechTreeMsagl.cs
index 77cddc090..279267628 100644
--- a/Assets/Scripts/TechTreeMsagl.cs
+++ b/Assets/Scripts/TechTreeMsagl.cs
@@ -72,6 +72,12 @@ public class TechTreeMsagl : MonoBehaviour
public BlueprintData[] Blueprints { get; set; }
void Start()
+ {
+ if(TestMode)
+ Initialize();
+ }
+
+ public void Initialize()
{
_icons = Resources.LoadAll(IconsPath);
}
@@ -159,18 +165,21 @@ public class TechTreeMsagl : MonoBehaviour
foreach (var sourceBlueprint in Blueprints.Where(sb =>
targetBlueprint.Dependencies.Any(dep => sb.ID == dep)))
{
- graph.Edges.Add(new Edge(nodeMap[sourceBlueprint], nodeMap[targetBlueprint]));
+ var edge = new Edge(nodeMap[sourceBlueprint], nodeMap[targetBlueprint]);
+ graph.Edges.Add(edge);
var splitName = sourceBlueprint.Name.Split(' ');
if (splitName.Length > 1)
{
var nameStart = string.Join(" ", splitName.Take(splitName.Length - 1));
if(targetBlueprint.Name.StartsWith(nameStart))
- settings.AddSameLayerNeighbors(nodeMap[sourceBlueprint], nodeMap[targetBlueprint]);
+ edge.Weight *= 10;
}
}
}
}
+ settings.BrandesThreshold = 9999;
+
var islands = graph.GetClusteredConnectedComponents();
var islandMap =
graph.Nodes.ToDictionary(n => n, n => islands.Find(c => c.Nodes.Any(cn => cn.UserData == n)));
diff --git a/Economy.Server/Program.cs b/Economy.Server/Program.cs
index d3f44be51..196c328de 100644
--- a/Economy.Server/Program.cs
+++ b/Economy.Server/Program.cs
@@ -157,11 +157,11 @@ namespace ChatApp.Server
OrbitData[] orbits;
PlanetData[] planets;
ZoneGenerator.GenerateZone(
- global: context.GlobalData,
- zone: zone,
- mapLayers: mapLayers.Values,
- resources: cache.GetAll(),
- orbitData: out orbits,
+ global: context.GlobalData,
+ zone: zone,
+ mapLayers: mapLayers.Values,
+ resources: cache.GetAll(),
+ orbitData: out orbits,
planetsData: out planets);
cache.AddAll(orbits);
cache.AddAll(planets);
diff --git a/Economy.Shared.Unity.csproj b/Economy.Shared.Unity.csproj
index baaf7fbad..79c0ea0a6 100644
--- a/Economy.Shared.Unity.csproj
+++ b/Economy.Shared.Unity.csproj
@@ -64,8 +64,8 @@
-
+
@@ -87,6 +87,7 @@
+
@@ -445,6 +446,7 @@
+