[−][src]Trait weasel::actor::ActorRules
Set of rules that handle how abilities are represented and how they can alter the state of the world when activated.
Associated Types
type Ability: Id + 'static + Serialize + for<'a> Deserialize<'a>
See Ability.
type AbilitiesSeed: Clone + Debug + Serialize + for<'a> Deserialize<'a>
See AbilitiesSeed.
type Activation: Clone + Debug + Serialize + for<'a> Deserialize<'a>
See Activation.
type AbilitiesAlteration: Clone + Debug + Serialize + for<'a> Deserialize<'a>
See AbilitiesAlteration.
Provided methods
fn generate_abilities(
&self,
_seed: &Option<Self::AbilitiesSeed>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
) -> Box<dyn Iterator<Item = Self::Ability>>
&self,
_seed: &Option<Self::AbilitiesSeed>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
) -> Box<dyn Iterator<Item = Self::Ability>>
Generates all abilities of an actor. Abilities should have unique ids, otherwise only the last entry will be persisted.
The provided implementation generates an empty set of abilities.
fn activable(&self, _action: Action<R>) -> bool
Returns true if creature
can activate ability
with the given activation profile.
ability
is guaranteed to be known by the actor.
The provided implementation accepts any activation.
fn activate(
&self,
_state: &BattleState<R>,
_action: Action<R>,
_event_queue: &mut Option<EventQueue<R>>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
&self,
_state: &BattleState<R>,
_action: Action<R>,
_event_queue: &mut Option<EventQueue<R>>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
Activate an ability.
ability
is guaranteed to be known by actor
.
In order to change the state of the world, abilities should insert
event prototypes in event_queue
.
The provided implementation does nothing.
fn alter(
&self,
_actor: &mut dyn Actor<R>,
_alteration: &Self::AbilitiesAlteration,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
&self,
_actor: &mut dyn Actor<R>,
_alteration: &Self::AbilitiesAlteration,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
Alters one or more abilities starting from the given alteration object.
The provided implementation does nothing.
fn on_round_start(
&self,
_actor: &dyn Actor<R>,
_event_queue: &mut Option<EventQueue<R>>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
&self,
_actor: &dyn Actor<R>,
_event_queue: &mut Option<EventQueue<R>>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
Invoked when a new round begins.
The provided implementation does nothing.
fn on_round_end(
&self,
_actor: &dyn Actor<R>,
_event_queue: &mut Option<EventQueue<R>>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
&self,
_actor: &dyn Actor<R>,
_event_queue: &mut Option<EventQueue<R>>,
_entropy: &mut Entropy<R>,
_metrics: &mut WriteMetrics<R>
)
Invoked when the current round ends.
The provided implementation does nothing.