Mega Placement
Megas now have unique placement algorithms for their home sectors PerformanceStats can be marked as simple to hide heat and durability PerformanceStats automatically hide exponents when min and max are the same Some behaviors now have options to spread their effects over time
This commit is contained in:
parent
98371fc453
commit
61072de924
19 changed files with 352 additions and 80 deletions
|
|
@ -1256,6 +1256,7 @@
|
|||
<e p="Behaviors.cs" t="Include" />
|
||||
<e p="Controller.cs" t="Include" />
|
||||
<e p="Cooldown.cs" t="Include" />
|
||||
<e p="EnergyDraw.cs" t="Include" />
|
||||
<e p="FactoryBehavior.cs" t="Include" />
|
||||
<e p="Heat.cs" t="Include" />
|
||||
<e p="Hitscan.cs" t="Include" />
|
||||
|
|
@ -1267,6 +1268,7 @@
|
|||
<e p="Radiator.cs" t="Include" />
|
||||
<e p="Reactor.cs" t="Include" />
|
||||
<e p="Reflector.cs" t="Include" />
|
||||
<e p="ResourceScanner.cs" t="Include" />
|
||||
<e p="Sensor.cs" t="Include" />
|
||||
<e p="Shield.cs" t="Include" />
|
||||
<e p="StatModifier.cs" t="Include" />
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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<SimplePerformanceStatAttribute>() != 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));
|
||||
|
|
|
|||
|
|
@ -105,4 +105,7 @@ public class InspectableTypeAttribute : InspectableFieldAttribute
|
|||
{
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class SimplePerformanceStatAttribute : Attribute { }
|
||||
44
Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs
Normal file
44
Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4f382d59677799f44b024f2a9b4577e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
44
Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs
Normal file
44
Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2c7dc37e3c3c74343adc476dd1981a48
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -51,4 +51,13 @@ public enum HullType
|
|||
Ship,
|
||||
Station,
|
||||
Turret
|
||||
}
|
||||
|
||||
public enum MegaPlacementType
|
||||
{
|
||||
Mass = 0,
|
||||
Planets = 1,
|
||||
Resources = 2,
|
||||
Connected = 3,
|
||||
Isolated = 4
|
||||
}
|
||||
|
|
@ -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<T, U>(this IEnumerable<T> items, Func<T, U> selector)
|
||||
{
|
||||
if (!items.Any())
|
||||
{
|
||||
throw new InvalidOperationException("Empty input sequence");
|
||||
}
|
||||
|
||||
var comparer = Comparer<U>.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<T> FindPath<T>(this IEnumerable<Edge<T>> data, T source, T target, Func<T, T, double> costFunction, bool bestFirst = true) where T : class
|
||||
// {
|
||||
// List<DijkstraVertex<T>> members = new List<DijkstraVertex<T>>{new DijkstraVertex<T>{Vertex = source}};
|
||||
// List<T> searched = new List<T>();
|
||||
// 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<DijkstraVertex<T>> path = new Stack<DijkstraVertex<T>>();
|
||||
// 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<T> {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<T>
|
||||
{
|
||||
public double Cost;
|
||||
public double Heuristic;
|
||||
public DijkstraVertex<T> Parent;
|
||||
public T Vertex;
|
||||
}
|
||||
}
|
||||
|
||||
public class ReferenceEqualityComparer : EqualityComparer<Object>
|
||||
|
|
|
|||
|
|
@ -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<MegaCorporation>();
|
||||
|
||||
var availableZones = Cache.GetAll<ZoneData>()
|
||||
.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<PlanetData>(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<ZoneData>(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<ZoneData>(z.Wormholes.First());
|
||||
while (next.Wormholes.Count == 2)
|
||||
{
|
||||
var temp = next;
|
||||
next = Cache.Get<ZoneData>(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)
|
||||
// {
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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<MegaCorporation>();
|
||||
if (megas.First().HomeZone == Guid.Empty)
|
||||
{
|
||||
foreach (var corpzone in megas
|
||||
.Zip(_cache.GetAll<ZoneData>().OrderByDescending(z => z.Mass),
|
||||
(corporation, zone) => new {corporation, zone}))
|
||||
corpzone.corporation.HomeZone = corpzone.zone.ID;
|
||||
_context.PlaceMegas();
|
||||
}
|
||||
|
||||
var player = _cache.GetAll<Player>().FirstOrDefault();
|
||||
|
|
@ -181,6 +180,9 @@ public class StrategyGameManager : MonoBehaviour
|
|||
|
||||
GameMenuRoot.gameObject.SetActive(true);
|
||||
CorpMenuRoot.gameObject.SetActive(false);
|
||||
|
||||
_selectedZone = _cache.Get<MegaCorporation>(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<ZoneData>(zone.ZoneID).Visited)
|
||||
{
|
||||
GenerateZone(zone.ZoneID);
|
||||
}
|
||||
// if(!_context.Cache.Get<ZoneData>(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<Transform>();
|
||||
|
|
@ -407,6 +416,7 @@ public class StrategyGameManager : MonoBehaviour
|
|||
link.localScale = new Vector3(length(diff) * GalaxyScale, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GenerateZone(Guid zone)
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@
|
|||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Behaviors.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Controller.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Cooldown.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\EnergyDraw.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\FactoryBehavior.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Heat.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Hitscan.cs" />
|
||||
|
|
@ -84,6 +85,7 @@
|
|||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Radiator.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Reactor.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Reflector.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\ResourceScanner.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Sensor.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Shield.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\StatModifier.cs" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue