Production/Demand Profiles and Blueprint Resource Requirements

Added the ability to associate blueprints and compound commodities with personality attributes
Added the ability to restrict blueprints according to the presence of resources, for resource harvesting infrastructure
Improved the properties panel UI for Sector and Tech tabs
This commit is contained in:
hyperion51 2020-05-03 00:36:47 +01:00
commit 35fb4381ed
16 changed files with 769 additions and 263 deletions

View file

@ -92,8 +92,8 @@ MonoBehaviour:
m_outlineColor:
serializedVersion: 2
rgba: 4278190080
m_fontSize: 36
m_fontSizeBase: 36
m_fontSize: 24
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
@ -109,7 +109,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
@ -138,7 +138,7 @@ MonoBehaviour:
spaceCount: 1
wordCount: 2
linkCount: 0
lineCount: 1
lineCount: 8
pageCount: 1
materialCount: 1
m_isUsingLegacyAnimationComponent: 0
@ -209,7 +209,7 @@ MonoBehaviour:
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: -1
m_PreferredHeight: 64
m_PreferredHeight: 32
m_FlexibleWidth: 1
m_FlexibleHeight: -1
m_LayoutPriority: 1

View file

@ -53,7 +53,7 @@ MonoBehaviour:
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: -1
m_PreferredHeight: 64
m_PreferredHeight: 32
m_FlexibleWidth: 1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@ -149,8 +149,8 @@ MonoBehaviour:
m_outlineColor:
serializedVersion: 2
rgba: 4278190080
m_fontSize: 36
m_fontSizeBase: 36
m_fontSize: 24
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
@ -166,7 +166,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
@ -195,7 +195,7 @@ MonoBehaviour:
spaceCount: 1
wordCount: 2
linkCount: 0
lineCount: 1
lineCount: 6
pageCount: 1
materialCount: 1
m_isUsingLegacyAnimationComponent: 0

View file

@ -53,7 +53,7 @@ MonoBehaviour:
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: -1
m_PreferredHeight: 64
m_PreferredHeight: 32
m_FlexibleWidth: 1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@ -149,8 +149,8 @@ MonoBehaviour:
m_outlineColor:
serializedVersion: 2
rgba: 4278190080
m_fontSize: 36
m_fontSizeBase: 36
m_fontSize: 24
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
@ -166,7 +166,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
@ -195,7 +195,7 @@ MonoBehaviour:
spaceCount: 1
wordCount: 2
linkCount: 0
lineCount: 1
lineCount: 6
pageCount: 1
materialCount: 1
m_isUsingLegacyAnimationComponent: 0

View file

@ -55,7 +55,7 @@ MonoBehaviour:
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: -1
m_PreferredHeight: 64
m_PreferredHeight: 32
m_FlexibleWidth: 1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@ -165,8 +165,8 @@ MonoBehaviour:
m_outlineColor:
serializedVersion: 2
rgba: 4278190080
m_fontSize: 36
m_fontSizeBase: 36
m_fontSize: 24
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
@ -182,7 +182,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
@ -211,7 +211,7 @@ MonoBehaviour:
spaceCount: 0
wordCount: 1
linkCount: 0
lineCount: 1
lineCount: 5
pageCount: 1
materialCount: 1
m_isUsingLegacyAnimationComponent: 0
@ -321,8 +321,8 @@ MonoBehaviour:
m_outlineColor:
serializedVersion: 2
rgba: 4278190080
m_fontSize: 36
m_fontSizeBase: 36
m_fontSize: 24
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
@ -338,7 +338,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
@ -367,7 +367,7 @@ MonoBehaviour:
spaceCount: 0
wordCount: 1
linkCount: 0
lineCount: 1
lineCount: 9
pageCount: 1
materialCount: 1
m_isUsingLegacyAnimationComponent: 0

BIN
Assets/Resources/Sprites/Flat UI/DotRight.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,88 @@
fileFormatVersion: 2
guid: 7b21eb9dd8a2f07468305b1e3fd4497f
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 437c59f5a03717844a1c0b681279dd2b
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Resources/Sprites/Flat UI/areaFade1.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,88 @@
fileFormatVersion: 2
guid: e63fd14753d0f4943a54d9c382aa8cb1
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 367844c269e9ed84899b0706b8b83dd6
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load diff

