100 lines
3.3 KiB
GDScript
100 lines
3.3 KiB
GDScript
class_name DiveRulesResolver
|
|
extends RefCounted
|
|
|
|
const DiveDifficultyProfile = preload("res://game/domain/rules/dive_difficulty_profile.gd")
|
|
const DiveUpgradeEffects = preload("res://game/domain/rules/dive_upgrade_effects.gd")
|
|
const DiveAccessibilityAdjustments = preload(
|
|
"res://game/domain/rules/dive_accessibility_adjustments.gd"
|
|
)
|
|
const ResolvedDiveRules = preload("res://game/domain/rules/resolved_dive_rules.gd")
|
|
|
|
const BASE_BATTERY_CAPACITY_KWH := 100.0
|
|
const BASE_OXYGEN_CAPACITY_L := 480.0
|
|
const BASE_OXYGEN_CONSUMPTION_L_PER_MIN := 30.0
|
|
const BASE_HULL_INTEGRITY := 100.0
|
|
const BASE_CERTIFIED_DEPTH_M := 60.0
|
|
|
|
const BASE_LONGITUDINAL_POWER_KW := 1800.0
|
|
const BASE_STEERING_POWER_KW := 180.0
|
|
const BASE_VERTICAL_POWER_KW := 360.0
|
|
const BASE_HIGH_THRUST_POWER_KW := 900.0
|
|
const BASE_RETURN_ENERGY_KWH_PER_M := 100.0 / 1200.0
|
|
const BASE_ASCENT_ENERGY_KWH_PER_M := 0.035
|
|
|
|
|
|
func resolve(
|
|
difficulty: DiveDifficultyProfile,
|
|
upgrades: DiveUpgradeEffects = null,
|
|
accessibility: DiveAccessibilityAdjustments = null
|
|
) -> ResolvedDiveRules:
|
|
var resolved_upgrades: DiveUpgradeEffects = (
|
|
upgrades if upgrades != null else DiveUpgradeEffects.new()
|
|
)
|
|
var resolved_accessibility: DiveAccessibilityAdjustments = (
|
|
accessibility if accessibility != null else DiveAccessibilityAdjustments.new()
|
|
)
|
|
if difficulty == null:
|
|
return null
|
|
if not difficulty.validation_error().is_empty():
|
|
return null
|
|
if not resolved_upgrades.validation_error().is_empty():
|
|
return null
|
|
if not resolved_accessibility.validation_error().is_empty():
|
|
return null
|
|
|
|
# Base values, then submarine upgrades, difficulty and gameplay accessibility.
|
|
var battery_capacity: float = (
|
|
BASE_BATTERY_CAPACITY_KWH + resolved_upgrades.battery_capacity_bonus_kwh
|
|
)
|
|
var oxygen_capacity: float = (
|
|
BASE_OXYGEN_CAPACITY_L + resolved_upgrades.oxygen_capacity_bonus_l
|
|
)
|
|
var hull_integrity: float = BASE_HULL_INTEGRITY + resolved_upgrades.hull_integrity_bonus
|
|
var certified_depth: float = (
|
|
BASE_CERTIFIED_DEPTH_M + resolved_upgrades.certified_depth_bonus_m
|
|
)
|
|
|
|
var battery_multiplier: float = (
|
|
resolved_upgrades.battery_consumption_multiplier
|
|
* difficulty.battery_consumption_multiplier
|
|
* resolved_accessibility.battery_consumption_multiplier
|
|
)
|
|
var oxygen_multiplier: float = (
|
|
difficulty.oxygen_consumption_multiplier
|
|
* resolved_accessibility.oxygen_consumption_multiplier
|
|
)
|
|
var pressure_multiplier: float = (
|
|
resolved_upgrades.pressure_damage_multiplier
|
|
* difficulty.pressure_damage_multiplier
|
|
* resolved_accessibility.pressure_damage_multiplier
|
|
)
|
|
var collision_multiplier: float = (
|
|
resolved_upgrades.collision_damage_multiplier
|
|
* difficulty.collision_damage_multiplier
|
|
)
|
|
|
|
var result: ResolvedDiveRules = ResolvedDiveRules.new(
|
|
battery_capacity,
|
|
oxygen_capacity,
|
|
BASE_OXYGEN_CONSUMPTION_L_PER_MIN * oxygen_multiplier,
|
|
hull_integrity,
|
|
certified_depth,
|
|
BASE_LONGITUDINAL_POWER_KW * battery_multiplier,
|
|
BASE_STEERING_POWER_KW * battery_multiplier,
|
|
BASE_VERTICAL_POWER_KW * battery_multiplier,
|
|
BASE_HIGH_THRUST_POWER_KW * battery_multiplier,
|
|
BASE_RETURN_ENERGY_KWH_PER_M * battery_multiplier,
|
|
BASE_ASCENT_ENERGY_KWH_PER_M * battery_multiplier,
|
|
pressure_multiplier,
|
|
collision_multiplier,
|
|
3.5,
|
|
4.0,
|
|
0.45,
|
|
1.5 * difficulty.crush_grace_multiplier,
|
|
0.30,
|
|
0.15,
|
|
0.05,
|
|
3.0
|
|
)
|
|
return result if result.validation_error().is_empty() else null
|