-
Notifications
You must be signed in to change notification settings - Fork 31
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
Merge all *State
structs and GameState
trait into one universal State
struct
#255
Comments
Working in WIP_255_state branch |
Almost finished - it works the same as before but with unified The thing I want to fix now is that I can't merge First comes the I think that the least bad solution is to redo handling of But I'm not sure what exactly i need to do for this. Right now the filtering system assumes that |
That was really silly: I had some problems with fn is_unit_visible(&self, unit: &Unit) -> bool {
let fow = match self.fow {
Some(ref fow) => fow,
None => return true,
};
fow.is_visible(unit) || self.shown_unit_ids.contains(&unit.id) // <-
} Plus, there was a problem with let world_pos = scene.node(node_id).pos;
let map_pos = geom::world_pos_to_map_pos(world_pos);
map_text.add_text(map_pos, "lost"); Added some basic maps for testing purposes: 0c268fbcc |
Required for #253 and must greatly simplify codebase.
Right now I have
InternalState
,FullState
,PartialState
,TmpPartialState
structs andGameState
trait which is implemented for all of them. This greatly complicates #253 (see comments) because you need generalized code in some places and concrete struct in other places + it introduses a few lifetime-related problems withTmpPartialState
.So I want to try to merge all this into one universal
State
struct which can fill all these roles and will not have any lifetime parameters.The only way to achieve this that I see is to use "option hack": have an
for: Option<Fow>
fields in the struct and insert/extract (usingOption::take
and movement semantics) it for switching betweenFullState
/PartialState
roles.Demo: https://play.rust-lang.org/?gist=401412510e667a291c151b84b7be6a98
The text was updated successfully, but these errors were encountered: