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

Refactor site properties #198

Open
narc0tiq opened this issue Jan 1, 2025 · 0 comments
Open

Refactor site properties #198

narc0tiq opened this issue Jan 1, 2025 · 0 comments

Comments

@narc0tiq
Copy link
Owner

narc0tiq commented Jan 1, 2025

If you take a look at

YARM/resmon/types.lua

Lines 49 to 101 in 484eaa6

---@class yarm_site
local site = {
is_summary = false, -- true for summary sites generated by resmon.sites.generate_summaries
site_count = 0, -- nonzero only for summaries (see above), where it contains the number of sites being summarized
index = 0,
name_tag = "", -- Player-set name tag added to the site display name
added_at = game.tick,
surface = entity.surface, ---@type LuaSurface
force = player.force or game.forces.player,
center = { x = 0, y = 0 },
first_center = { x = 0, y = 0 },
ore_type = entity.name, ---@type string Resource entity prototype name
ore_name = entity.prototype.localised_name,
tracker_indices = {},
entity_count = 0,
initial_amount = 0,
amount = 0,
amount_left = 0, -- like amount, but for infinite resources it excludes that minimum that the resource will always contain
update_amount = 0, -- intermediate value while updating a site amount
extents = {
left = entity.position.x,
right = entity.position.x,
top = entity.position.y,
bottom = entity.position.y,
},
next_to_scan = {},
is_overlay_being_created = false,
entities_to_be_overlaid = {},
entities_to_be_overlaid_count = 0,
next_to_overlay = {},
next_to_overlay_count = 0,
etd_minutes = -1,
scanned_etd_minutes = -1,
lifetime_etd_minutes = -1,
ore_per_minute = 0, ---@type integer The current ore depletion rate, as of the last time the site was updated
scanned_ore_per_minute = 0,
lifetime_ore_per_minute = 0,
etd_is_lifetime = true,
last_ore_check = nil, -- tick when the site last finished counting its deposits
last_modified_amount = nil, -- last amount when the site was modified
last_modified_tick = nil, -- last tick when the site changed amount (may be older than last_ore_check if the site has not been mining)
etd_minutes_delta = 0,
ore_per_minute_delta = 0, ---@type integer The change in ore-per-minute since the last time we updated the site
finalizing = false, -- true after finishing on-tick scans while waiting for player confirmation/cancellation
finalizing_since = nil, -- tick number when finalizing turned true
is_site_expanding = false, -- true when expanding an existing site
has_expanded = false,
original_amount = 0,
remaining_permille = 1000,
deleting_since = nil, -- tick number when player presses "delete" for the first time; if not pressed for the second time within 120 ticks, deletion is cancelled
chart_tag = nil, ---@type LuaCustomChartTag? the associated chart tag (aka map marker) with the site name and amount
iter_key = nil, -- used when iterating the site contents to remember how far we've gotten
}
, there are 50 properties that a site has on creation, some of which are very closely related. There must be a better way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant