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:
hyperion51 2020-05-21 01:53:06 +01:00
commit 61072de924
19 changed files with 352 additions and 80 deletions

View 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;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4f382d59677799f44b024f2a9b4577e7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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;
}
}

View file

@ -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;
}

View 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;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2c7dc37e3c3c74343adc476dd1981a48
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: