From 70100a48ef8044f6367aed557e37e81b28355e54 Mon Sep 17 00:00:00 2001 From: hyperion51 Date: Mon, 8 Jun 2020 01:01:33 +0100 Subject: [PATCH] Population Personality Property Production Performance Personality now affects production quality You can now assign population points to infrastructure Production influences personality Automated production has a quality variable, imitating population affinity New properties panel field type for incrementing/decrementing integers --- .../.idea/contentModel.xml | 1 + Assembly-CSharp.csproj | 1 + Assets/Prefabs/Increment Field.prefab | 799 ++++++++++++++++++ Assets/Prefabs/Increment Field.prefab.meta | 7 + Assets/Prefabs/Properties Panel.prefab | 2 + Assets/Resources/Sprites/Icons/add.png.meta | 6 +- .../Resources/Sprites/Icons/remove.png.meta | 6 +- .../ServerShared/Behaviors/Behaviors.cs | 5 + .../ServerShared/Behaviors/FactoryBehavior.cs | 35 +- Assets/Scripts/ServerShared/BlueprintData.cs | 17 +- Assets/Scripts/ServerShared/Entity.cs | 7 + Assets/Scripts/ServerShared/GameContext.cs | 2 +- Assets/Scripts/ServerShared/GlobalData.cs | 3 + Assets/Scripts/UI/ColonyTab.cs | 2 +- Assets/Scripts/UI/IncrementField.cs | 12 + Assets/Scripts/UI/IncrementField.cs.meta | 11 + Assets/Scripts/UI/PropertiesPanel.cs | 29 + 17 files changed, 920 insertions(+), 25 deletions(-) create mode 100644 Assets/Prefabs/Increment Field.prefab create mode 100644 Assets/Prefabs/Increment Field.prefab.meta create mode 100644 Assets/Scripts/UI/IncrementField.cs create mode 100644 Assets/Scripts/UI/IncrementField.cs.meta diff --git a/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml b/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml index f821b035c..254adef97 100644 --- a/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml +++ b/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml @@ -1773,6 +1773,7 @@ + diff --git a/Assembly-CSharp.csproj b/Assembly-CSharp.csproj index 07f056668..907f40576 100644 --- a/Assembly-CSharp.csproj +++ b/Assembly-CSharp.csproj @@ -886,6 +886,7 @@ + diff --git a/Assets/Prefabs/Increment Field.prefab b/Assets/Prefabs/Increment Field.prefab new file mode 100644 index 000000000..8d99e8f42 --- /dev/null +++ b/Assets/Prefabs/Increment Field.prefab @@ -0,0 +1,799 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1605753206073100128 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8483308900631515678} + - component: {fileID: 8526869212183972466} + - component: {fileID: 2687083270484067498} + - component: {fileID: 3540973798616952804} + - component: {fileID: 5135471079449148330} + m_Layer: 5 + m_Name: Minus + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &8483308900631515678 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1605753206073100128} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 2544338102157427055} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -24, y: 0} + m_SizeDelta: {x: 24, y: 0} + m_Pivot: {x: 1, y: 0.5} +--- !u!222 &8526869212183972466 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1605753206073100128} + m_CullTransparentMesh: 0 +--- !u!114 &2687083270484067498 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1605753206073100128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.8, g: 0.9333333, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: f1aad09b4bf42ba4aa13a9fa1d97f01c, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &3540973798616952804 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1605753206073100128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fafbcd26aa8d175448880b37b7a41b2e, type: 3} + m_Name: + m_EditorClassIdentifier: + StateDamping: 10 + Fill: {fileID: 2687083270484067498} + Label: {fileID: 0} + CurrentState: 0 + DisableClickWhenSelected: 1 + UnselectedColor: {r: 0.8, g: 0.9333333, b: 1, a: 1} + SelectedColor: {r: 1, g: 0.44583336, b: 0.050000012, a: 0.65882355} + HoverColor: {r: 1, g: 1, b: 1, a: 0} + ClickColor: {r: 1, g: 0.44583336, b: 0.050000012, a: 1} + DisabledColor: {r: 0.14959699, g: 0.21268159, b: 0.301, a: 1} + EnabledTextColor: {r: 0, g: 0, b: 0, a: 0} + DisabledTextColor: {r: 0, g: 0, b: 0, a: 0} +--- !u!114 &5135471079449148330 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1605753206073100128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -1254083943, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_AspectMode: 1 + m_AspectRatio: 1 +--- !u!1 &1960970090893401441 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3010338289210832122} + - component: {fileID: 1238012534644946962} + - component: {fileID: 1680907406881728193} + - component: {fileID: 1034328813087786387} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &3010338289210832122 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1960970090893401441} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 6770904480725292323} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &1238012534644946962 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1960970090893401441} + m_CullTransparentMesh: 0 +--- !u!114 &1680907406881728193 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1960970090893401441} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0.4180913, b: 1, a: 0.15294118} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 84d126f984de5fd42ac66361c00f830c, type: 3} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &1034328813087786387 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1960970090893401441} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1679637790, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreLayout: 1 + m_MinWidth: -1 + m_MinHeight: -1 + m_PreferredWidth: -1 + m_PreferredHeight: -1 + m_FlexibleWidth: -1 + m_FlexibleHeight: -1 + m_LayoutPriority: 1 +--- !u!1 &5283002100655394437 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2544338102157427055} + - component: {fileID: 4673874671755542913} + m_Layer: 5 + m_Name: Value + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2544338102157427055 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5283002100655394437} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 3841991687815987397} + - {fileID: 7863247503782211248} + - {fileID: 8483308900631515678} + m_Father: {fileID: 6770904480725292323} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &4673874671755542913 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5283002100655394437} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1679637790, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreLayout: 0 + m_MinWidth: -1 + m_MinHeight: -1 + m_PreferredWidth: 0 + m_PreferredHeight: -1 + m_FlexibleWidth: 2 + m_FlexibleHeight: -1 + m_LayoutPriority: 1 +--- !u!1 &6770904480229951562 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6770904480229951561} + - component: {fileID: 6770904480229951559} + - component: {fileID: 6770904480229951560} + - component: {fileID: 4105548676279582035} + m_Layer: 5 + m_Name: Name + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &6770904480229951561 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6770904480229951562} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 6770904480725292323} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &6770904480229951559 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6770904480229951562} + m_CullTransparentMesh: 0 +--- !u!114 &6770904480229951560 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6770904480229951562} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: Dolor + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 9dcd07b95faae7641a3ff6fccab43c32, type: 2} + m_sharedMaterial: {fileID: 21906973755630180, guid: 9dcd07b95faae7641a3ff6fccab43c32, + type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_outlineColor: + serializedVersion: 2 + rgba: 4278190080 + m_fontSize: 20 + m_fontSizeBase: 20 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 1 + m_textAlignment: 513 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_firstOverflowCharacterIndex: -1 + m_linkedTextComponent: {fileID: 0} + m_isLinkedTextComponent: 0 + m_isTextTruncated: 0 + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_ignoreRectMaskCulling: 0 + m_ignoreCulling: 1 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_VertexBufferAutoSizeReduction: 1 + m_firstVisibleCharacter: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_textInfo: + textComponent: {fileID: 6770904480229951560} + characterCount: 5 + spriteCount: 0 + spaceCount: 0 + wordCount: 1 + linkCount: 0 + lineCount: 1 + pageCount: 1 + materialCount: 1 + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_spriteAnimator: {fileID: 0} + m_hasFontAssetChanged: 0 + m_subTextObjects: + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!114 &4105548676279582035 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6770904480229951562} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1679637790, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreLayout: 0 + m_MinWidth: -1 + m_MinHeight: -1 + m_PreferredWidth: 0 + m_PreferredHeight: -1 + m_FlexibleWidth: 3 + m_FlexibleHeight: -1 + m_LayoutPriority: 1 +--- !u!1 &6770904480725292324 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6770904480725292323} + - component: {fileID: 1631430149142837322} + - component: {fileID: 7366034754694240657} + - component: {fileID: 5486709585343280439} + m_Layer: 5 + m_Name: Increment Field + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &6770904480725292323 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6770904480725292324} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 3010338289210832122} + - {fileID: 6770904480229951561} + - {fileID: 2544338102157427055} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &1631430149142837322 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6770904480725292324} + m_CullTransparentMesh: 0 +--- !u!114 &7366034754694240657 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6770904480725292324} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -405508275, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 12 + m_Right: 8 + m_Top: 6 + m_Bottom: 6 + m_ChildAlignment: 4 + m_Spacing: 4 + m_ChildForceExpandWidth: 1 + m_ChildForceExpandHeight: 1 + m_ChildControlWidth: 1 + m_ChildControlHeight: 1 +--- !u!114 &5486709585343280439 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6770904480725292324} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a20edbefbc04f1241a5e5137ac00951f, type: 3} + m_Name: + m_EditorClassIdentifier: + Label: {fileID: 6770904480229951560} + Value: {fileID: 6924119194371198423} + Increment: {fileID: 5572919139501783512} + Decrement: {fileID: 3540973798616952804} +--- !u!1 &7504558634519373875 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7863247503782211248} + - component: {fileID: 5145711774446738166} + - component: {fileID: 1410452812875009136} + - component: {fileID: 5572919139501783512} + - component: {fileID: 4834146310204943466} + m_Layer: 5 + m_Name: Plus + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7863247503782211248 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7504558634519373875} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 2544338102157427055} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 2, y: 0} + m_SizeDelta: {x: 24, y: 0} + m_Pivot: {x: 1, y: 0.5} +--- !u!222 &5145711774446738166 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7504558634519373875} + m_CullTransparentMesh: 0 +--- !u!114 &1410452812875009136 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7504558634519373875} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.8, g: 0.9333333, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 1d55ddcd5a3c2354faea7e99db862d21, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &5572919139501783512 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7504558634519373875} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fafbcd26aa8d175448880b37b7a41b2e, type: 3} + m_Name: + m_EditorClassIdentifier: + StateDamping: 10 + Fill: {fileID: 1410452812875009136} + Label: {fileID: 0} + CurrentState: 0 + DisableClickWhenSelected: 1 + UnselectedColor: {r: 0.8, g: 0.9333333, b: 1, a: 1} + SelectedColor: {r: 1, g: 0.44583336, b: 0.050000012, a: 0.65882355} + HoverColor: {r: 1, g: 1, b: 1, a: 0} + ClickColor: {r: 1, g: 0.44583336, b: 0.050000012, a: 1} + DisabledColor: {r: 0.14959699, g: 0.21268159, b: 0.301, a: 1} + EnabledTextColor: {r: 0, g: 0, b: 0, a: 0} + DisabledTextColor: {r: 0, g: 0, b: 0, a: 0} +--- !u!114 &4834146310204943466 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7504558634519373875} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -1254083943, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_AspectMode: 1 + m_AspectRatio: 1 +--- !u!1 &8163497113325809434 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3841991687815987397} + - component: {fileID: 3684854048432852154} + - component: {fileID: 6924119194371198423} + m_Layer: 5 + m_Name: Label + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &3841991687815987397 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8163497113325809434} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 2544338102157427055} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -28, y: 0} + m_SizeDelta: {x: -56, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &3684854048432852154 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8163497113325809434} + m_CullTransparentMesh: 0 +--- !u!114 &6924119194371198423 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8163497113325809434} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: 123456789 + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 9dcd07b95faae7641a3ff6fccab43c32, type: 2} + m_sharedMaterial: {fileID: 21906973755630180, guid: 9dcd07b95faae7641a3ff6fccab43c32, + type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_outlineColor: + serializedVersion: 2 + rgba: 4278190080 + m_fontSize: 20 + m_fontSizeBase: 20 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_textAlignment: 516 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_firstOverflowCharacterIndex: -1 + m_linkedTextComponent: {fileID: 0} + m_isLinkedTextComponent: 0 + m_isTextTruncated: 0 + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_ignoreRectMaskCulling: 0 + m_ignoreCulling: 1 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_VertexBufferAutoSizeReduction: 1 + m_firstVisibleCharacter: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_textInfo: + textComponent: {fileID: 6924119194371198423} + characterCount: 9 + spriteCount: 0 + spaceCount: 0 + wordCount: 1 + linkCount: 0 + lineCount: 1 + pageCount: 1 + materialCount: 1 + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_spriteAnimator: {fileID: 0} + m_hasFontAssetChanged: 0 + m_subTextObjects: + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} diff --git a/Assets/Prefabs/Increment Field.prefab.meta b/Assets/Prefabs/Increment Field.prefab.meta new file mode 100644 index 000000000..a4d37c743 --- /dev/null +++ b/Assets/Prefabs/Increment Field.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9c14c92a1a08b0a4fb4f6aa6f8504082 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Properties Panel.prefab b/Assets/Prefabs/Properties Panel.prefab index 3eb108816..1008ed77d 100644 --- a/Assets/Prefabs/Properties Panel.prefab +++ b/Assets/Prefabs/Properties Panel.prefab @@ -114,6 +114,8 @@ MonoBehaviour: type: 3} ButtonField: {fileID: 6566784227922820057, guid: 6db1feb4cda7b8c419384cd42c85a5c4, type: 3} + IncrementField: {fileID: 5486709585343280439, guid: 9c14c92a1a08b0a4fb4f6aa6f8504082, + type: 3} SelectedChild: {fileID: 0} --- !u!1 &2378632238144827086 GameObject: diff --git a/Assets/Resources/Sprites/Icons/add.png.meta b/Assets/Resources/Sprites/Icons/add.png.meta index 7aaeb9ca4..f45ef66a3 100644 --- a/Assets/Resources/Sprites/Icons/add.png.meta +++ b/Assets/Resources/Sprites/Icons/add.png.meta @@ -60,7 +60,7 @@ TextureImporter: platformSettings: - serializedVersion: 2 buildTarget: DefaultTexturePlatform - maxTextureSize: 256 + maxTextureSize: 64 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 @@ -71,7 +71,7 @@ TextureImporter: androidETC2FallbackOverride: 0 - serializedVersion: 2 buildTarget: Standalone - maxTextureSize: 256 + maxTextureSize: 64 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 @@ -82,7 +82,7 @@ TextureImporter: androidETC2FallbackOverride: 0 - serializedVersion: 2 buildTarget: WebGL - maxTextureSize: 256 + maxTextureSize: 64 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 diff --git a/Assets/Resources/Sprites/Icons/remove.png.meta b/Assets/Resources/Sprites/Icons/remove.png.meta index 00b5b1d4e..dc79b899c 100644 --- a/Assets/Resources/Sprites/Icons/remove.png.meta +++ b/Assets/Resources/Sprites/Icons/remove.png.meta @@ -60,7 +60,7 @@ TextureImporter: platformSettings: - serializedVersion: 2 buildTarget: DefaultTexturePlatform - maxTextureSize: 256 + maxTextureSize: 64 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 @@ -71,7 +71,7 @@ TextureImporter: androidETC2FallbackOverride: 0 - serializedVersion: 2 buildTarget: Standalone - maxTextureSize: 256 + maxTextureSize: 64 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 @@ -82,7 +82,7 @@ TextureImporter: androidETC2FallbackOverride: 0 - serializedVersion: 2 buildTarget: WebGL - maxTextureSize: 256 + maxTextureSize: 64 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 diff --git a/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs b/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs index e8b6e7425..4b5491d19 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs @@ -47,6 +47,11 @@ public interface IPersistentBehavior// where T : IBehavior void Restore(PersistentBehaviorData data); } +public interface IPopulationAssignment +{ + int AssignedPopulation { get; set; } +} + public interface IController { bool Available { get; } diff --git a/Assets/Scripts/ServerShared/Behaviors/FactoryBehavior.cs b/Assets/Scripts/ServerShared/Behaviors/FactoryBehavior.cs index d84cb458c..426e46084 100644 --- a/Assets/Scripts/ServerShared/Behaviors/FactoryBehavior.cs +++ b/Assets/Scripts/ServerShared/Behaviors/FactoryBehavior.cs @@ -15,8 +15,11 @@ public class FactoryData : BehaviorData [InspectableField, JsonProperty("automation"), Key(2)] public int AutomationPoints; + + [InspectableField, JsonProperty("automationQuality"), Key(3)] + public float AutomationQuality = .5f; - [InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("productionProfile"), Key(3)] + [InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("productionProfile"), Key(4)] public Dictionary ProductionProfile = new Dictionary(); public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item) @@ -25,13 +28,14 @@ public class FactoryData : BehaviorData } } -public class Factory : IBehavior, IPersistentBehavior +public class Factory : IBehavior, IPersistentBehavior, IPopulationAssignment { public float ProductionQuality; public double RetoolingTime; public string ItemName; public Guid ItemUnderConstruction; public bool Active; + public int AssignedPopulation { get; set; } public Entity Entity { get; } public Gear Item { get; } @@ -64,7 +68,6 @@ public class Factory : IBehavior, IPersistentBehavior private FactoryData _data; private Guid _blueprint; - private int _assignedPopulation; private bool _retooling = false; private float _currentProductionQuality; @@ -86,7 +89,7 @@ public class Factory : IBehavior, IPersistentBehavior if (ItemUnderConstruction != Guid.Empty) { Entity.IncompleteCargo[ItemUnderConstruction] = - Entity.IncompleteCargo[ItemUnderConstruction] - delta * (_assignedPopulation + _data.AutomationPoints) / + Entity.IncompleteCargo[ItemUnderConstruction] - delta * (AssignedPopulation + _data.AutomationPoints) / pow(lerp(blueprint.QualityFloor, 1, saturate(_currentProductionQuality)), blueprint.ProductionExponent); @@ -99,6 +102,9 @@ public class Factory : IBehavior, IPersistentBehavior Entity.AddCargo(craftedItemInstance); Entity.IncompleteCargo.Remove(ItemUnderConstruction); ItemUnderConstruction = Guid.Empty; + foreach (var attribute in _data.ProductionProfile) + Entity.Personality[attribute.Key] = lerp(Entity.Personality[attribute.Key], attribute.Value, + Context.GlobalData.ProductionPersonalityLerp * ((float) AssignedPopulation / Entity.Population)); Item.Change(); } @@ -119,11 +125,20 @@ public class Factory : IBehavior, IPersistentBehavior if (Active) { - // Applying exponents to two random numbers and adding them produces a range of interesting probability distributions for quality - ItemUnderConstruction = Entity.Build(blueprint, blueprint.Quality * + var profileDistance = 0f; + if (_data.ProductionProfile.Any()) + profileDistance = _data.ProductionProfile.Sum(x => abs(x.Value - Entity.Personality[x.Key])) / + _data.ProductionProfile.Count; + var personalityQuality = + (_data.AutomationPoints * _data.AutomationQuality + AssignedPopulation * (1 - profileDistance)) / + (_data.AutomationPoints + AssignedPopulation); + ItemUnderConstruction = Entity.Build(blueprint, + blueprint.Quality * + pow(personalityQuality, blueprint.PersonalityExponent) * pow(ProductionQuality, blueprint.QualityExponent) * - (pow(Context.Random.NextFloat(), blueprint.RandomExponent) + - pow(Context.Random.NextFloat(), blueprint.RandomExponent)) / 2, ItemName); + // Applying exponents to two random numbers and averaging them produces a range of interesting probability distributions for quality + (pow(Context.Random.NextFloat(), blueprint.RandomQualityExponent) + + pow(Context.Random.NextFloat(), blueprint.RandomQualityExponent)) / 2, ItemName); if(ItemUnderConstruction!=Guid.Empty) Item.Change(); @@ -139,7 +154,7 @@ public class Factory : IBehavior, IPersistentBehavior { Blueprint = _blueprint, RetoolingTime = RetoolingTime, - AssignedPopulation = _assignedPopulation, + AssignedPopulation = AssignedPopulation, ProductionQuality = ProductionQuality }; } @@ -149,7 +164,7 @@ public class Factory : IBehavior, IPersistentBehavior var factoryPersistence = data as FactoryPersistence; _blueprint = factoryPersistence.Blueprint; RetoolingTime = factoryPersistence.RetoolingTime; - _assignedPopulation = factoryPersistence.AssignedPopulation; + AssignedPopulation = factoryPersistence.AssignedPopulation; ProductionQuality = factoryPersistence.ProductionQuality; } } diff --git a/Assets/Scripts/ServerShared/BlueprintData.cs b/Assets/Scripts/ServerShared/BlueprintData.cs index 1501d8817..5d941b785 100644 --- a/Assets/Scripts/ServerShared/BlueprintData.cs +++ b/Assets/Scripts/ServerShared/BlueprintData.cs @@ -31,24 +31,27 @@ public class BlueprintData : DatabaseEntry, INamedEntry public float ProductionExponent = 1; [InspectableField, JsonProperty("randomExponent"), Key(8)] - public float RandomExponent = 1; + public float RandomQualityExponent = 1; - [InspectableField, JsonProperty("qualityFloor"), Key(9)] + [InspectableField, JsonProperty("personalityExponent"), Key(9)] + public float PersonalityExponent = 1; + + [InspectableField, JsonProperty("qualityFloor"), Key(10)] public float QualityFloor = .25f; - [InspectableField, JsonProperty("statEffects"), Key(10)] + [InspectableField, JsonProperty("statEffects"), Key(11)] public List StatEffects = new List(); - [InspectableField, JsonProperty("researchTime"), Key(11)] + [InspectableField, JsonProperty("researchTime"), Key(12)] public float ResearchTime; - [InspectableDatabaseLink(typeof(BlueprintData)), JsonProperty("researchDependencies"), Key(12)] + [InspectableDatabaseLink(typeof(BlueprintData)), JsonProperty("researchDependencies"), Key(13)] public List Dependencies = new List(); - [InspectableDatabaseLink(typeof(CraftedItemData)), JsonProperty("factoryItem"), Key(13)] + [InspectableDatabaseLink(typeof(CraftedItemData)), JsonProperty("factoryItem"), Key(14)] public Guid FactoryItem; - [InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("resourceRequirements"), Key(14)] + [InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("resourceRequirements"), Key(15)] public Dictionary ResourceRequirements = new Dictionary(); [IgnoreMember] public string EntryName diff --git a/Assets/Scripts/ServerShared/Entity.cs b/Assets/Scripts/ServerShared/Entity.cs index 1bab9c44c..6a97969a9 100644 --- a/Assets/Scripts/ServerShared/Entity.cs +++ b/Assets/Scripts/ServerShared/Entity.cs @@ -75,6 +75,9 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR // [IgnoreMember] public Dictionary GearData; // [IgnoreMember] public Dictionary> ItemBehaviors; + private List PopulationAssignments = new List(); + + [IgnoreMember] public int AssignedPopulation => PopulationAssignments.Sum(pa => pa.AssignedPopulation); [IgnoreMember] public float Mass { get; private set; } [IgnoreMember] public float OccupiedCapacity { get; private set; } [IgnoreMember] public float ThermalMass { get; private set; } @@ -187,6 +190,10 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR Trigger = (Trigger) g.FirstOrDefault(b=>b is Trigger) }) .ToArray(); + + foreach(var behavior in hardpoint.Behaviors) + if(behavior is IPopulationAssignment populationAssignment) + PopulationAssignments.Add(populationAssignment); } public void Equip(Gear gear, Hardpoint hardpoint) diff --git a/Assets/Scripts/ServerShared/GameContext.cs b/Assets/Scripts/ServerShared/GameContext.cs index 640ab1ad7..13d651516 100644 --- a/Assets/Scripts/ServerShared/GameContext.cs +++ b/Assets/Scripts/ServerShared/GameContext.cs @@ -744,7 +744,7 @@ public class GameContext { Name = $"{loadoutData.Name} {Random.NextInt(1,255):X}", Temperature = 293, - Population = 1 + Population = 4 }; var parentCorp = Cache.Get(corpData.Parent); foreach (var attribute in parentCorp.Personality) diff --git a/Assets/Scripts/ServerShared/GlobalData.cs b/Assets/Scripts/ServerShared/GlobalData.cs index 28a6d2863..c10aadda6 100644 --- a/Assets/Scripts/ServerShared/GlobalData.cs +++ b/Assets/Scripts/ServerShared/GlobalData.cs @@ -163,6 +163,9 @@ public class GlobalData : DatabaseEntry [InspectableField, JsonProperty("significantDigits"), Key(51)] public int SignificantDigits = 3; + + [InspectableField, JsonProperty("productionPersonalityLerp"), Key(52)] + public float ProductionPersonalityLerp = .05f; public float PlanetRadius(float mass) { diff --git a/Assets/Scripts/UI/ColonyTab.cs b/Assets/Scripts/UI/ColonyTab.cs index 9f81c1079..cb52d5d87 100644 --- a/Assets/Scripts/UI/ColonyTab.cs +++ b/Assets/Scripts/UI/ColonyTab.cs @@ -65,7 +65,7 @@ public class ColonyTab : MonoBehaviour General.AddProperty("Mass", () => $"{entity.Mass.SignificantDigits(Context.GlobalData.SignificantDigits)}"); General.AddProperty("Temperature", () => $"{entity.Temperature:0}°K"); General.AddProperty("Energy", () => $"{entity.Energy:0}/{entity.GetBehaviors().First().Capacitance:0}"); - General.AddProperty("Population", () => $"{entity.Population}"); + General.AddProperty("Assigned Population", () => $"{entity.AssignedPopulation}/{entity.Population}"); var personalityList = General.AddList("Personality"); foreach (var attribute in entity.Personality.Keys) personalityList.AddPersonalityProperty(Context.Cache.Get(attribute), diff --git a/Assets/Scripts/UI/IncrementField.cs b/Assets/Scripts/UI/IncrementField.cs new file mode 100644 index 000000000..cee503f85 --- /dev/null +++ b/Assets/Scripts/UI/IncrementField.cs @@ -0,0 +1,12 @@ +using System.Collections; +using System.Collections.Generic; +using TMPro; +using UnityEngine; + +public class IncrementField : MonoBehaviour +{ + public TextMeshProUGUI Label; + public TextMeshProUGUI Value; + public FlatFlatButton Increment; + public FlatFlatButton Decrement; +} diff --git a/Assets/Scripts/UI/IncrementField.cs.meta b/Assets/Scripts/UI/IncrementField.cs.meta new file mode 100644 index 000000000..a252af394 --- /dev/null +++ b/Assets/Scripts/UI/IncrementField.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a20edbefbc04f1241a5e5137ac00951f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UI/PropertiesPanel.cs b/Assets/Scripts/UI/PropertiesPanel.cs index 5ab0ffb87..5e2dca68a 100644 --- a/Assets/Scripts/UI/PropertiesPanel.cs +++ b/Assets/Scripts/UI/PropertiesPanel.cs @@ -9,6 +9,8 @@ using UniRx; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; +using Unity.Mathematics; +using static Unity.Mathematics.math; public class PropertiesPanel : MonoBehaviour { @@ -26,6 +28,7 @@ public class PropertiesPanel : MonoBehaviour public BoolField BoolField; public PropertyButton PropertyButton; public ButtonField ButtonField; + public IncrementField IncrementField; [HideInInspector] public FlatFlatButton SelectedChild; [HideInInspector] public GameContext Context; @@ -215,6 +218,27 @@ public class PropertiesPanel : MonoBehaviour OnPropertyAdded?.Invoke(field.gameObject); } + public void AddIncrementField(string name, Func read, Action write, Func min, Func max) + { + var field = Instantiate(IncrementField, transform); + field.Label.text = name; + field.Increment.OnClick += data => write(read() + 1); + field.Decrement.OnClick += data => write(read() - 1); + RefreshPropertyValues += () => + { + var val = read(); + var minval = min(); + var maxval = max(); + if (val < minval || val > maxval) + write(val = clamp(val, minval, maxval)); + field.Value.text = val.ToString(CultureInfo.InvariantCulture); + field.Increment.CurrentState = val == maxval ? FlatButtonState.Disabled : FlatButtonState.Unselected; + field.Decrement.CurrentState = val == minval ? FlatButtonState.Disabled : FlatButtonState.Unselected; + }; + Properties.Add(field.gameObject); + OnPropertyAdded?.Invoke(field.gameObject); + } + public void AddField(string name, Func read, Action write, float min, float max) { var field = Instantiate(RangedFloatField, transform); @@ -464,6 +488,11 @@ public class PropertiesPanel : MonoBehaviour } foreach (var behavior in hardpoint.Behaviors) { + if(behavior is IPopulationAssignment populationAssignment) + AddIncrementField("Assigned Population", + () => populationAssignment.AssignedPopulation, + p => populationAssignment.AssignedPopulation = p, + () => 0, () => entity.Population - entity.AssignedPopulation + populationAssignment.AssignedPopulation); if (behavior is Thermotoggle thermotoggle) AddField("Target Temperature", () => thermotoggle.TargetTemperature, temp => thermotoggle.TargetTemperature = temp); if (behavior is Factory factory)