public void SellResource(ResourceId _resource, float _amount) { if (selectedVehicle.Inventory.CheckForResource(_resource)) { _amount = Mathf.Min(selectedVehicle.Inventory.GetResourceAmount(_resource), _amount); player.Money += (int)CalculateValue(_resource, _amount); selectedVehicle.Inventory.RemoveResource(_resource, _amount); UpdateCapacity(); uiAudio.PlaySound(UIsounds.Purchase); } }
void LeftClickActions(RaycastResult result) { if (heldItem != null && result.gameObject.tag == "PartComponent" && heldItem.type == ContentType.Part) { VehicleEditorComponent _component = result.gameObject.GetComponentInParent <VehicleEditorComponent>(); if (heldItem.partContent is PartDrill && _component.partType == PartType.Drill) { uiAudio.PlaySound(UIsounds.Upgrade); _component.AddPart(heldItem.partContent); Drop(); editorTabs[openEditorIndex].FinalizeChanges(); return; } else if (heldItem.partContent is PartCabin && _component.partType == PartType.Cabin) { uiAudio.PlaySound(UIsounds.Upgrade); _component.AddPart(heldItem.partContent); Drop(); editorTabs[openEditorIndex].FinalizeChanges(); return; } else if (heldItem.partContent is PartEngine && _component.partType == PartType.Engine) { uiAudio.PlaySound(UIsounds.Upgrade); _component.AddPart(heldItem.partContent); Drop(); editorTabs[openEditorIndex].FinalizeChanges(); return; } else if (heldItem.partContent is PartWheel && _component.partType == PartType.Wheels) { uiAudio.PlaySound(UIsounds.Upgrade); _component.AddPart(heldItem.partContent); Drop(); editorTabs[openEditorIndex].FinalizeChanges(); return; } else if (heldItem.partContent is PartUpgrade && _component.partType == PartType.Upgrade) { uiAudio.PlaySound(UIsounds.Upgrade); _component.AddPart(heldItem.partContent); Drop(); editorTabs[openEditorIndex].FinalizeChanges(); return; } else { Drop(); } } else if (heldItem != null && result.gameObject.tag == "WorkerComponent" && heldItem.type == ContentType.Worker) { EditorWorkerComponent _component = result.gameObject.GetComponentInParent <EditorWorkerComponent>(); editorTabs[openEditorIndex].vehicle.GetPart(out PartCabin _cabin); bool canEquipAuxillary = _cabin != null || _component.station == WorkStation.Cabin; if (editorTabs[openEditorIndex].vehicle.CrewCount < editorTabs[openEditorIndex].vehicle.CrewCountMax && canEquipAuxillary) { _component.AddWorker(heldItem.workerContent); Drop(); editorTabs[openEditorIndex].EquipWorker(_component.station); } else { Drop(); } } else { Drop(); } }