Hauling Task

Added a control module which enables drones to haul items from colony to colony
Added confirmation dialog for actions which require confirmation, can have fields added to it just like a PropertiesPanel
Moving items between inventories now displays confirmation dialog
This commit is contained in:
hyperion51 2020-06-12 01:57:15 +01:00
commit 991d411c91
24 changed files with 1965 additions and 2193 deletions

View file

@ -1245,6 +1245,7 @@
<e p="AgentBehavior.cs" t="Include" />
<e p="AgentTask.cs" t="Include" />
<e p="Aim.cs" t="Include" />
<e p="HaulingTask.cs" t="Include" />
<e p="Locomotion.cs" t="Include" />
<e p="Mining.cs" t="Include" />
<e p="StationTowing.cs" t="Include" />
@ -1259,6 +1260,7 @@
<e p="Cooldown.cs" t="Include" />
<e p="EnergyDraw.cs" t="Include" />
<e p="FactoryBehavior.cs" t="Include" />
<e p="HaulingController.cs" t="Include" />
<e p="Heat.cs" t="Include" />
<e p="Hitscan.cs" t="Include" />
<e p="ItemUsage.cs" t="Include" />
@ -1765,6 +1767,7 @@
<e p="ClickCatcher.cs" t="Include" />
<e p="ClickRaycaster.cs" t="Include" />
<e p="ColonyTab.cs" t="Include" />
<e p="ConfirmationDialog.cs" t="Include" />
<e p="ContextMenu.cs" t="Include" />
<e p="ContextMenuOption.cs" t="Include" />
<e p="CorporationMenuItem.cs" t="Include" />

View file

@ -20,7 +20,6 @@
<Path>Library</Path>
<Path>Logs</Path>
<Path>Server</Path>
<Path>Temp</Path>
<Path>obj</Path>
</explicitExcludes>
</component>

View file

@ -876,6 +876,7 @@
<Compile Include="Assets\Scripts\UI\ClickCatcher.cs" />
<Compile Include="Assets\Scripts\UI\ClickRaycaster.cs" />
<Compile Include="Assets\Scripts\UI\ColonyTab.cs" />
<Compile Include="Assets\Scripts\UI\ConfirmationDialog.cs" />
<Compile Include="Assets\Scripts\UI\ContextMenu.cs" />
<Compile Include="Assets\Scripts\UI\ContextMenuOption.cs" />
<Compile Include="Assets\Scripts\UI\CorporationMenuItem.cs" />

File diff suppressed because it is too large Load diff