View file

@ -206,7 +206,7 @@ public class DatabaseInspector : EditorWindow
else if (type == typeof(Dictionary<Guid, float>))
{
var dict = (Dictionary<Guid, float>) field.GetValue(obj);
Inspect(field.Name.SplitCamelCase(), ref dict);
Inspect(field.Name.SplitCamelCase(), ref dict, link.EntryType);
}
else if (type == typeof(List<BlueprintStatEffect>))
{
@ -685,7 +685,7 @@ public class DatabaseInspector : EditorWindow
}
}
public void Inspect(string label, ref Dictionary<Guid,float> value)
public void Inspect(string label, ref Dictionary<Guid,float> value, Type referenceType)
{
Space();
LabelField(label, EditorStyles.boldLabel);
@ -703,7 +703,17 @@ public class DatabaseInspector : EditorWindow
{
using (var h = new HorizontalScope(_list.ListItemStyle))
{
GUILayout.Label(DatabaseCache.Get(ingredient.Key).ID.ToString());
var entry = DatabaseCache.Get(ingredient.Key);
if (entry == null)
{
value.Remove(ingredient.Key);
GUI.changed = true;
return;
}
if(entry is INamedEntry named)
GUILayout.Label(named.EntryName);
else GUILayout.Label(entry.ID.ToString());
value[ingredient.Key] = DelayedFloatField(value[ingredient.Key], GUILayout.Width(50));
var rect = GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
@ -715,15 +725,18 @@ public class DatabaseInspector : EditorWindow
if (v.rect.Contains(Event.current.mousePosition))
{
var dragData = DragAndDrop.GetGenericData("Item");
var isId = dragData is Guid guid;
var dragEntry = isId ? DatabaseCache.Get(guid) : null;
var correctType = referenceType.IsInstanceOfType(dragEntry);
if(Event.current.type == EventType.DragUpdated)
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
DragAndDrop.visualMode = correctType ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected;
else if(Event.current.type == EventType.DragPerform)
{
var guid = DragAndDrop.GetGenericData("Item");
if (guid is Guid)
if (isId && correctType)
{
DragAndDrop.AcceptDrag();
value[(Guid) guid] = 1;
value[guid] = 1;
GUI.changed = true;
}
}

View file

@ -50,6 +50,12 @@ public class BlueprintData : DatabaseEntry, INamedEntry
[InspectableDatabaseLink(typeof(CraftedItemData)), JsonProperty("factoryItem"), Key(14)]
public Guid FactoryItem;
[InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("resourceRequirements"), Key(15)]
public Dictionary<Guid, int> ResourceRequirements = new Dictionary<Guid, int>();
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("productionProfile"), Key(16)]
public Dictionary<Guid, float> ProductionProfile = new Dictionary<Guid, float>();
[IgnoreMember] public string EntryName
{
@ -64,16 +70,16 @@ public class BlueprintStatEffect
[InspectableField, JsonProperty("ingredient"), Key(1)]
public Guid Ingredient;
[InspectableField, JsonProperty("stat"), Key(2)]
[InspectableField, JsonProperty("stat"), Key(2)]
public StatReference StatReference = new StatReference();
}
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class StatReference
{
[InspectableType(typeof(IBehaviorData)), JsonProperty("behavior"), Key(1)]
[InspectableType(typeof(IBehaviorData)), JsonProperty("behavior"), Key(1)]
public string Behavior;
[InspectableField, JsonProperty("stat"), Key(2)]
[InspectableField, JsonProperty("stat"), Key(2)]
public string Stat;
}

View file

@ -35,6 +35,7 @@ public interface INamedEntry
Union(14, typeof(StationData)),
Union(15, typeof(OrbitData)),
Union(16, typeof(PlanetData)),
Union(17, typeof(PersonalityAttribute)),
// Union(17, typeof(ShipData)),
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
//[Union(21, typeof(ContractData))]

View file

@ -21,7 +21,8 @@ public enum HardpointType
Energy,
Ballistic,
Launcher,
Infrastructure
Infrastructure,
ControlModule
}
public enum DamageType

View file

@ -70,7 +70,7 @@ public static class Extensions
private static Random Random => (Random) (_random ?? (_random = new Random((uint) (DateTime.Now.Ticks%uint.MaxValue))));
// public static T RandomElement<T>(this IEnumerable<T> enumerable) => enumerable.ElementAt(Random.NextInt(0, enumerable.Count()));
public static float NextUnbounded(this ref Random random) => 1 / (1 - random.NextFloat()) - 1;
public static float NextUnbounded(this ref Random random, float bias, float power) => 1 / (1 - pow(random.NextFloat(), 1 - pow(clamp(bias,0,.99f), 1 / power))) - 1;
public static float NextUnbounded(this ref Random random, float bias, float power, float ceiling) => 1 / (1 - pow(min(random.NextFloat(), ceiling), 1 - pow(clamp(bias,0,.99f), 1 / power))) - 1;
private static Dictionary<Type,Type[]> InterfaceClasses = new Dictionary<Type, Type[]>();
public static Type[] GetAllInterfaceClasses(this Type type)

View file

@ -50,10 +50,14 @@ public class SimpleCommodityData : ItemData
// Controls the bias power variable during resource placement
[InspectableField, JsonProperty("resourceDensityBiasPower"), Key(8)]
public float ResourceDensityBiasPower = 5;
public float DensityBiasPower = 5;
// Controls the bias power variable during resource placement
[InspectableField, JsonProperty("resourceRandomCeiling"), Key(9)]
public float RandomCeiling = .9f;
// Minimum amount of resources needed for presence to register
[InspectableField, JsonProperty("resourceFloor"), Key(9)]
[InspectableField, JsonProperty("resourceFloor"), Key(10)]
public float ResourceFloor = 10f;
}
@ -68,7 +72,11 @@ public abstract class CraftedItemData : ItemData
}
[RethinkTable("Items"), Inspectable, MessagePackObject]
public class CompoundCommodityData : CraftedItemData {}
public class CompoundCommodityData : CraftedItemData
{
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("demandProfile"), Key(6)]
public Dictionary<Guid, float> DemandProfile = new Dictionary<Guid, float>();
}
[Union(0, typeof(GearData)),
Union(1, typeof(HullData)),
@ -210,4 +218,17 @@ public class PerformanceStat
return ConstantModifiers[entity];
}
}
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class PersonalityAttribute : DatabaseEntry, INamedEntry
{
[InspectableField, JsonProperty("name"), Key(1)]
public string Name;
[IgnoreMember] public string EntryName
{
get => Name;
set => Name = value;
}
}

