Skip to content

Commit

Permalink
First pass on ship threat as spawn criteria
Browse files Browse the repository at this point in the history
- Add debug module for ShipBuilder
- Split default ship outfitting rules into separate file
  • Loading branch information
sturnclaw committed Sep 11, 2024
1 parent 2f55e64 commit 68a25a0
Show file tree
Hide file tree
Showing 3 changed files with 448 additions and 64 deletions.
65 changes: 65 additions & 0 deletions data/modules/MissionUtils/DebugShipBuilder.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

local debugView = require 'pigui.views.debug'
local ShipDef = require 'ShipDef'
local ShipBuilder = require 'modules.MissionUtils.ShipBuilder'
local ShipConfig = require 'ShipConfig'

local ui = require 'pigui'

debugView.registerTab("ShipBuilder", {
selectedHull = nil,
draw = function(self)
if not ui.beginTabItem("ShipBuilder") then
return
end

if self.selectedHull then
if ui.button("<") then
self.selectedHull = nil

ui.endTabItem()
return
end

ui.sameLine()
ui.text(self.selectedHull)

ui.spacing()

if ui.collapsingHeader("Hull Threat") then
local threat = ShipBuilder.GetHullThreat(self.selectedHull)

for k, v in pairs(threat) do
ui.text(tostring(k) .. ": " .. tostring(v))
end
end

if ui.collapsingHeader("Slots") then
local config = ShipConfig[self.selectedHull]

for k, v in pairs(config.slots) do
ui.text(k)

local data = " "
for k2, v2 in pairs(v) do
data = data .. tostring(k2) .. " = " .. tostring(v2) .. ", "
end

ui.text(data)
end
end
else
for id, def in pairs(ShipDef) do
if ui.selectable(id) then
self.selectedHull = id
end

local threat = ShipBuilder.GetHullThreat(id)
ui.sameLine()
ui.text("threat: " .. tostring(threat.total))
end
end

ui.endTabItem()
end
})
44 changes: 44 additions & 0 deletions data/modules/MissionUtils/OutfitRules.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt

local Engine = require 'Engine'
local Equipment = require 'Equipment'
local EquipSet = require 'EquipSet'
local ShipDef = require 'ShipDef'
local ShipConfig = require 'ShipConfig'
local Space = require 'Space'
local Ship = require 'Ship'

local utils = require 'utils'

---@class MissionUtils.OutfitRules
local OutfitRules = {}

OutfitRules.DefaultHyperdrive = {
slot = "hyperdrive"
}

OutfitRules.DefaultAtmoShield = {
slot = "hull",
filter = "hull.atmo_shield",
limit = 1
}

OutfitRules.DefaultShieldGen = {
slot = "shield",
limit = 1
}

OutfitRules.DefaultAutopilot = {
slot = "computer",
equip = "misc.autopilot",
limit = 1
}

OutfitRules.DefaultLaserCooling = {
slot = nil,
equip = "misc.laser_cooling_booster",
limit = 1
}

return OutfitRules
Loading

0 comments on commit 68a25a0

Please sign in to comment.