View file

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 5e84952f528d8644ebddaa8320c3edfa
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,757 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &637043372951832103
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 9205143394894844816}
- component: {fileID: 4469578874892252439}
- component: {fileID: 5465891749406180462}
- component: {fileID: 3425627920762289370}
m_Layer: 5
m_Name: InputField (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &9205143394894844816
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 637043372951832103}
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: 4511804501416319407}
m_Father: {fileID: 794376384055840323}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.6, 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 &4469578874892252439
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 637043372951832103}
m_CullTransparentMesh: 0
--- !u!114 &5465891749406180462
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 637043372951832103}
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: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0}
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 &3425627920762289370
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 637043372951832103}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 5465891749406180462}
m_TextViewport: {fileID: 4511804501416319407}
m_TextComponent: {fileID: 7890337943757317320}
m_Placeholder: {fileID: 3434022285913689421}
m_VerticalScrollbar: {fileID: 0}
m_VerticalScrollbarEventHandler: {fileID: 0}
m_ScrollSensitivity: 1
m_ContentType: 0
m_InputType: 0
m_AsteriskChar: 42
m_KeyboardType: 0
m_LineType: 0
m_HideMobileInput: 0
m_HideSoftKeyboard: 0
m_CharacterValidation: 0
m_RegexValue:
m_GlobalPointSize: 14
m_CharacterLimit: 0
m_OnEndEdit:
m_PersistentCalls:
m_Calls: []
m_OnSubmit:
m_PersistentCalls:
m_Calls: []
m_OnSelect:
m_PersistentCalls:
m_Calls: []
m_OnDeselect:
m_PersistentCalls:
m_Calls: []
m_OnTextSelection:
m_PersistentCalls:
m_Calls: []
m_OnEndTextSelection:
m_PersistentCalls:
m_Calls: []
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
m_OnTouchScreenKeyboardStatusChanged:
m_PersistentCalls:
m_Calls: []
m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_CustomCaretColor: 0
m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412}
m_Text:
m_CaretBlinkRate: 0.85
m_CaretWidth: 1
m_ReadOnly: 0
m_RichText: 1
m_GlobalFontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_OnFocusSelectAll: 1
m_ResetOnDeActivation: 1
m_RestoreOriginalTextOnEscape: 1
m_isRichTextEditingAllowed: 0
m_LineLimit: 0
m_InputValidator: {fileID: 0}
--- !u!1 &3101295647485675918
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4511804501416319407}
- component: {fileID: 7026500166527976491}
m_Layer: 5
m_Name: Text Area
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4511804501416319407
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3101295647485675918}
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: 3598232582267177394}
- {fileID: 405184888630814489}
m_Father: {fileID: 9205143394894844816}
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.5}
m_SizeDelta: {x: -20, y: -13}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &7026500166527976491
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3101295647485675918}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -146154839, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &4234952706148560194
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 405184888630814489}
- component: {fileID: 9077432209583512576}
- component: {fileID: 7890337943757317320}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &405184888630814489
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4234952706148560194}
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: 4511804501416319407}
m_RootOrder: 1
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 &9077432209583512576
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4234952706148560194}
m_CullTransparentMesh: 0
--- !u!114 &7890337943757317320
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4234952706148560194}
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: "\u200B"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4281479730
m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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: 14
m_fontSizeBase: 14
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_textAlignment: 257
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 0
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: 1
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: 7890337943757317320}
characterCount: 1
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!1 &4568708397195691702
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3598232582267177394}
- component: {fileID: 2316990952866495610}
- component: {fileID: 3434022285913689421}
m_Layer: 5
m_Name: Placeholder
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3598232582267177394
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4568708397195691702}
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: 4511804501416319407}
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 &2316990952866495610
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4568708397195691702}
m_CullTransparentMesh: 0
--- !u!114 &3434022285913689421
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4568708397195691702}
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: Enter text...
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 2133996082
m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5}
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: 14
m_fontSizeBase: 14
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 2
m_textAlignment: 257
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 0
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: 1
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: 3434022285913689421}
characterCount: 13
spriteCount: 0
spaceCount: 1
wordCount: 2
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!1 &6733799253200703793
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4986522462497623644}
- component: {fileID: 5660052098025509788}
- component: {fileID: 4726003071877532417}
m_Layer: 5
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4986522462497623644
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6733799253200703793}
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: 794376384055840323}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0.6, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -16, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5660052098025509788
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6733799253200703793}
m_CullTransparentMesh: 0
--- !u!114 &4726003071877532417
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6733799253200703793}
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: New Text
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, 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: 24
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
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: 4726003071877532417}
characterCount: 8
spriteCount: 0
spaceCount: 1
wordCount: 2
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!1 &8493759615676307522
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 794376384055840323}
- component: {fileID: 5180397118875141325}
- component: {fileID: 2933753487102485379}
m_Layer: 5
m_Name: StupidInput
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &794376384055840323
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8493759615676307522}
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: 4986522462497623644}
- {fileID: 9205143394894844816}
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!114 &5180397118875141325
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8493759615676307522}
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: -1
m_PreferredHeight: 32
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
--- !u!114 &2933753487102485379
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8493759615676307522}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: eaba78dd36b0e9e4ba8123c4b149fc43, type: 3}
m_Name:
m_EditorClassIdentifier:
Label: {fileID: 4726003071877532417}
Field: {fileID: 3425627920762289370}

View file

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 61c1ea5d3873299429efa815251bb71b
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load diff

View file

@ -10,6 +10,7 @@ using UnityEngine;
Union(0, typeof(StationTowing)),
Union(1, typeof(Mining)),
Union(2, typeof(Survey)),
Union(3, typeof(HaulingTask)),
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
public abstract class AgentTask : DatabaseEntry
{

View file

@ -0,0 +1,23 @@
using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using UnityEngine;
public class HaulingTask : AgentTask
{
public override TaskType Type => TaskType.Haul;
[JsonProperty("origin"), Key(4)]
public Guid Origin;
[JsonProperty("target"), Key(5)]
public Guid Target;
[JsonProperty("itemType"), Key(6)]
public Guid ItemType;
[JsonProperty("quantity"), Key(7)]
public int Quantity;
}

View file

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

View file

@ -99,6 +99,7 @@ public abstract class PersistentBehaviorData
Union(27, typeof(SurveyControllerData)),
Union(28, typeof(ResourceScannerData)),
Union(29, typeof(WanderControllerData)),
Union(30, typeof(HaulingControllerData)),
JsonConverter(typeof(JsonKnownTypesConverter<BehaviorData>)), JsonObject(MemberSerialization.OptIn)]
public abstract class BehaviorData
{

View file

@ -43,6 +43,7 @@ public abstract class ControllerBase : IBehavior, IController, IInitializableBeh
protected List<SimplifiedZoneData> Path;
protected Guid Task;
protected bool Moving;
protected bool Waiting;
private GameContext _context;
private Entity _entity;
@ -50,6 +51,8 @@ public abstract class ControllerBase : IBehavior, IController, IInitializableBeh
private MovementPhase _movementPhase;
private Action _onFinishMoving;
private bool _spaceworthy;
private float _waitTime;
private Action _onFinishWaiting;
public ControllerBase(GameContext context, ControllerData data, Entity entity)
{
@ -88,6 +91,18 @@ public abstract class ControllerBase : IBehavior, IController, IInitializableBeh
GoHome();
}
}
if (Waiting)
{
_waitTime -= delta;
if (_waitTime < 0)
{
Waiting = false;
_onFinishWaiting?.Invoke();
}
return true;
}
if (Moving)
{
@ -165,6 +180,13 @@ public abstract class ControllerBase : IBehavior, IController, IInitializableBeh
}));
}
public void Wait(float time, Action onFinish = null)
{
_waitTime = time;
Waiting = true;
_onFinishWaiting = onFinish;
}
public void MoveTo(Entity entity, bool matchVelocity = true, Action onFinish = null)
{
TargetPosition = () => entity.Position;

View file

@ -0,0 +1,163 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), Order(-100)]
public class HaulingControllerData : ControllerData
{
[InspectableField, JsonProperty("targetDistance"), Key(6)]
public float DockTime = 2;
public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item)
{
return new HaulingController(context, this, entity, item);
}
}
public class HaulingController : ControllerBase, IBehavior, IPersistentBehavior
{
public override TaskType TaskType => TaskType.Haul;
public BehaviorData Data => _data;
private HaulingControllerData _data;
private GameContext _context;
private Entity _entity;
private Gear _item;
private bool _taskStarted;
private int _itemsDelivered;
private SimpleCommodity _simpleCommodityDelivery;
private List<CraftedItemInstance> _craftedItemDelivery = new List<CraftedItemInstance>();
public HaulingController(GameContext context, HaulingControllerData data, Entity entity, Gear item) : base(context, data, entity)
{
_context = context;
_data = data;
_entity = entity;
_item = item;
}
public new bool Update(float delta)
{
var haulingTask = _context.Cache.Get<HaulingTask>(Task);
if (haulingTask != null)
{
if (!_taskStarted)
{
MoveTo(haulingTask.Zone, OnOriginZoneArrival);
_taskStarted = true;
}
}
return base.Update(delta);
}
void OnOriginZoneArrival()
{
var haulingTask = _context.Cache.Get<HaulingTask>(Task);
_entity.SetMessage("Entering pickup phase.");
MoveTo(_context.Cache.Get<Entity>(haulingTask.Origin), true, OnPickup);
}
void OnPickup()
{
var haulingTask = _context.Cache.Get<HaulingTask>(Task);
var target = _context.ZoneEntities[_entity.Zone][haulingTask.Origin] as OrbitalEntity;
_context.SetParent(_entity, target);
var itemData = _context.Cache.Get<ItemData>(haulingTask.ItemType);
int quantity = min((int) ((_entity.Capacity - _entity.OccupiedCapacity) / itemData.Size), haulingTask.Quantity - _itemsDelivered);
if (itemData is SimpleCommodityData)
{
var itemMatch = target.Cargo
.Select(id => _context.Cache.Get<SimpleCommodity>(id))
.FirstOrDefault(ii => ii != null && ii.Data == haulingTask.ItemType);
if(itemMatch==null)
FinishTask();
_simpleCommodityDelivery = _entity.AddCargo(target.RemoveCargo(itemMatch, quantity));
}
else if (itemData is CraftedItemData)
{
var itemMatches = target.Cargo
.Select(id => _context.Cache.Get<CraftedItemInstance>(id))
.Where(ii => ii != null && ii.Data == haulingTask.ItemType);
if(!itemMatches.Any())
FinishTask();
foreach (var match in itemMatches)
_craftedItemDelivery.Add(_entity.AddCargo(target.RemoveCargo(match)));
}
Wait(_data.DockTime, OnItemObtained);
}
void OnItemObtained()
{
var haulingTask = _context.Cache.Get<HaulingTask>(Task);
_entity.SetMessage("Entering delivery phase.");
var target = _context.Cache.Get<Entity>(haulingTask.Target);
MoveTo(target.Zone, OnTargetZoneArrival);
}
void OnTargetZoneArrival()
{
var haulingTask = _context.Cache.Get<HaulingTask>(Task);
MoveTo(_context.Cache.Get<Entity>(haulingTask.Target), true, OnDelivery);
}
void OnDelivery()
{
var haulingTask = _context.Cache.Get<HaulingTask>(Task);
var target = _context.ZoneEntities[_entity.Zone][haulingTask.Target] as OrbitalEntity;
_context.SetParent(_entity, target);
var itemData = _context.Cache.Get<ItemData>(haulingTask.ItemType);
if (itemData is SimpleCommodityData)
{
target.AddCargo(_entity.RemoveCargo(_simpleCommodityDelivery, _simpleCommodityDelivery.Quantity));
_itemsDelivered += _simpleCommodityDelivery.Quantity;
_simpleCommodityDelivery = null;
}
else if (itemData is CraftedItemData)
{
foreach (var item in _craftedItemDelivery)
target.AddCargo(_entity.RemoveCargo(item));
_itemsDelivered += _craftedItemDelivery.Count;
_craftedItemDelivery.Clear();
}
Wait(_data.DockTime, () =>
{
if(_itemsDelivered == haulingTask.Quantity)
FinishTask();
else
_taskStarted = false;
});
}
public PersistentBehaviorData Store()
{
return new HaulingControllerPersistence
{
Task = Task
};
}
public void Restore(PersistentBehaviorData data)
{
var towingControllerPersistence = data as HaulingControllerPersistence;
Task = towingControllerPersistence.Task;
}
}
public class HaulingControllerPersistence : PersistentBehaviorData
{
[JsonProperty("task"), Key(0)]
public Guid Task;
}

