diff --git a/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml b/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml index 4fcbfa33a..ec265876b 100644 --- a/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml +++ b/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml @@ -1256,6 +1256,7 @@ + @@ -1267,6 +1268,7 @@ + diff --git a/Assets/Prefabs/Corporation Selection.prefab b/Assets/Prefabs/Corporation Selection.prefab index 55465774e..0e983e9be 100644 --- a/Assets/Prefabs/Corporation Selection.prefab +++ b/Assets/Prefabs/Corporation Selection.prefab @@ -96,7 +96,7 @@ MonoBehaviour: m_outlineColor: serializedVersion: 2 rgba: 4278190080 - m_fontSize: 16 + m_fontSize: 12 m_fontSizeBase: 16 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -113,7 +113,7 @@ MonoBehaviour: m_enableWordWrapping: 1 m_wordWrappingRatios: 0.4 m_overflowMode: 0 - m_firstOverflowCharacterIndex: -1 + m_firstOverflowCharacterIndex: 0 m_linkedTextComponent: {fileID: 0} m_isLinkedTextComponent: 0 m_isTextTruncated: 0 @@ -142,7 +142,7 @@ MonoBehaviour: spaceCount: 31 wordCount: 32 linkCount: 0 - lineCount: 6 + lineCount: 181 pageCount: 1 materialCount: 2 m_isUsingLegacyAnimationComponent: 0 @@ -454,7 +454,7 @@ MonoBehaviour: m_outlineColor: serializedVersion: 2 rgba: 4278190080 - m_fontSize: 48 + m_fontSize: 18 m_fontSizeBase: 48 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -471,7 +471,7 @@ MonoBehaviour: m_enableWordWrapping: 1 m_wordWrappingRatios: 0.4 m_overflowMode: 0 - m_firstOverflowCharacterIndex: -1 + m_firstOverflowCharacterIndex: 0 m_linkedTextComponent: {fileID: 0} m_isLinkedTextComponent: 0 m_isTextTruncated: 0 @@ -500,7 +500,7 @@ MonoBehaviour: spaceCount: 1 wordCount: 2 linkCount: 0 - lineCount: 2 + lineCount: 16 pageCount: 1 materialCount: 1 m_isUsingLegacyAnimationComponent: 0 @@ -740,7 +740,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 172.80005} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &3643881634576849054 CanvasRenderer: @@ -763,7 +763,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0.8, g: 0.9333333, b: 1, a: 1} + m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 m_OnCullStateChanged: m_PersistentCalls: diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 1ab88cd77..8ac18bc62 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -8311,6 +8311,16 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 1619776840} m_Modifications: + - target: {fileID: 4451361954557856253, guid: cde91a528214ecc4081092fcad3cc981, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4451361954557856253, guid: cde91a528214ecc4081092fcad3cc981, + type: 3} + propertyPath: m_SizeDelta.x + value: -40 + objectReference: {fileID: 0} - target: {fileID: 4451361955953725105, guid: cde91a528214ecc4081092fcad3cc981, type: 3} propertyPath: m_textInfo.characterCount @@ -8341,25 +8351,55 @@ PrefabInstance: propertyPath: m_text value: Corporation Name objectReference: {fileID: 0} + - target: {fileID: 4451361955953725105, guid: cde91a528214ecc4081092fcad3cc981, + type: 3} + propertyPath: m_fontSize + value: 32 + objectReference: {fileID: 0} + - target: {fileID: 4451361955953725105, guid: cde91a528214ecc4081092fcad3cc981, + type: 3} + propertyPath: m_fontSizeBase + value: 32 + objectReference: {fileID: 0} + - target: {fileID: 4451361955953725105, guid: cde91a528214ecc4081092fcad3cc981, + type: 3} + propertyPath: m_textAlignment + value: 513 + objectReference: {fileID: 0} - target: {fileID: 4451361956030022762, guid: cde91a528214ecc4081092fcad3cc981, type: 3} propertyPath: m_textInfo.characterCount - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 4451361956030022762, guid: cde91a528214ecc4081092fcad3cc981, type: 3} propertyPath: m_textInfo.wordCount - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 4451361956030022762, guid: cde91a528214ecc4081092fcad3cc981, type: 3} propertyPath: m_textInfo.lineCount - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 4451361956030022762, guid: cde91a528214ecc4081092fcad3cc981, type: 3} propertyPath: m_textInfo.pageCount - value: 0 + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4451361956030022762, guid: cde91a528214ecc4081092fcad3cc981, + type: 3} + propertyPath: m_fontSize + value: 32 + objectReference: {fileID: 0} + - target: {fileID: 4451361956030022762, guid: cde91a528214ecc4081092fcad3cc981, + type: 3} + propertyPath: m_fontSizeBase + value: 32 + objectReference: {fileID: 0} + - target: {fileID: 4451361956030022762, guid: cde91a528214ecc4081092fcad3cc981, + type: 3} + propertyPath: m_textAlignment + value: 513 objectReference: {fileID: 0} - target: {fileID: 4451361956630297305, guid: cde91a528214ecc4081092fcad3cc981, type: 3} @@ -8424,7 +8464,7 @@ PrefabInstance: - target: {fileID: 4451361956630297310, guid: cde91a528214ecc4081092fcad3cc981, type: 3} propertyPath: m_AnchoredPosition.x - value: 0 + value: -147.9 objectReference: {fileID: 0} - target: {fileID: 4451361956630297310, guid: cde91a528214ecc4081092fcad3cc981, type: 3} @@ -8434,12 +8474,12 @@ PrefabInstance: - target: {fileID: 4451361956630297310, guid: cde91a528214ecc4081092fcad3cc981, type: 3} propertyPath: m_SizeDelta.x - value: 285.13 + value: 650 objectReference: {fileID: 0} - target: {fileID: 4451361956630297310, guid: cde91a528214ecc4081092fcad3cc981, type: 3} propertyPath: m_SizeDelta.y - value: 32.005005 + value: 64 objectReference: {fileID: 0} - target: {fileID: 4451361956630297310, guid: cde91a528214ecc4081092fcad3cc981, type: 3} @@ -8464,7 +8504,7 @@ PrefabInstance: - target: {fileID: 4451361956630297310, guid: cde91a528214ecc4081092fcad3cc981, type: 3} propertyPath: m_Pivot.x - value: 0.5 + value: 0 objectReference: {fileID: 0} - target: {fileID: 4451361956630297310, guid: cde91a528214ecc4081092fcad3cc981, type: 3} @@ -11199,7 +11239,7 @@ PrefabInstance: - target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e, type: 3} propertyPath: m_AnchoredPosition.x - value: 90.43 + value: 0 objectReference: {fileID: 0} - target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e, type: 3} diff --git a/Assets/Scripts/Editor/DatabaseInspector.cs b/Assets/Scripts/Editor/DatabaseInspector.cs index 568ceb760..89fa37ffd 100644 --- a/Assets/Scripts/Editor/DatabaseInspector.cs +++ b/Assets/Scripts/Editor/DatabaseInspector.cs @@ -184,7 +184,7 @@ public class DatabaseInspector : EditorWindow else if (type == typeof(Type) && inspectable is InspectableTypeAttribute typeAttribute) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (Type) value, typeAttribute.Type)); else if (type == typeof(GameObject)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (GameObject) value)); else if (type == typeof(AnimationCurve)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (AnimationCurve) value)); - else if (type == typeof(PerformanceStat)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (PerformanceStat) value, obj as CraftedItemData)); + else if (type == typeof(PerformanceStat)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (PerformanceStat) value, field.GetCustomAttribute() != null)); else if (type == typeof(PerformanceStat[])) { LabelField(field.Name.SplitCamelCase(), EditorStyles.boldLabel); @@ -196,7 +196,7 @@ public class DatabaseInspector : EditorWindow stats = new PerformanceStat[damageTypes.Length]; for (var i = 0; i < stats.Length; i++) { - stats[i] = Inspect(damageTypes[i].SplitCamelCase(), stats[i], obj as CraftedItemData); + stats[i] = Inspect(damageTypes[i].SplitCamelCase(), stats[i]); } field.SetValue(obj, stats); } @@ -519,7 +519,7 @@ public class DatabaseInspector : EditorWindow if (area) { EditorStyles.textArea.wordWrap = true; - return DelayedTextField(value, EditorStyles.textArea, GUILayout.Width(position.width-width-10), GUILayout.Height(100)); + return DelayedTextField(value, EditorStyles.textArea, /*GUILayout.Width(EditorGUIUtility.currentViewWidth-width-10), */GUILayout.Height(100)); } return DelayedTextField(value); } @@ -971,7 +971,7 @@ public class DatabaseInspector : EditorWindow } } - public PerformanceStat Inspect(string label, PerformanceStat value, CraftedItemData crafted) + public PerformanceStat Inspect(string label, PerformanceStat value, bool isSimple = false) { using (new VerticalScope()) { @@ -984,17 +984,30 @@ public class DatabaseInspector : EditorWindow value.Max = DelayedFloatField(value.Max); } - using (new HorizontalScope()) + // Only display heat, durability and quality effects if the stat actually varies + if (Math.Abs(value.Min - value.Max) > .01f) { - GUILayout.Label("", GUILayout.Width(width)); - GUILayout.Label("H", _labelStyle); - value.HeatDependent = Toggle(value.HeatDependent); - GUILayout.Label("D", _labelStyle); - value.DurabilityDependent = Toggle(value.DurabilityDependent); - GUILayout.Label("QEx", _labelStyle, GUILayout.Width(labelWidth + 5)); - value.QualityExponent = DelayedFloatField(value.QualityExponent); + using (new HorizontalScope()) + { + GUILayout.Label("", GUILayout.Width(width)); + if (!isSimple) + { + GUILayout.Label("H", _labelStyle); + value.HeatDependent = Toggle(value.HeatDependent); + GUILayout.Label("D", _labelStyle); + value.DurabilityDependent = Toggle(value.DurabilityDependent); + GUILayout.Label("QEx", _labelStyle, GUILayout.Width(labelWidth + 5)); + value.QualityExponent = DelayedFloatField(value.QualityExponent); + } + else + { + GUILayout.Label("Quality Exponent", _labelStyle); + value.QualityExponent = DelayedFloatField(value.QualityExponent); + } + } } + // using (new HorizontalScope()) // { // GUILayout.Label("", GUILayout.Width(width)); diff --git a/Assets/Scripts/ServerShared/Attributes.cs b/Assets/Scripts/ServerShared/Attributes.cs index f749cdc08..0ca583604 100644 --- a/Assets/Scripts/ServerShared/Attributes.cs +++ b/Assets/Scripts/ServerShared/Attributes.cs @@ -105,4 +105,7 @@ public class InspectableTypeAttribute : InspectableFieldAttribute { Type = type; } -} \ No newline at end of file +} + +[AttributeUsage(AttributeTargets.Field)] +public class SimplePerformanceStatAttribute : Attribute { } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs b/Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs new file mode 100644 index 000000000..61a074208 --- /dev/null +++ b/Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs @@ -0,0 +1,44 @@ +using System; +using System.Linq; +using MessagePack; +using Newtonsoft.Json; + +[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(12)] +public class EnergyDrawData : BehaviorData +{ + [InspectableField, JsonProperty("draw"), Key(1)] + public PerformanceStat Draw = new PerformanceStat(); + + [InspectableField, JsonProperty("perSecond"), Key(2)] + public bool PerSecond; + + public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item) + { + return new EnergyDraw(context, this, entity, item); + } +} + +public class EnergyDraw : IBehavior +{ + private EnergyDrawData _data; + + private Entity Entity { get; } + private Gear Item { get; } + private GameContext Context { get; } + + public BehaviorData Data => _data; + + public EnergyDraw(GameContext context, EnergyDrawData data, Entity entity, Gear item) + { + _data = data; + Entity = entity; + Item = item; + Context = context; + } + + public bool Update(float delta) + { + Entity.Energy -= Context.Evaluate(_data.Draw, Item, Entity) * (_data.PerSecond ? delta : 1); + return true; + } +} \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs.meta b/Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs.meta new file mode 100644 index 000000000..d80c1ee73 --- /dev/null +++ b/Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4f382d59677799f44b024f2a9b4577e7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/Behaviors/Heat.cs b/Assets/Scripts/ServerShared/Behaviors/Heat.cs index 8031fcdb4..c1389fcd8 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Heat.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Heat.cs @@ -9,6 +9,9 @@ public class HeatData : BehaviorData [InspectableField, JsonProperty("heat"), Key(1)] public PerformanceStat Heat = new PerformanceStat(); + [InspectableField, JsonProperty("perSecond"), Key(2)] + public bool PerSecond; + public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item) { return new Heat(context, this, entity, item); @@ -35,7 +38,7 @@ public class Heat : IBehavior public bool Update(float delta) { - Entity.AddHeat(Context.Evaluate(_data.Heat, Item, Entity)); + Entity.AddHeat(Context.Evaluate(_data.Heat, Item, Entity) * (_data.PerSecond ? delta : 1)); return true; } } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Behaviors/Hitscan.cs b/Assets/Scripts/ServerShared/Behaviors/Hitscan.cs index 966375ff6..e81c4ffc1 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Hitscan.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Hitscan.cs @@ -4,6 +4,9 @@ using Newtonsoft.Json; [InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)] public class HitscanData : WeaponData { + [InspectableField, JsonProperty("perSecond"), Key(6)] + public bool PerSecond; + public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item) { return new Hitscan(context, this, entity, item); @@ -32,6 +35,7 @@ public class Hitscan : IBehavior public bool Update(float delta) { + // TODO: Implement hitscan weapons! return true; } diff --git a/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs b/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs new file mode 100644 index 000000000..89e83ddd9 --- /dev/null +++ b/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs @@ -0,0 +1,44 @@ +using System; +using System.Linq; +using MessagePack; +using Newtonsoft.Json; + +[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)] +public class ResourceScannerData : BehaviorData +{ + [InspectableField, JsonProperty("range"), Key(1)] + public PerformanceStat Range = new PerformanceStat(); + + [InspectableField, JsonProperty("minDensity"), Key(2)] + public PerformanceStat MinimumDensity = new PerformanceStat(); + + public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item) + { + return new ResourceScanner(context, this, entity, item); + } +} + +public class ResourceScanner : IBehavior +{ + private ResourceScannerData _data; + + private Entity Entity { get; } + private Gear Item { get; } + private GameContext Context { get; } + + public BehaviorData Data => _data; + + public ResourceScanner(GameContext context, ResourceScannerData data, Entity entity, Gear item) + { + _data = data; + Entity = entity; + Item = item; + Context = context; + } + + public bool Update(float delta) + { + // TODO: Implement resource scanners! + return true; + } +} \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs.meta b/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs.meta new file mode 100644 index 000000000..dde219a6a --- /dev/null +++ b/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2c7dc37e3c3c74343adc476dd1981a48 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/DatabaseItems.cs b/Assets/Scripts/ServerShared/DatabaseItems.cs index 820555364..50595c87b 100644 --- a/Assets/Scripts/ServerShared/DatabaseItems.cs +++ b/Assets/Scripts/ServerShared/DatabaseItems.cs @@ -113,6 +113,9 @@ public class MegaCorporation : DatabaseEntry, INamedEntry [JsonProperty("parent"), Key(7)] public Guid HomeZone; + [InspectableField, JsonProperty("placement"), Key(8)] + public MegaPlacementType PlacementType; + [IgnoreMember] public string EntryName { get => Name; diff --git a/Assets/Scripts/ServerShared/Entity.cs b/Assets/Scripts/ServerShared/Entity.cs index 90468c24b..147dd6d4e 100644 --- a/Assets/Scripts/ServerShared/Entity.cs +++ b/Assets/Scripts/ServerShared/Entity.cs @@ -264,7 +264,6 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR AddItemBehaviors(); - var index = 0; // Iterate only over the behaviors of items which contain persistent data // Filter the behaviors for each item to get the persistent ones, then cast them and combine with the persisted data array for that item foreach (var persistentBehaviorData in ItemBehaviors diff --git a/Assets/Scripts/ServerShared/Enums.cs b/Assets/Scripts/ServerShared/Enums.cs index e135476ed..9556f8315 100644 --- a/Assets/Scripts/ServerShared/Enums.cs +++ b/Assets/Scripts/ServerShared/Enums.cs @@ -51,4 +51,13 @@ public enum HullType Ship, Station, Turret +} + +public enum MegaPlacementType +{ + Mass = 0, + Planets = 1, + Resources = 2, + Connected = 3, + Isolated = 4 } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Extensions.cs b/Assets/Scripts/ServerShared/Extensions.cs index d2c3c2ece..d78fec899 100644 --- a/Assets/Scripts/ServerShared/Extensions.cs +++ b/Assets/Scripts/ServerShared/Extensions.cs @@ -237,6 +237,32 @@ public static class Extensions var d3 = directionAngle + 2 * PI - currentAngle; return abs(d1) < abs(d2) ? abs(d1) < abs(d3) ? d1 : d3 : abs(d2) < abs(d3) ? d2 : d3; } + + // https://stackoverflow.com/a/3188835 + public static T MaxBy(this IEnumerable items, Func selector) + { + if (!items.Any()) + { + throw new InvalidOperationException("Empty input sequence"); + } + + var comparer = Comparer.Default; + T maxItem = items.First(); + U maxValue = selector(maxItem); + + foreach (T item in items.Skip(1)) + { + // Get the value of the item and compare it to the current max. + U value = selector(item); + if (comparer.Compare(value, maxValue) > 0) + { + maxValue = value; + maxItem = item; + } + } + + return maxItem; + } } // https://github.com/Burtsev-Alexey/net-object-deep-copy @@ -308,42 +334,6 @@ public static class ObjectExtensions return (r2.x + r2.width >= r1.x && r2.x <= r1.x + r1.width) && (r2.y + r2.height >= r1.y && r2.y <= r1.y + r1.height); } - - // public static IEnumerable FindPath(this IEnumerable> data, T source, T target, Func costFunction, bool bestFirst = true) where T : class - // { - // List> members = new List>{new DijkstraVertex{Vertex = source}}; - // List searched = new List(); - // while (true) - // { - // var v = members.Where(m=>!searched.Contains(m.Vertex)).OrderBy(m=>bestFirst?m.Heuristic:m.Cost).FirstOrDefault(); - // if (v == null) return null; // No vertices left unsearched - // if (v.Vertex == target) - // { - // Stack> path = new Stack>(); - // path.Push(v); - // while(path.Peek().Parent!=null) - // path.Push(path.Peek().Parent); - // return path.Select(dv => dv.Vertex).ToList(); - // } - // members.AddRange(data.Where(l => l.Source == v.Vertex).Select(l => l.Target).Concat(data.Where(l => l.Target == v.Vertex).Select(l => l.Source)) - // .Where(n => members.All(m => m.Vertex != n)).Select(n => - // { - // var c = new DijkstraVertex {Parent = v, Vertex = n, Cost = v.Cost + costFunction(v.Vertex,n)}; - // if (bestFirst) - // c.Heuristic = c.Cost + costFunction(c.Vertex,target); - // return c; - // })); - // searched.Add(v.Vertex); - // } - // } - - class DijkstraVertex - { - public double Cost; - public double Heuristic; - public DijkstraVertex Parent; - public T Vertex; - } } public class ReferenceEqualityComparer : EqualityComparer diff --git a/Assets/Scripts/ServerShared/GameContext.cs b/Assets/Scripts/ServerShared/GameContext.cs index 89b29c8ef..a3e0002aa 100644 --- a/Assets/Scripts/ServerShared/GameContext.cs +++ b/Assets/Scripts/ServerShared/GameContext.cs @@ -132,7 +132,6 @@ public class GameContext nearestController.AssignTask(task.ID, nearestControllerPath); } } - } foreach (var kvp in ZoneEntities) @@ -251,6 +250,91 @@ public class GameContext { return pow(distance, GlobalData.OrbitPeriodExponent) * GlobalData.OrbitPeriodMultiplier; } + + public void PlaceMegas() + { + var megas = Cache.GetAll(); + + var availableZones = Cache.GetAll() + .Where(z => megas.All(m => m.HomeZone != z.ID)) + .ToList(); + + foreach(var megaPlacement in megas + .OrderBy(m=>m.PlacementType) + .GroupBy(m=>m.PlacementType)) + switch (megaPlacement.Key) + { + case MegaPlacementType.Mass: + foreach (var mega in megaPlacement) + { + var zone = availableZones + .MaxBy(z => z.Mass); + availableZones.Remove(zone); + mega.HomeZone = zone.ID; + } + break; + case MegaPlacementType.Planets: + foreach (var mega in megaPlacement) + { + var zone = availableZones + .MaxBy(z => z.Planets.Length); + availableZones.Remove(zone); + mega.HomeZone = zone.ID; + } + break; + case MegaPlacementType.Resources: + foreach (var mega in megaPlacement) + { + var zone = availableZones + .MaxBy(z => z.Planets + .SelectMany(id=>Cache.Get(id).Resources + .Select(r=>r.Key)) + .Distinct() + .Count()); + availableZones.Remove(zone); + mega.HomeZone = zone.ID; + } + break; + case MegaPlacementType.Connected: + foreach (var mega in megaPlacement) + { + var zone = availableZones + .OrderByDescending(z => z.Wormholes.Count) + .ThenBy(z=>megas + .Sum(m=>m.HomeZone==Guid.Empty?0:lengthsq(Cache.Get(m.HomeZone).Position - z.Position))) + .First(); + availableZones.Remove(zone); + mega.HomeZone = zone.ID; + } + break; + case MegaPlacementType.Isolated: + foreach (var mega in megaPlacement) + { + var zone = availableZones + .Where(z=>z.Wormholes.Count==1) + .MaxBy(z => + { + int soloChain = 0; + var previous = z; + var next = Cache.Get(z.Wormholes.First()); + while (next.Wormholes.Count == 2) + { + var temp = next; + next = Cache.Get(next.Wormholes.First(w=>w != previous.ID)); + previous = temp; + soloChain++; + } + + return soloChain; + }); + availableZones.Remove(zone); + mega.HomeZone = zone.ID; + } + break; + default: + throw new ArgumentOutOfRangeException(); + } + } // public int ItemTier(CraftedItemData itemData) // { diff --git a/Assets/Scripts/ServerShared/ItemData.cs b/Assets/Scripts/ServerShared/ItemData.cs index 5ad70ab8b..605a2685a 100644 --- a/Assets/Scripts/ServerShared/ItemData.cs +++ b/Assets/Scripts/ServerShared/ItemData.cs @@ -96,13 +96,13 @@ public abstract class EquippableItemData : CraftedItemData [TemperatureInspectable, JsonProperty("maxTemp"), Key(8)] public float MaximumTemperature; - [InspectableField, JsonProperty("durabilityStat"), Key(9)] + [InspectableField, JsonProperty("durabilityStat"), Key(9), SimplePerformanceStat] public PerformanceStat Durability = new PerformanceStat(); - [InspectableField, JsonProperty("durabilityExponent"), Key(10)] + [InspectableField, JsonProperty("durabilityExponent"), Key(10), SimplePerformanceStat] public PerformanceStat DurabilityExponent = new PerformanceStat(); - [InspectableField, JsonProperty("heatExponent"), Key(11)] + [InspectableField, JsonProperty("heatExponent"), Key(11), SimplePerformanceStat] public PerformanceStat HeatExponent = new PerformanceStat(); [InspectableField, JsonProperty("behaviors"), Key(12)] diff --git a/Assets/Scripts/StrategyGameManager.cs b/Assets/Scripts/StrategyGameManager.cs index 699b4cf5d..1b24a6e21 100644 --- a/Assets/Scripts/StrategyGameManager.cs +++ b/Assets/Scripts/StrategyGameManager.cs @@ -109,14 +109,13 @@ public class StrategyGameManager : MonoBehaviour Position = z.Position, ZoneID = z.ID }); + + foreach (var zone in _context.GalaxyZones.Keys) GenerateZone(zone); var megas = _cache.GetAll(); if (megas.First().HomeZone == Guid.Empty) { - foreach (var corpzone in megas - .Zip(_cache.GetAll().OrderByDescending(z => z.Mass), - (corporation, zone) => new {corporation, zone})) - corpzone.corporation.HomeZone = corpzone.zone.ID; + _context.PlaceMegas(); } var player = _cache.GetAll().FirstOrDefault(); @@ -181,6 +180,9 @@ public class StrategyGameManager : MonoBehaviour GameMenuRoot.gameObject.SetActive(true); CorpMenuRoot.gameObject.SetActive(false); + + _selectedZone = _cache.Get(newCorp.Parent).HomeZone; + ZoneTabButton.OnPointerClick(null); } }; } @@ -384,10 +386,10 @@ public class StrategyGameManager : MonoBehaviour CultClient.Send(new ZoneRequestMessage{ZoneID = zone.ZoneID}); if (TestMode) { - if(!_context.Cache.Get(zone.ZoneID).Visited) - { - GenerateZone(zone.ZoneID); - } + // if(!_context.Cache.Get(zone.ZoneID).Visited) + // { + // GenerateZone(zone.ZoneID); + // } PopulateZoneProperties(zone.ZoneID); } _selectedZone = zone.ZoneID; @@ -398,6 +400,13 @@ public class StrategyGameManager : MonoBehaviour // If the user double clicks on a zone, switch to the zone tab if(pointer.clickCount == 2) ZoneTabButton.OnPointerClick(pointer); }; + + if(_selectedZone == zone.ZoneID) + { + _selectedGalaxyZone = instanceZone; + _selectedGalaxyZone.Background.material.SetColor("_TintColor", SelectedColor); + } + foreach (var linkedZone in zone.Links.Where(l=>!linkedZones.Contains(l))) { var link = GalaxyZoneLinkPrototype.Instantiate(); @@ -407,6 +416,7 @@ public class StrategyGameManager : MonoBehaviour link.localScale = new Vector3(length(diff) * GalaxyScale, 1, 1); } } + } void GenerateZone(Guid zone) diff --git a/Economy.Shared.Unity.csproj b/Economy.Shared.Unity.csproj index 5405b14b3..8eb5d47fc 100644 --- a/Economy.Shared.Unity.csproj +++ b/Economy.Shared.Unity.csproj @@ -73,6 +73,7 @@ + @@ -84,6 +85,7 @@ +