Skip to content

Commit

Permalink
Add StructureObject::as_repairable
Browse files Browse the repository at this point in the history
  • Loading branch information
shanemadden committed Jan 8, 2024
1 parent 7a27f15 commit 4bf3118
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Unreleased
==========

### Additions:

- Add `StructureObject::as_repairable` matching related functions for other object traits

0.20.0 (2024-01-08)
===================

Expand Down
26 changes: 26 additions & 0 deletions src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,32 @@ impl StructureObject {
}
}

pub fn as_repairable(&self) -> Option<&dyn Repairable> {
match self {
Self::StructureSpawn(s) => Some(s),
Self::StructureExtension(s) => Some(s),
Self::StructureRoad(s) => Some(s),
Self::StructureWall(s) => Some(s),
Self::StructureRampart(s) => Some(s),
Self::StructureKeeperLair(_) => None,
Self::StructurePortal(_) => None,
Self::StructureController(_) => None,
Self::StructureLink(s) => Some(s),
Self::StructureStorage(s) => Some(s),
Self::StructureTower(s) => Some(s),
Self::StructureObserver(s) => Some(s),
Self::StructurePowerBank(s) => Some(s),
Self::StructurePowerSpawn(s) => Some(s),
Self::StructureExtractor(s) => Some(s),
Self::StructureLab(s) => Some(s),
Self::StructureTerminal(s) => Some(s),
Self::StructureContainer(s) => Some(s),
Self::StructureNuker(s) => Some(s),
Self::StructureFactory(s) => Some(s),
Self::StructureInvaderCore(_) => None,
}
}

pub fn as_dismantleable(&self) -> Option<&dyn Dismantleable> {
match self {
Self::StructureSpawn(s) => Some(s),
Expand Down

0 comments on commit 4bf3118

Please sign in to comment.