private bool IsApplianceApplicableToBodyPart(ZaraEngine.Inventory.InventoryMedicalItemBase item, ZaraEngine.Injuries.BodyParts bodyPart) { if (item.Name == InventoryController.MedicalItems.Splint) { if (bodyPart != ZaraEngine.Injuries.BodyParts.LeftForearm && bodyPart != ZaraEngine.Injuries.BodyParts.LeftShin && bodyPart != ZaraEngine.Injuries.BodyParts.LeftSpokebone && bodyPart != ZaraEngine.Injuries.BodyParts.RightForearm && bodyPart != ZaraEngine.Injuries.BodyParts.RightShin && bodyPart != ZaraEngine.Injuries.BodyParts.RightSpokebone) { return(false); } } if (item.Name == InventoryController.MedicalItems.Bandage) { if (bodyPart != ZaraEngine.Injuries.BodyParts.Belly && bodyPart != ZaraEngine.Injuries.BodyParts.Forehead && bodyPart != ZaraEngine.Injuries.BodyParts.LeftBrush && bodyPart != ZaraEngine.Injuries.BodyParts.LeftChest && bodyPart != ZaraEngine.Injuries.BodyParts.LeftFoot && bodyPart != ZaraEngine.Injuries.BodyParts.LeftForearm && bodyPart != ZaraEngine.Injuries.BodyParts.LeftHip && bodyPart != ZaraEngine.Injuries.BodyParts.LeftKnee && bodyPart != ZaraEngine.Injuries.BodyParts.LeftShin && bodyPart != ZaraEngine.Injuries.BodyParts.LeftShoulder && bodyPart != ZaraEngine.Injuries.BodyParts.LeftSpokebone && bodyPart != ZaraEngine.Injuries.BodyParts.RightBrush && bodyPart != ZaraEngine.Injuries.BodyParts.RightChest && bodyPart != ZaraEngine.Injuries.BodyParts.RightFoot && bodyPart != ZaraEngine.Injuries.BodyParts.RightForearm && bodyPart != ZaraEngine.Injuries.BodyParts.RightHip && bodyPart != ZaraEngine.Injuries.BodyParts.RightKnee && bodyPart != ZaraEngine.Injuries.BodyParts.RightShin && bodyPart != ZaraEngine.Injuries.BodyParts.RightShoulder && bodyPart != ZaraEngine.Injuries.BodyParts.RightSpokebone && bodyPart != ZaraEngine.Injuries.BodyParts.Throat) { return(false); } } return(true); }
private bool TryProcessMedicalAppliance(ZaraEngine.Inventory.IInventoryItem item, ZaraEngine.Injuries.BodyParts bodyPart) { var appliance = item as ZaraEngine.Inventory.InventoryMedicalItemBase; if (item is null) { return(false); } if (appliance is null) { Debug.Log($"The item {item.Name} is not a medical item"); return(false); } if (appliance.MedicineKind != ZaraEngine.Inventory.InventoryMedicalItemBase.MedicineKinds.Appliance) { Debug.Log($"The item {item.Name} is not an appliance"); return(false); } if (!IsApplianceApplicableToBodyPart(appliance, bodyPart)) { Debug.Log($"The item {item.Name} cannot be applied to {bodyPart}"); return(false); } // After all checks are done, and we know that we can use this appliance on a selected body part, we must use this item in the inventory // and notify our health angine that we took some kind of medical thing -- for the health engine to do its job var isUsed = false; var usageResult = _inventory.TryUse(item, checkOnly: false); isUsed = usageResult.Result == ZaraEngine.Inventory.ItemUseResult.UsageResult.UsedAll || usageResult.Result == ZaraEngine.Inventory.ItemUseResult.UsageResult.UsedSingle; if (isUsed) { // Notify the health angine _health.OnApplianceTaken(appliance, bodyPart); RefreshConsumablesUICombo(); RefreshToolsUICombo(); Debug.Log($"Appliance {appliance.Name} was applied to the {bodyPart}"); return(true); } return(false); }