Skip to content

Commit

Permalink
Change: proof-of-concept object tiles from industry layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
andythenorth committed Sep 9, 2022
1 parent 38068b1 commit 1aa1831
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/industries/assembly_plant.py
Expand Up @@ -84,6 +84,7 @@
ground_overlay=spriteset_ground_overlay,
building_sprites=[spriteset_1],
fences=["nw", "ne", "se", "sw"],
as_object=True,
)
industry.add_spritelayout(
id="assembly_plant_spritelayout_central_assembly_hall",
Expand Down
4 changes: 3 additions & 1 deletion src/industry.py
Expand Up @@ -462,6 +462,7 @@ def __init__(
perma_fences=[],
magic_trees=[],
terrain_aware_ground=False,
as_object=False,
):
self.id = id
self.ground_sprite = ground_sprite
Expand All @@ -474,7 +475,8 @@ def __init__(
self.perma_fences=perma_fences
self.magic_trees = magic_trees
self.terrain_aware_ground = terrain_aware_ground # we don't draw terrain (and climate) aware ground unless explicitly required by the spritelayout, it makes nml compiles slower

# test objects
self.as_object = as_object

class MagicSpritelayoutSlopeAwareTrees(object):
"""Occasionally we need magic. If we're going magic, let's go full on magic. This one makes 4 climate-aware trees on a slope-aware ground tile"""
Expand Down
10 changes: 10 additions & 0 deletions src/lang/english.lng
Expand Up @@ -579,3 +579,13 @@ STR_COLOUR_RED
STR_COLOUR_YELLOW :{YELLOW}
STR_COLOUR_WHITE :{WHITE}


STR_OBJ_TEST :FIRS TEST
STR_OBJ_CLASSNAME_FIRS :FIRS


STR_VERSION_22723 :1.2.0 (r22723)

STR_NAME_OBJCLASS_INFRASTRUCTURE :Infrastructure

STR_NAME_COMPANY_LAND :Company land
29 changes: 29 additions & 0 deletions src/templates/spritelayouts.pynml
Expand Up @@ -243,4 +243,33 @@
</tal:optional_fence>

}

<tal:as_object condition="spritelayout.as_object">
item(FEAT_OBJECTS, ${spritelayout.id}_object) {
property {
/* The class allows to sort objects into categories. This is 'infrastructure' */
class: "INFR";
/* If no other NewGRF provides this class before us, we have to name it */
classname: string(STR_OBJ_CLASSNAME_FIRS);
/* Name of this particular object */
name: string(STR_OBJ_TEST);
climates_available: ALL_CLIMATES;
size: [1, 1];
build_cost_multiplier: 1;
remove_cost_multiplier: 1;
introduction_date: date(1,1,1); // available from day 1
end_of_life_date: date(10000,1,1); // available till year 10000
/* Anything can overbuild the object, removing returns the money, we don't want foundations and we want to allow bridges */
object_flags: bitmask(OBJ_FLAG_ANYTHING_REMOVE, OBJ_FLAG_REMOVE_IS_INCOME, OBJ_FLAG_NO_FOUNDATIONS, OBJ_FLAG_ALLOW_BRIDGE);
height: 128; // it's only a ground tile
num_views: 1;
}
graphics {
purchase: ${spritelayout.id};
tile_check: return 0;
additional_text: return string(STR_OBJ_TEST);
${spritelayout.id};
}
}
</tal:as_object>
</tal:spritelayouts>

0 comments on commit 1aa1831

Please sign in to comment.