Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ship Equipment Overhaul - EquipSet v2 #5734

Merged
merged 119 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
1994fd9
Provide lua access to the raw shipdef json values
Web-eWorks Feb 13, 2023
6ba9057
Equipment item prototype and instances
Web-eWorks Feb 13, 2023
5ad02ba
Polyfill equipment mass/volume
Web-eWorks Feb 17, 2023
758d7c6
Convert equipment to use new slot system
Web-eWorks Dec 16, 2023
85e5800
Remove old EquipSet implementation
Web-eWorks Dec 22, 2023
d9ccc6b
ItemCard improvements
Web-eWorks Jan 15, 2024
2f5d7b8
Equipment: mark equip as persistent, separate CabinType
Web-eWorks Jan 15, 2024
02bc14d
temp: add EquipSetCompat to fill old EquipSet API
Web-eWorks Jan 15, 2024
4076518
Fully remove Ship:GetStats() from Lua API
Web-eWorks Jan 16, 2024
b1d9c97
Ship: rename usedCapacity -> loadedMass
Web-eWorks Jan 16, 2024
9024710
ShipType: capacity is volume, add cargo attribute
Web-eWorks Jan 16, 2024
5dd80de
Cargo space is separate from equipment volume
Web-eWorks Jan 18, 2024
3321ee8
Add ShipConfig class
Web-eWorks Jan 19, 2024
ecd690f
New EquipSet implementation
Web-eWorks Jan 19, 2024
f4e08f9
EquipType: migrate to EquipSet v2
Web-eWorks Jan 19, 2024
6b360c1
Ship: add GetInstalledHyperdrive, initialize EquipSet
Web-eWorks Jan 20, 2024
a814ce4
Add Passenger helper library
Web-eWorks Jan 20, 2024
7246d32
Add proof-of-concept ShipBuilder utility library
Web-eWorks Jan 20, 2024
ad787f1
Convert misc. UI code to new EquipSet APIs
Web-eWorks Jan 21, 2024
8c28f52
First pass updating mission modules to use new APIs
Web-eWorks Feb 3, 2024
ddbb95a
Ship: remove unused methods, deprecate AddEquip
Web-eWorks Feb 3, 2024
e197fce
Move equipment resell price modifier into Economy.lua
Web-eWorks Feb 3, 2024
5c812bc
Break equip card rendering out into a separate file
Web-eWorks Feb 3, 2024
890dcca
Replace equipment market with equipment outfitter
Web-eWorks Feb 3, 2024
8330e35
hack: new equipment API in new game menu
Web-eWorks Feb 3, 2024
7e34e2d
test: add ship configurations for bowfin + coronatrix
Web-eWorks Feb 3, 2024
3dad275
Add new translation strings for equipment system
Web-eWorks Feb 3, 2024
a74db2e
First pass on ship threat as spawn criteria
Web-eWorks Sep 11, 2024
31b644a
Spawn police with new ShipBuilder API
Web-eWorks Sep 11, 2024
9fac8bb
ui: unify rounding value used for item-card like elements
Web-eWorks Sep 12, 2024
3168013
item-card: configurable main icon color
Web-eWorks Sep 12, 2024
ffbe8d6
EquipSet: don't copy installed array, write cache on install
Web-eWorks Sep 12, 2024
57730c0
Equip: handle multi-count item slots, SpecializeForShip
Web-eWorks Sep 13, 2024
f506262
Outfitter: handle multi-count and specialized items
Web-eWorks Sep 13, 2024
37b3041
Update thruster equipment to use multi-count slots
Web-eWorks Sep 13, 2024
b185fcc
ShipBuilder: handle multi-count slots and SpecializeForShip
Web-eWorks Sep 13, 2024
c7b04b8
EquipSet: add recursive slot capability
Web-eWorks Sep 17, 2024
74e7ecf
Support recursive slots in ship equipment UI
Web-eWorks Sep 17, 2024
cd00604
Outfitter: select adjacent slots on purchase, double-click to buy
Web-eWorks Sep 17, 2024
324b4ab
Outfitter: allow user to sort market list
Web-eWorks Sep 18, 2024
159d777
ShipBuilder: handle recursive slots
Web-eWorks Sep 18, 2024
ea6a724
Rename ShipConfig -> HullConfig
Web-eWorks Sep 19, 2024
872e119
fixup: type annotation for utils.proto
Web-eWorks Sep 19, 2024
2b50be8
Add coronatrix internal missile rack for testing
Web-eWorks Sep 19, 2024
5a871a2
ShipBuilder: support controlling rules by threat factor
Web-eWorks Sep 19, 2024
cf3fa43
ShipBuilder: add shared rules for weapon and shield slots
Web-eWorks Sep 20, 2024
d25a522
Update Assassination mission to use ShipBuilder API
Web-eWorks Sep 20, 2024
ea4fa88
OutfitRules: add pulsecannon rules
Web-eWorks Sep 20, 2024
48691f6
CargoRun: convert to ShipBuilder API
Web-eWorks Sep 20, 2024
6e6454b
Taxi: convert to ShipBuilder template API
Web-eWorks Sep 20, 2024
9fbfadd
MissionUtils: add shared ShipTemplates file
Web-eWorks Sep 20, 2024
588e01b
Update copyright
Web-eWorks Sep 20, 2024
6c52d24
Use shared ShipTemplates definition file
Web-eWorks Sep 20, 2024
4f13325
ShipBuilder: remove MakeGenericPirateNear()
Web-eWorks Sep 20, 2024
d862b38
ShipBuilder: add minimum hyperclass filter to hull selection
Web-eWorks Sep 21, 2024
7a02240
Combat: convert to ShipBuilder APIs
Web-eWorks Sep 21, 2024
cd66782
DeliverPackage: convert to ShipBuilder APIs
Web-eWorks Sep 21, 2024
a95d794
PolicePatrol: convert to ShipBuilder APIs
Web-eWorks Sep 21, 2024
bb09c28
Rondel: convert to ShipBuilder APIs
Web-eWorks Sep 21, 2024
1daa1ea
Scoop: convert to ShipBuilder APIs
Web-eWorks Sep 21, 2024
00dc552
Pirates: migrate to ShipBuilder APIs
Web-eWorks Sep 21, 2024
c31e21b
ShipBuilder: add MakeShipAroundStar
Web-eWorks Sep 21, 2024
c185d89
EquipSet: add equipment class filter to GetInstalledWithFilter()
Web-eWorks Sep 25, 2024
241df22
Improve Lua type information
Web-eWorks Sep 25, 2024
7f02d0b
Support multiple passengers per installed cabin
Web-eWorks Sep 25, 2024
9c87300
Add basic cabin equipment for S1-S5
Web-eWorks Sep 25, 2024
a2bb696
EquipType: remove __call metamethod
Web-eWorks Sep 25, 2024
b0b6012
SearchRescue: convert to use ShipBuilder APIs
Web-eWorks Sep 25, 2024
eca429f
EquipSet: prevent ID collisions for non-slot entries
Web-eWorks Sep 25, 2024
1e397f6
ShipBuilder: add randomChance rule selector
Web-eWorks Sep 25, 2024
1547a65
ShipTemplates: add radar equipment
Web-eWorks Sep 25, 2024
3493726
TradeShips: convert to ShipBuilder APIs
Web-eWorks Sep 25, 2024
a5d9392
Ship: remove freeCapacity, store masses as float
Web-eWorks Sep 26, 2024
a32a601
EquipSet: remove all installed equipment when ship type changes
Web-eWorks Sep 26, 2024
0ff7160
Equipment: military/civilian hyperdrive slots types
Web-eWorks Sep 26, 2024
8b50b6d
ShipMarket: convert to new EquipSet API
Web-eWorks Sep 26, 2024
dea166d
EquipSet: type information for listeners
Web-eWorks Sep 26, 2024
7ad3369
Migrate onShipEquipmentChanged to EquipSet API
Web-eWorks Sep 26, 2024
a551e20
Remove Ship:AddEquip() and onShipEquipmentChanged
Web-eWorks Sep 26, 2024
5eacb33
Cleanup leftovers in Ship
Web-eWorks Sep 26, 2024
f9eaf83
Remove uses of equipSlotCapacity
Web-eWorks Sep 26, 2024
437c2ae
Remove ShipDef.equipSlotCapacity
Web-eWorks Sep 26, 2024
264bc6e
SpaceStation: restore stocking, store equipment by id
Web-eWorks Sep 26, 2024
28fc546
EquipType: restore weapon functionality
Web-eWorks Sep 26, 2024
65f9698
SecondHand: use new Equipment list
Web-eWorks Sep 26, 2024
0f09843
SearchRescue: use new Equipment list
Web-eWorks Sep 26, 2024
854a9fa
TradeShips: remove unused Equipment import
Web-eWorks Sep 26, 2024
a1702a8
Cleanup TODOs and unused variables
Web-eWorks Sep 26, 2024
87da4f5
Equipment: remove old equipment list
Web-eWorks Sep 26, 2024
9fc56bc
Document public methods of EquipSet
Web-eWorks Sep 26, 2024
2f9ceb0
Document EquipType.lua
Web-eWorks Sep 26, 2024
611a59a
Document ShipBuilder.lua
Web-eWorks Sep 27, 2024
a42000e
EquipSet: change HullConfig, rebuild slot cache on ShipType change
Web-eWorks Sep 27, 2024
406fa18
Debug: remove old ship tools, change icons
Web-eWorks Sep 27, 2024
a9bed38
Add DebugShipTool tab
Web-eWorks Sep 27, 2024
89d97ae
EquipSet: reset ship capacity on ShipType change
Web-eWorks Sep 28, 2024
68baf80
Equipment: fix incorrect serializer class names
Web-eWorks Sep 28, 2024
1f2f19d
Restat equipment for new size classes
Web-eWorks Sep 28, 2024
058d406
ui: update for equipment changes
Web-eWorks Sep 28, 2024
e049417
Add equipment slots to all S1 ships
Web-eWorks Sep 29, 2024
edc5e90
Rename misleading predicate argument to transformer
Web-eWorks Nov 1, 2024
c946eb3
Outfitter: prevent replacing non-empty equipment
Web-eWorks Nov 1, 2024
67e30ff
Fix EquipSet:GetFreeSlotForEquip allowing occupied slots
Web-eWorks Nov 3, 2024
79ae557
Import ship JSONs
Web-eWorks Nov 3, 2024
0178192
Update some lang strings for shipdefs
Web-eWorks Nov 3, 2024
57fd8d8
Properly wrap ui.beginTable() in an if block
Web-eWorks Nov 3, 2024
125630d
Fix comment descriptions, bowfin missile bay slot
Web-eWorks Nov 3, 2024
092d4d5
Outfitter: use sort translation strings from ui-core
Web-eWorks Nov 4, 2024
5aae2f3
Rename Passengers.CountCabins -> CountBerths
Web-eWorks Nov 4, 2024
3fa73a0
Rename ShipDef.capacity -> ShipDef.equipCapacity
Web-eWorks Nov 4, 2024
5100afe
Address review feedback, amend documentation
Web-eWorks Nov 4, 2024
9f3a4fb
Add HullConfig.GetHullConfig(id) helper
Web-eWorks Nov 4, 2024
251e69d
Fix crash when uninstalling passenger cabin
Web-eWorks Nov 4, 2024
94241f4
Add fuel scoops to "Hull Mounts" equipment category
Web-eWorks Nov 4, 2024
32dd758
Add descriptions to new translation strings
Web-eWorks Nov 4, 2024
862890d
Fix outfitter not handling slot types with underscores
Web-eWorks Nov 4, 2024
01d6ec4
Add placeholder s1/2/3 fuel scoops, remove multi_scoop
Web-eWorks Nov 4, 2024
d13cbca
Add structure slot, placeholder hull reinforcement equipment
Web-eWorks Nov 4, 2024
1f6f38b
Use correct spacing in equipment stats tooltip
Web-eWorks Nov 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 180 additions & 8 deletions data/lang/equipment-core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,6 @@
"description": "",
"message": "R40 Unguided Rocket"
},
"MULTI_SCOOP": {
"description": "A ship equipment: a cargo scoop and fuel scoop combined into one",
"message": "Multi Scoop"
},
"MULTI_SCOOP_DESCRIPTION": {
"description": "",
"message": "Although less effective than a fuel scoop it permits scooping of both cargo and fuel"
},
"ORBIT_SCANNER": {
"description": "A ship equipment that records data of terrain, for cartography mapping/geological survey. Note: Scout Mission module reference and distinguishes between 'orbital' and 'surface' scanner types, the former scans planet from orbit, the latter from low altitude.",
"message": "Orbital scanner XKM-650"
Expand Down Expand Up @@ -446,5 +438,185 @@
"WEAPONS": {
"description": "Category name of weapon-related equipment",
"message": "Weapons"
},
"THRUSTERS_DEFAULT": {
"description": "Equipment name for default RCS thrusters",
"message": "Default Thrusters"
},
"PROJECTILE_SPEED": {
"description": "Stat label for weapon projectile speeds",
"message": "Projectile Speed"
},
"STAT_VOLUME": {
"description": "Stat label for equipment volume",
"message": "Volume"
},
"STAT_WEIGHT": {
"description": "Stat label for equipment weight",
"message": "Weight"
},
"STAT_POWER_DRAW": {
"description": "Stat label for equipment power draw",
"message": "Power Draw"
},
"COMPUTER_MODULES": {
"description": "Category name of computer-related equipment",
"message": "Computer Modules"
},
"HULL_MOUNTS": {
"description": "Category name for hull-mounted equipment",
"message": "Hull Mounts"
},
"HARDPOINT_FUEL_SCOOP": {
"description": "Name for the 'Fuel Scoop' equipment hardpoint",
"message": "Fuel Scoop"
},
"HARDPOINT_MISSILE": {
"description": "Name for a generic missile mount",
"message": "Missile"
},
"HARDPOINT_PYLON": {
"description": "Name for a generic missile pylon",
"message": "Pylon"
},
"HARDPOINT_MISSILE_BAY": {
"description": "Name for the 'Missile Bay' equipment hardpoint",
"message": "Missile Bay"
},
"HARDPOINT_MISSILE_ARRAY": {
"description": "Name for the 'Missile Array' equipment hardpoint",
"message": "Missile Array"
},
"HARDPOINT_UTILITY": {
"description": "Name for a generic utility hardpoint",
"message": "Utility"
},
"HARDPOINT_WEAPON": {
"description": "Name for a generic weapon hardpoint",
"message": "Weapon"
},
"HARDPOINT_WEAPON_FRONT": {
"description": "Name for a generic front-facing weapon hardpoint",
"message": "Front Weapon"
},
"HARDPOINT_WEAPON_CHIN": {
"description": "Name for the 'Chin Mount' equipment hardpoint",
"message": "Chin Mount"
},
"HARDPOINT_WEAPON_LEFT_NOSE": {
"description": "Name for the 'Left Nose' weapon hardpoint",
"message": "Left Nose"
},
"HARDPOINT_WEAPON_RIGHT_NOSE": {
"description": "Name for the 'Right Nose' weapon hardpoint",
"message": "Right Nose"
},
"HARDPOINT_WEAPON_REAR": {
"description": "Name for a generic rear-facing weapon hardpoint",
"message": "Rear Weapon"
},
"SLOT_SENSOR": {
"description": "Name for a generic (flight/navigation) sensor slot",
"message": "Sensor"
},
"SLOT_CABIN": {
"description": "Name for a generic room slot inside the pressurized living space",
"message": "Cabin"
},
"SLOT_COMPUTER": {
"description": "Name for a generic computer equipment slot",
"message": "Computer"
},
"SLOT_SHIELD": {
"description": "Name for a generic shield slot",
"message": "Shield"
},
"SLOT_SHIELD_LEFT": {
"description": "Name for a left-side shield slot",
"message": "Shield L"
},
"SLOT_SHIELD_RIGHT": {
"description": "Name for a right-side shield equipment slot",
"message": "Shield R"
},
"SLOT_HULL": {
"description": "Name for an equipment slot that augments or modifies the ship hull",
"message": "Hull"
},
"SLOT_HYPERDRIVE": {
"description": "Name for a ship's singular hyperdrive equipment slot",
"message": "Hyperdrive"
},
"SLOT_ENGINE": {
"description": "Name for the ship's primary travel engines",
"message": "Engines"
},
"SLOT_THRUSTER": {
"description": "Generic name for secondary attitude or maneuvering thrusters",
"message": "Thrusters"
},
"SLOT_CABIN_FORE": {
"description": "Name for a cabin slot towards the front of the ship",
"message": "Fore Cabin"
},
"SLOT_CABIN_REAR": {
"description": "Name for a cabin slot towards the rear of the ship",
"message": "Rear Cabin"
},
"SLOT_STRUCTURE": {
"description": "Name for the ship's internal structure modification slot",
"message": "Structure"
},
"MISC_EQUIPMENT": {
"description": "Category header for miscellaneous equipment",
"message": "Miscellaneous"
},
"OPLI_INTERNAL_MISSILE_RACK_S2": {
"description": "Equipment name for an OPLI internal missile rack",
"message": "OPLI Internal Missile Rack"
},
"OKB_KALURI_BOWFIN_MISSILE_RACK": {
"description": "Equipment name for an OKB-Kaluri Bowfin internal missile launcher",
"message": "Bowfin Missile Launcher"
},
"CABINS": {
"description": "Category header for pressurized cabin slots",
"message": "Cabins"
},
"PASSENGER_BERTHS": {
"description": "Label for the total number of passenger berths in a cabin equipment item",
"message": "Passenger Berths"
},
"OCCUPIED_BERTHS": {
"description": "Label for the number of passenger berths currently occupied in a cabin equipment item",
"message": "Occupied Berths"
},
"MISSILE_RAIL_S1": {
"description": "Name for a single-missile external launcher. 'Cnida' is a brand name.",
"message": "Cnida-101 Missile Rail"
},
"MISSILE_RAIL_S2": {
"description": "Name for a single-missile external launcher. 'Cnida' is a brand name.",
"message": "Cnida-102 Missile Rail"
},
"MISSILE_RAIL_S3": {
"description": "Name for a single-missile external launcher. 'Cnida' is a brand name.",
"message": "Cnida-103 Missile Rail"
},
"MISSILE_RACK_341": {
"description": "Name for a multiple-missile external missile rack. 'Hydri' is a brand name.",
"message": "LH-140 Hydri Missile Rack"
},
"MISSILE_RACK_322": {
"description": "Name for a multiple-missile external missile rack. 'Hydri' is a brand name.",
"message": "LH-230 Hydri Missile Rack"
},
"MISSILE_RACK_221": {
"description": "Name for a multiple-missile external missile rack. 'Hydri' is a brand name.",
"message": "LH-120 Hydri Missile Rack"
},
"REINFORCED_STRUCTURE": {
"description": "Name for an equipment item that reinforces the hull's superstructure",
"message": "Reinforced Structure"
}
}
40 changes: 38 additions & 2 deletions data/lang/ui-core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2011,9 +2011,9 @@
"description": "",
"message": "Repair {damage}% hull damage for {price}"
},
"REPLACE_EQUIPMENT_WITH": {
"REPLACE_EQUIPMENT": {
"description": "Market header when replacing equipped items",
"message": "Replace Equipment With"
"message": "Replace Equipment"
},
"REPUTATION": {
"description": "",
Expand Down Expand Up @@ -2618,5 +2618,41 @@
"ZOOM": {
"description": "Label for a zoom (magnification) control bar.",
"message": "Zoom"
},
"SELECTED": {
"description": "Label indicating the following item is selected",
"message": "Selected"
},
"INSTALLED": {
"description": "Label indicating something is installed",
"message": "Installed"
},
"SELL_EQUIP": {
"description": "Button text to sell installed equipment. May be used in a singular or plural context.",
"message": "Sell {name}"
},
"BUY_EQUIP": {
"description": "Button text to buy selected equipment. May be used in a singular or plural context.",
"message": "Buy {name}"
},
"EXPAND": {
"description": "Open / expand a collapsed folder or group",
"message": "Expand"
},
"COLLAPSE": {
"description": "Close / collapse an open folder or group",
"message": "Collapse"
},
"CANNOT_SELL_NONEMPTY_EQUIP": {
"description": "",
"message": "Cannot sell an equipment item unless it is empty."
},
"VOLUME": {
"description": "The volume property of some object",
"message": "Volume"
},
"EQUIPMENT_CAPACITY": {
"description": "The equipment capacity of a ship",
"message": "Equipment Capacity"
}
}
19 changes: 6 additions & 13 deletions data/libs/CargoManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function CargoManager:Constructor(ship)
if not self.ship:hasprop("totalCargo") then
ship:setprop("totalCargo", self:GetTotalSpace())
end

if not self.ship:hasprop("usedCargo") then
ship:setprop("usedCargo", 0)
end
Expand Down Expand Up @@ -63,14 +63,7 @@ end
--
-- Returns the available amount of cargo space currently present on the vessel.
function CargoManager:GetFreeSpace()
local ship = self.ship

-- use mass_cap directly here instead of freeCapacity because this can be
-- called before ship:UpdateEquipStats() has been called
local avail_mass = ShipDef[ship.shipId].capacity - (ship.mass_cap or 0)
local cargo_space = ShipDef[ship.shipId].equipSlotCapacity.cargo or 0

return math.min(avail_mass, cargo_space - self.usedCargoSpace)
return self:GetTotalSpace() - self.usedCargoSpace
end

-- Method: GetUsedSpace
Expand All @@ -84,7 +77,7 @@ end
--
-- Returns the maximum amount of cargo that could be stored on the vessel.
function CargoManager:GetTotalSpace()
return self:GetFreeSpace() + self.usedCargoSpace
return ShipDef[self.ship.shipId].cargo
end

-- Method: AddCommodity
Expand All @@ -103,9 +96,9 @@ end
---@param type CommodityType
---@param count integer
function CargoManager:AddCommodity(type, count)
-- TODO: use a cargo volume metric with variable mass instead of fixed 1m^3 == 1t
-- TODO: use a cargo volume metric with variable mass instead of fixed 1t == 1m^3
local required_space = (type.mass or 1) * (count or 1)

if self:GetFreeSpace() < required_space then
return false
end
Expand Down Expand Up @@ -251,7 +244,7 @@ end
function CargoManager:Unserialize()
setmetatable(self, CargoManager.meta)
self.listeners = {}

return self
end

Expand Down
1 change: 1 addition & 0 deletions data/libs/Character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ local Serializer = require 'Serializer'
local utils = require 'utils'

local Character;
---@class Character
Character = {

--
Expand Down
5 changes: 5 additions & 0 deletions data/libs/Economy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ table.sort(Economies, function(a, b) return a.id < b.id end)
-- Percentage modifier applied to buying/selling commodities
-- Prevents buying a commodity at a station and immediately reselling it
Economy.TradeFeeSplit = 2

-- Total trade fee percentage applied to a buy->sell transaction
Economy.TotalTradeFees = 2 * Economy.TradeFeeSplit

-- Scalar multiplier applied when reselling "used" equipment items back onto the market
Economy.BaseResellPriceModifier = 0.8

-- stationMarket is a persistent table of stock information for every station
-- the player has visited in their journey
local stationMarket = {}
Expand Down
Loading