Use lantern only at night
This commit is contained in:
parent
3ea0475ba7
commit
a8cbd70884
34
src/bot.rs
34
src/bot.rs
@ -11,6 +11,7 @@ use veloren_common::{
|
|||||||
clock::Clock,
|
clock::Clock,
|
||||||
comp::{invite::InviteKind, item::ItemDefinitionIdOwned, ChatType, ControllerInputs, Ori, Pos},
|
comp::{invite::InviteKind, item::ItemDefinitionIdOwned, ChatType, ControllerInputs, Ori, Pos},
|
||||||
outcome::Outcome,
|
outcome::Outcome,
|
||||||
|
time::DayPeriod,
|
||||||
trade::{PendingTrade, TradeAction},
|
trade::{PendingTrade, TradeAction},
|
||||||
uid::Uid,
|
uid::Uid,
|
||||||
ViewDistances,
|
ViewDistances,
|
||||||
@ -113,10 +114,7 @@ impl Bot {
|
|||||||
self.client.respawn();
|
self.client.respawn();
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.client.is_lantern_enabled() {
|
self.handle_lantern();
|
||||||
self.client.enable_lantern();
|
|
||||||
}
|
|
||||||
|
|
||||||
self.handle_position_and_orientation()?;
|
self.handle_position_and_orientation()?;
|
||||||
|
|
||||||
if let Some((_, trade, _)) = self.client.pending_trade() {
|
if let Some((_, trade, _)) = self.client.pending_trade() {
|
||||||
@ -193,6 +191,23 @@ impl Bot {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_lantern(&mut self) {
|
||||||
|
let day_period = self.client.state().get_day_period();
|
||||||
|
|
||||||
|
match day_period {
|
||||||
|
DayPeriod::Night => {
|
||||||
|
if !self.client.is_lantern_enabled() {
|
||||||
|
self.client.enable_lantern();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DayPeriod::Morning | DayPeriod::Noon | DayPeriod::Evening => {
|
||||||
|
if self.client.is_lantern_enabled() {
|
||||||
|
self.client.disable_lantern();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn handle_trade(&mut self, trade: PendingTrade) -> Result<(), String> {
|
fn handle_trade(&mut self, trade: PendingTrade) -> Result<(), String> {
|
||||||
let my_offer_index = trade
|
let my_offer_index = trade
|
||||||
.which_party(self.client.uid().ok_or("Failed to get uid")?)
|
.which_party(self.client.uid().ok_or("Failed to get uid")?)
|
||||||
@ -490,10 +505,13 @@ impl Bot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn handle_position_and_orientation(&mut self) -> Result<(), String> {
|
fn handle_position_and_orientation(&mut self) -> Result<(), String> {
|
||||||
let current_position = self.client.position();
|
match self.client.position() {
|
||||||
|
Some(current_position) => {
|
||||||
if current_position == Some(self.position.into()) {
|
if current_position == self.position.into() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => return Ok(()),
|
||||||
}
|
}
|
||||||
|
|
||||||
let entity = self.client.entity().clone();
|
let entity = self.client.entity().clone();
|
||||||
|
Loading…
Reference in New Issue
Block a user