View file

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

View file

@ -41,6 +41,7 @@ public interface INamedEntry
Union(21, typeof(Mining)),
Union(22, typeof(StationTowing)),
Union(23, typeof(Survey)),
Union(24, typeof(HaulingTask)),
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
//[Union(21, typeof(ContractData))]
//[Union(22, typeof(Station))]

View file

@ -170,6 +170,13 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
foreach (var hardpoint in Hardpoints)
if(hardpoint.Gear!=null)
foreach (var behavior in hardpoint.Behaviors)
{
if(behavior is IPopulationAssignment populationAssignment)
PopulationAssignments.Add(populationAssignment);
if(behavior is IInitializableBehavior initializableBehavior)
initializableBehavior.Initialize();
}
RecalculateMass();
}
@ -199,13 +206,6 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
})
.ToArray();
foreach (var behavior in hardpoint.Behaviors)
{
if(behavior is IPopulationAssignment populationAssignment)
PopulationAssignments.Add(populationAssignment);
if(behavior is IInitializableBehavior initializableBehavior)
initializableBehavior.Initialize();
}
}
public void Unequip(Hardpoint hardpoint)
@ -550,20 +550,34 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
public virtual void Update(float delta)
{
if (!Active)
return;
foreach (var hardpoint in Hardpoints.Where(hp=>hp.Gear!=null))
if (Active)
{
foreach (var group in hardpoint.BehaviorGroups)
foreach (var hardpoint in Hardpoints.Where(hp=>hp.Gear!=null))
{
foreach (var group in hardpoint.BehaviorGroups)
foreach(var behavior in group.Behaviors)
if(!behavior.Update(delta))
break;
foreach (var behavior in hardpoint.Behaviors.Where(b => b is IAlwaysUpdatedBehavior).Cast<IAlwaysUpdatedBehavior>())
behavior.AlwaysUpdate(delta);
foreach (var behavior in hardpoint.Behaviors.Where(b => b is IAlwaysUpdatedBehavior).Cast<IAlwaysUpdatedBehavior>())
behavior.AlwaysUpdate(delta);
if(hardpoint.Gear.ItemData.Performance(Temperature) < .01f)
hardpoint.Gear.Durability -= delta;
if(hardpoint.Gear.ItemData.Performance(Temperature) < .01f)
hardpoint.Gear.Durability -= delta;
}
foreach (var message in Messages.Keys.ToArray())
{
Messages[message] = Messages[message] - delta;
if (Messages[message] < 0)
Messages.Remove(message);
}
foreach (var incompleteGear in IncompleteGear.Keys.ToArray())
{
IncompleteGear[incompleteGear] = IncompleteGear[incompleteGear] - delta;
if (IncompleteGear[incompleteGear] < 0) Equip(incompleteGear);
}
}
if (Parent != Guid.Empty)
@ -574,79 +588,6 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
Temperature = parent.Temperature;
}
// Processing stale item data properly was a pain in my ass, so the shortcut is just persisting and restoring everything
// if (Hardpoints.Any(hp => hp.Gear.ItemData != hp.ItemData))
// {
// OnBeforeSerialize();
// OnAfterDeserialize();
// }
foreach (var message in Messages.Keys.ToArray())
{
Messages[message] = Messages[message] - delta;
if (Messages[message] < 0)
Messages.Remove(message);
}
foreach (var incompleteGear in IncompleteGear.Keys.ToArray())
{
IncompleteGear[incompleteGear] = IncompleteGear[incompleteGear] - delta;
if (IncompleteGear[incompleteGear] < 0) Equip(incompleteGear);
}
// Here's the PITA way
// foreach (var staleItem in GearData
// .Where(kvp=>kvp.Key.ItemData!=kvp.Value)
// .Select(kvp=>kvp.Key))
// {
// // Item is stale, there's an updated one in the database cache
// //var actualItem = Context.Cache.Get<Gear>(staleItem.ID);
// var staleBehaviors = ItemBehaviors[staleItem];
// ItemBehaviors.Remove(staleItem);
//
// // We'll be reloading the item along with its behaviors, some data must be persisted
// var persistentData = staleBehaviors
// .Where(b => b is IPersistentBehavior)
// .Cast<IPersistentBehavior>()
// .Select(b => b.Store());
//
// // Regenerate the behavior list for the updated item
// ItemBehaviors[staleItem] = staleItem.ItemData.Behaviors
// .Select(bd => bd.CreateInstance(Context, this, staleItem))
// .OrderBy(b => b.GetType().GetCustomAttribute<UpdateOrderAttribute>()?.Order ?? 0).ToList();
//
// foreach(var behavior in ItemBehaviors[staleItem])
// behavior.Initialize();
//
// // Restore state for persisted behaviors
// foreach(var persistentBehaviorData in ItemBehaviors[staleItem]
// .Where(b => b is IPersistentBehavior)
// .Cast<IPersistentBehavior>()
// .Zip(persistentData, (behavior, data) => new {behavior, data}))
// persistentBehaviorData.behavior.Restore(persistentBehaviorData.data);
//
// // Regenerate activated behavior bindings
// if (Bindings.ContainsKey(staleItem))
// {
// Bindings.Remove(staleItem);
// Bindings[staleItem] = ItemBehaviors[staleItem]
// .Where(b => b is IActivatedBehavior)
// .Cast<IActivatedBehavior>().ToList();
// }
//
// // Remove axis bindings and overrides for analog behaviors
// foreach (var axis in staleBehaviors.Where(b => b is IAnalogBehavior).Cast<IAnalogBehavior>())
// {
// Axes.Remove(axis);
// if (AxisOverrides.ContainsKey(axis))
// AxisOverrides.Remove(axis);
// }
//
// // Regenerate axis bindings for analog behaviors
// foreach (var axis in ItemBehaviors[staleItem].Where(b => b is IAnalogBehavior).Cast<IAnalogBehavior>())
// Axes[axis] = 0;
// }
if (_cargoChanged)
{
CargoEvent.Change();

View file

@ -709,15 +709,9 @@ public class GameContext
if (hullData.HullType == HullType.Ship)
{
var entity = new Ship(this, hull.ID, gear.Select(g => g.ID),
cargo.Select(c => c.ID).Concat(simpleCargo.Select(c => c.ID)), zone, corporation)
{
Name = $"{loadoutData.Name} {Random.NextInt(1,255):X}"
};
var entity = CreateShip(hull.ID, gear.Select(g => g.ID),
cargo.Select(c => c.ID).Concat(simpleCargo.Select(c => c.ID)), zone, corporation, loadoutData.Name);
entity.Active = true;
Cache.Add(entity);
ZoneEntities[zone][entity.ID] = entity;
return entity;
}
@ -757,6 +751,19 @@ public class GameContext
return null;
}
public Ship CreateShip(Guid hull, IEnumerable<Guid> gear, IEnumerable<Guid> cargo, Guid zone, Guid corporation, string typeName)
{
var ship = new Ship(this, hull, gear, cargo, zone, corporation)
{
Name = $"{typeName} {Random.NextInt(1,255):X}"
};
Cache.Add(ship);
ZoneEntities[zone][ship.ID] = ship;
return ship;
}
public SimpleCommodity CreateInstance(Guid data, int count)
{

View file

@ -304,6 +304,7 @@ public class StrategyGameManager : MonoBehaviour
if (_currentTab == ColonyTabButton)
{
PropertiesPanel.Clear();
ColonyTab.Open(_selectedColony);
}
};

View file

@ -17,8 +17,8 @@ public class ColonyTab : MonoBehaviour
public PropertiesPanel ChildInventory;
public PropertiesPanel Details;
public ContextMenu ContextMenu;
public ConfirmationDialog ConfirmationDialog;
[HideInInspector]
public GameContext Context
{
get => _context;
@ -242,6 +242,37 @@ public class ColonyTab : MonoBehaviour
panel.AddSection("No Cargo");
else
{
Action<Guid, int> showHaulingDialog = (id, maxQuantity) =>
{
var itemData = Context.Cache.Get<ItemData>(id);
ConfirmationDialog.gameObject.SetActive(true);
ConfirmationDialog.Clear();
ConfirmationDialog.Title.text = $"Haul {itemData.Name}";
var quantity = maxQuantity;
var colonies = Context.Cache.GetAll<Entity>()
.Where(e => e.Corporation == entity.Corporation && e is OrbitalEntity && e != entity).ToArray();
var colonyNames = colonies.Select(c => c.Name).ToArray();
ConfirmationDialog.AddField("Quantity", () => quantity, i => quantity = clamp(i, 1, maxQuantity));
var selectedColony = 0;
ConfirmationDialog.AddField("Target Colony", () => selectedColony, i => selectedColony = i,
colonyNames);
ConfirmationDialog.Show(() =>
{
var haulingTask = new HaulingTask
{
Context = Context,
ItemType = id,
Origin = entity.ID,
Quantity = quantity,
Target = colonies[selectedColony].ID,
Zone = entity.Zone
};
Context.Cache.Add(haulingTask);
var corp = Context.Cache.Get<Corporation>(entity.Corporation);
corp.Tasks.Add(haulingTask.ID);
});
};
panel.AddSection("Cargo");
foreach (var itemID in entity.Cargo.Where(id => Context.Cache.Get<ItemInstance>(id) is SimpleCommodity))
{
@ -249,10 +280,20 @@ public class ColonyTab : MonoBehaviour
var data = simpleCommodity.ItemData;
panel.AddProperty(data.Name, () => simpleCommodity.Quantity.ToString(), eventData =>
{
Details.Clear();
Details.RemoveListener();
Details.AddItemProperties(entity, simpleCommodity);
Details.RefreshValues();
if (eventData.button == PointerEventData.InputButton.Left)
{
Details.Clear();
Details.RemoveListener();
Details.AddItemProperties(entity, simpleCommodity);
Details.RefreshValues();
}
else if (eventData.button == PointerEventData.InputButton.Right)
{
ContextMenu.gameObject.SetActive(true);
ContextMenu.Clear();
ContextMenu.AddOption("Haul", () => showHaulingDialog(simpleCommodity.Data, simpleCommodity.Quantity));
ContextMenu.Show();
}
}, true).Button.DragSuccess = eventData =>
{
Entity targetEntity = null;
@ -266,12 +307,19 @@ public class ColonyTab : MonoBehaviour
if (targetEntity != null)
{
int quantity = min((int) ((targetEntity.Capacity - targetEntity.OccupiedCapacity) / simpleCommodity.ItemData.Size), simpleCommodity.Quantity);
if (quantity > 0)
int maxQuantity = min((int) ((targetEntity.Capacity - targetEntity.OccupiedCapacity) / simpleCommodity.ItemData.Size), simpleCommodity.Quantity);
if (maxQuantity > 0)
{
var newItem = entity.RemoveCargo(simpleCommodity, quantity);
targetEntity.AddCargo(newItem);
return true;
ConfirmationDialog.gameObject.SetActive(true);
ConfirmationDialog.Clear();
ConfirmationDialog.Title.text = $"Move {simpleCommodity.ItemData.Name}";
var quantity = maxQuantity;
ConfirmationDialog.AddField("Quantity", () => quantity, i => quantity = clamp(i, 1, maxQuantity));
ConfirmationDialog.Show(() =>
{
var newItem = entity.RemoveCargo(simpleCommodity, quantity);
targetEntity.AddCargo(newItem);
});
}
}
@ -288,7 +336,7 @@ public class ColonyTab : MonoBehaviour
var corp = "GameCult";
if (craftedItem.SourceEntity != Guid.Empty)
corp = Context.Cache.Get<Corporation>(Context.Cache.Get<Entity>(craftedItem.SourceEntity).Corporation).Name;
return (craftedItem.Data, craftedItem.Name, corp) ;
return (craftedItem.Data, craftedItem.Name, corp);
}))
{
Action<CraftedItemInstance, PointerEventData> onClick = (item, data) =>
@ -308,15 +356,21 @@ public class ColonyTab : MonoBehaviour
if (gear.ItemData is HullData)
{
entity.RemoveCargo(gear);
var ship = new Ship(Context, gear.ID, Enumerable.Empty<Guid>(), Enumerable.Empty<Guid>(), entity.Zone, entity.Corporation);
ship.Name = gear.Name;
_context.Cache.Add(ship);
var ship = Context.CreateShip(gear.ID, Enumerable.Empty<Guid>(),
Enumerable.Empty<Guid>(), entity.Zone, entity.Corporation, gear.Name);
_context.SetParent(ship, entity);
}
else // Equip Item
entity.Equip(gear.ID, true);
}
}
else if (data.button == PointerEventData.InputButton.Right)
{
ContextMenu.gameObject.SetActive(true);
ContextMenu.Clear();
ContextMenu.AddOption("Haul", () => showHaulingDialog(item.Data, group.Count()));
ContextMenu.Show();
}
};
Func<PointerEventData, CraftedItemInstance, bool> dragSuccess = (data, item) =>
{

View file

@ -0,0 +1,54 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ConfirmationDialog : PropertiesPanel
{
public ClickCatcher CancelClickCatcher;
public FlatButton Cancel;
public FlatButton Confirm;
private Action _onCancel;
private Action _onConfirm;
private new void Start()
{
Cancel.OnClick += () =>
{
_onCancel?.Invoke();
End();
};
Confirm.OnClick += () =>
{
_onConfirm?.Invoke();
End();
};
if (CancelClickCatcher != null)
CancelClickCatcher.OnClick += data =>
{
_onCancel?.Invoke();
End();
};
OnPropertyAdded += go =>
{
go.SetActive(true);
go.transform.SetSiblingIndex(Title.transform.GetSiblingIndex() + 1);
};
}
private void End()
{
CancelClickCatcher.gameObject.SetActive(false);
gameObject.SetActive(false);
}
public void Show(Action onConfirm, Action onCancel = null)
{
_onConfirm = onConfirm;
_onCancel = onCancel;
transform.position = Input.mousePosition;
CancelClickCatcher.gameObject.SetActive(true);
}
}

View file

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

View file

@ -63,6 +63,7 @@ public class PropertiesPanel : MonoBehaviour
public void Clear()
{
RemoveListener();
foreach(var property in Properties)
Destroy(property);
Properties.Clear();
@ -187,7 +188,11 @@ public class PropertiesPanel : MonoBehaviour
{
field.Field.text = s;
field.gameObject.SetActive(false);
Observable.NextFrame().Subscribe(_ => OnPropertyAdded?.Invoke(field.gameObject));
Observable.NextFrame().Subscribe(_ =>
{
if(field != null)
OnPropertyAdded?.Invoke(field.gameObject);
});
}
};
Properties.Add(field.gameObject);
@ -410,7 +415,13 @@ public class PropertiesPanel : MonoBehaviour
.Select(id => Context.Cache.Get<ItemInstance>(id))
.Where(item => item is CraftedItemInstance)
.Cast<CraftedItemInstance>()
.GroupBy(craftedItem => (craftedItem.Data, craftedItem.Name, Context.Cache.Get<Corporation>(Context.Cache.Get<Entity>(craftedItem.SourceEntity).Corporation))))
.GroupBy(craftedItem =>
{
var corp = "GameCult";
if (craftedItem.SourceEntity != Guid.Empty)
corp = Context.Cache.Get<Corporation>(Context.Cache.Get<Entity>(craftedItem.SourceEntity).Corporation).Name;
return (craftedItem.Data, craftedItem.Name, corp);
}))
{
if (group.Count() == 1)
{
@ -524,6 +535,8 @@ public class PropertiesPanel : MonoBehaviour
RemoveListener();
ChangeSource = hardpoint.Gear;
if (ChangeSource == null)
return;
OnPropertiesChanged = InspectGearInternal;
ChangeSource.OnChanged += OnPropertiesChanged;
InspectGearInternal();

View file

@ -64,6 +64,7 @@
<Compile Include="Assets\Scripts\ServerShared\Agents\AgentBehavior.cs" />
<Compile Include="Assets\Scripts\ServerShared\Agents\AgentTask.cs" />
<Compile Include="Assets\Scripts\ServerShared\Agents\Aim.cs" />
<Compile Include="Assets\Scripts\ServerShared\Agents\HaulingTask.cs" />
<Compile Include="Assets\Scripts\ServerShared\Agents\Locomotion.cs" />
<Compile Include="Assets\Scripts\ServerShared\Agents\Mining.cs" />
<Compile Include="Assets\Scripts\ServerShared\Agents\StationTowing.cs" />
@ -76,6 +77,7 @@
<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\HaulingController.cs" />
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Heat.cs" />
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Hitscan.cs" />
<Compile Include="Assets\Scripts\ServerShared\Behaviors\ItemUsage.cs" />