View file

@ -76,7 +76,7 @@ public class ZoneGenerator
planet.Mass > context.GlobalData.PlanetMass ? BodyType.Planet : BodyType.Planetoid);
if ((bodyType & r.ResourceBodyType) != 0)
{
float quantity = context.Random.NextUnbounded(r.ResourceDensity.Aggregate(1f, (m, rdm) => m * resourceMaps[rdm]), r.ResourceDensityBiasPower);
float quantity = context.Random.NextUnbounded(r.ResourceDensity.Aggregate(1f, (m, rdm) => m * resourceMaps[rdm]), r.DensityBiasPower, r.RandomCeiling);
if (r.ResourceFloor < quantity) dictionary.Add(r.ID, quantity);
}
}
@ -128,7 +128,7 @@ public class ZoneGenerator
if (rosette)
{
// Create a rosette with a number of vertices between 2 and 9 inclusive
root.ExpandRosette((int)(random.NextFloat(1, 3) * random.NextFloat(2, 3)));
root.ExpandRosette((int)(random.NextFloat(1, 5) + random.NextFloat(1, 5)));
// Create a small number of less massive "captured" planets orbiting past the rosette
root.ExpandSolar(
@ -146,7 +146,7 @@ public class ZoneGenerator
var m = p.Mass / averageChildMass;
// Give each child in the rosette its own mini solar system
p.ExpandSolar(
count: (int) (random.NextFloat() * random.NextFloat() * m * 5 + 1),
count: (int) (random.NextFloat(1, 3 * m) + random.NextFloat(1, 3 * m)),
massMulMin: 0.75f,
massMulMax: 2.5f,
distMulMin: 1 + m * .25f,