Skip to content

EntityExtraData of incorrect type when ambiguous #254

@redruin1

Description

@redruin1

Suppose we have a blueprint with a single lamp with a circuit condition:

0eNptUMtqwzAQ/Jc9yyFOolDpUMh3lGJke9su6GGktakx+vdKDsSXHmeY1+4GvZ1xiuQZ9AY0BJ9Af2yQ6NsbWzlvHIKG5Iy1jTVugiyA/Ii/oNv8KQA9ExM+fTtYOz+7HmMRiH/8AqaQiiX4ml9j7teTFLCCblp5OclSUIZwDLbr8ccsFGJVDhSHmbhDb3qLI2iOM4oXXSzjK/WLYuLuuILXqa5YKPJcmGPWrmge8OxMbOonzhW4yUTDtRreIed6KjG6Ao+fCVgwpr1T3i/qppR8a69KnW85/wEk0HVl
Image

I would expect the following:

for entity in blueprint.entities {
    match entity.name.as_str() {
        "small-lamp" => {
            if let Some(data) = &entity.extra_data {
                println!("{:?}", data)
            }
        },
        _ => ()
    }
}

to produce a struct of type EntityExtraData::Lamp, but it actually produces:

AgriculturalTower { control_behavior: AgriculturalTowerControlBehavior { read_contents: false, common: CommonControlBehavior { circuit_enabled: true, circuit_condition: Some(Constant { comparator: Greater, first_signal: Some(Virtual { name: Some(VirtualSignalID("signal-check")), quality: None }), constant: 0 }), connect_to_logistic_network: false, logistic_condition: None } } }

I think it's picking the first valid one that it could be, which happens to be the first agri tower struct. If I'm doing this wrong, lemme know.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions