Skip to content

Commit

Permalink
disable ammo usage for AI ships
Browse files Browse the repository at this point in the history
  • Loading branch information
Gutin1 committed Jan 29, 2025
1 parent 0a76a80 commit c777984
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package net.horizonsend.ion.server.features.starship.subsystem.misc

import net.horizonsend.ion.server.features.multiblock.type.misc.AbstractMagazineMultiblock
import net.horizonsend.ion.server.features.starship.active.ActiveStarship
import net.horizonsend.ion.server.features.starship.control.controllers.ai.AIController
import net.horizonsend.ion.server.features.starship.subsystem.AbstractMultiblockSubsystem
import net.horizonsend.ion.server.features.starship.subsystem.weapon.interfaces.AmmoConsumingWeaponSubsystem
import net.horizonsend.ion.server.miscellaneous.utils.leftFace
Expand All @@ -12,11 +13,13 @@ import org.bukkit.inventory.InventoryHolder

class MagazineSubsystem(starship: ActiveStarship, sign: Sign, multiblock: AbstractMagazineMultiblock) : AbstractMultiblockSubsystem<AbstractMagazineMultiblock>(starship, sign, multiblock) {
fun isAmmoAvailable(subsystem: AmmoConsumingWeaponSubsystem): Boolean {
if (starship.controller is AIController) return true
val inventory = getInventory() ?: return false
return inventory.filterNotNull().any(subsystem::isRequiredAmmo)
}

fun tryConsumeAmmo(subsystem: AmmoConsumingWeaponSubsystem): Boolean {
if (starship.controller is AIController) return true
val inventory = getInventory()
?: return false

Expand Down

0 comments on commit c777984

Please sign in to comment.