Fields of Mistria — Vanilla GML Reference FoM v1.0.8

obj_dungeon_elevator.gml

object_create(
    "obj_dungeon_elevator",
    object_reserve("par_interactable"),
    {
        sprite_index: undefined,
        create: function() {
            event_inherit(ObjectEvent.Create);

            self.xstart = self.x;
            self.ystart = self.y;

            function dungeon_init() {
                depth = get_instance_depth(y);
                self.x += 8;

                //
                var x1 = (self.xstart div 8) - 1;
                var y1 = (self.ystart div 8) - 2;
                var x2 = x1 + 3;
                var y2 = y1 + 3;
                set_collision_on_node_region(GRID, x1, y1, x2, y2, true);

                var biome = DUNGEON_RUNNER == undefined ? 0 : DUNGEON_BIOME;
                self.floor_renderer = self.create_renderable(
                    string_to_asset(format("spr_dungeon_mines_elevator_ground_biome_{}_off", biome + 1))
                );
                self.floor_renderer.depth = get_floor_depth() - 1;

                self.base = self.create_renderable(spr_pulleyelevator_base);
                self.base.speed = 0;

                self.main = self.create_renderable(spr_pulleyelevator);
                self.main.y = self.y - 8;
                self.main.speed = 0;
                self.main.animation_frame = 1;

                self.main_top = self.create_renderable(spr_pulleyelevator);
                self.main_top.y = self.y - 8;
                self.main_top.speed = 0;
                self.main_top.animation_frame = 0;
            }

            mask_index = spr_pulleyelevator;
            self.register_interaction(
                InputId.Interact,
                "misc_local/use",
                function() {
                    ANCHOR.spawn_menu(Menu.Elevator);
                },
                function() {
                    //
                    return ARI.held_animal_id == undefined
                        && SCREEN_FADER.is_in();
                }
            );
            depth = get_instance_depth(y);
        },
        step_end: function() {
            if highlighter.update() && MIST.running == false {
                self.base.draw_kind = DrawKind.Overlay;
                self.base.tint = self.highlighter.color;
                self.base.alpha = self.highlighter.strength;

                self.main.draw_kind = DrawKind.Overlay;
                self.main.tint = self.highlighter.color;
                self.main.alpha = self.highlighter.strength;

                self.main_top.draw_kind = DrawKind.Overlay;
                self.main_top.tint = self.highlighter.color;
                self.main_top.alpha = self.highlighter.strength;
            } else {
                self.base.draw_kind = DrawKind.Normal;
                self.base.tint = c_white;
                self.base.alpha = 1.0;

                self.main.draw_kind = DrawKind.Normal;
                self.main.tint = c_white;
                self.main.alpha = 1.0;

                self.main_top.draw_kind = DrawKind.Normal;
                self.main_top.tint = c_white;
                self.main_top.alpha = 1.0;
            }
        }
    }
);