-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basically copy marvins priority system, because its simple and it works.
- Loading branch information
1 parent
4575057
commit 57f8e87
Showing
10 changed files
with
143 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,35 @@ | ||
use log::info; | ||
use screeps::{find, HasId, ResourceType, Room}; | ||
|
||
use super::cache::tick_cache::{hauling::HaulingType, RoomCache}; | ||
use crate::utils::scale_haul_priority; | ||
|
||
use super::cache::tick_cache::{hauling::{HaulingPriority, HaulingType}, RoomCache}; | ||
|
||
pub fn run_towers(room: &Room, cache: &mut RoomCache) { | ||
for tower in cache.structures.towers.values() { | ||
// Use cache here | ||
let enemies = room.find(find::HOSTILE_CREEPS, None); | ||
if enemies.is_empty() { | ||
return; | ||
} | ||
if (tower.store().get_used_capacity(Some(ResourceType::Energy)) as f32) | ||
< (tower.store().get_capacity(Some(ResourceType::Energy)) as f32 * 0.5) | ||
{ | ||
if tower.store().get_free_capacity(Some(ResourceType::Energy)) > 0 { | ||
let priority = scale_haul_priority( | ||
tower.store().get_capacity(None), | ||
tower.store().get_free_capacity(None) as u32, | ||
HaulingPriority::Combat, | ||
true, | ||
); | ||
|
||
info!("Tower {} is hauling energy", priority); | ||
|
||
cache.hauling.create_order( | ||
tower.raw_id(), | ||
Some(ResourceType::Energy), | ||
Some(tower.store().get_free_capacity(Some(ResourceType::Energy)) as u32), | ||
super::cache::tick_cache::hauling::HaulingPriority::Combat, | ||
priority, | ||
HaulingType::Transfer, | ||
); | ||
} | ||
// Use cache here | ||
let enemies = &cache.creeps.enemy_creeps; | ||
if enemies.is_empty() { | ||
return; | ||
} | ||
let _ = tower.attack(enemies.first().unwrap()); | ||
} | ||
} |
Oops, something went wrong.