reactive_graph_behaviour_service_api/
entity_component_behaviour_manager.rs

1use async_trait::async_trait;
2use springtime_di::injectable;
3use uuid::Uuid;
4
5use reactive_graph_behaviour_model_api::BehaviourTransitionError;
6use reactive_graph_behaviour_model_api::BehaviourTypeId;
7use reactive_graph_behaviour_model_api::ComponentBehaviourTypeId;
8use reactive_graph_graph::Component;
9use reactive_graph_lifecycle::Lifecycle;
10use reactive_graph_reactive_model_impl::ReactiveEntity;
11
12#[injectable]
13#[async_trait]
14pub trait EntityComponentBehaviourManager: Send + Sync + Lifecycle {
15    /// Adds new behaviours to the given entity instance.
16    fn add_behaviours_to_entity(&self, entity_instance: ReactiveEntity);
17
18    /// Possibly adds new behaviour to the given entity instance's component
19    fn add_behaviours_to_entity_component(&self, entity_instance: ReactiveEntity, component: Component);
20
21    /// Creates and adds the given behaviour to the given reactive entity instance's component.
22    fn add_behaviour_to_entity_component(&self, entity_instance: ReactiveEntity, component_behaviour_ty: &ComponentBehaviourTypeId);
23
24    /// Removes the given behaviour from the given reactive entity instance.
25    fn remove_behaviour_from_entity(&self, entity_instance: ReactiveEntity, behaviour_ty: &BehaviourTypeId);
26
27    /// Removes behaviours from the given entity instance.
28    fn remove_behaviours_from_entity(&self, entity_instance: ReactiveEntity);
29
30    /// Removes behaviour from the given entity instance's component
31    fn remove_behaviours_from_entity_component(&self, entity_instance: ReactiveEntity, component: Component);
32
33    /// Removes behaviours from the given entity instance by uuid.
34    fn remove_behaviours_by_id(&self, id: &Uuid);
35
36    /// Removes all behaviours of the given behaviour type.
37    fn remove_behaviours_by_behaviour(&self, behaviour_ty: &BehaviourTypeId);
38
39    /// Returns true, if the entity instance has the given behaviour.
40    fn has(&self, entity_instance: ReactiveEntity, behaviour_ty: &BehaviourTypeId) -> bool;
41
42    /// Returns the behaviours of the given entity instance.
43    fn get_all(&self, entity_instance: ReactiveEntity) -> Vec<BehaviourTypeId>;
44
45    /// Returns the entity instances with the given behaviour.
46    fn get_instances_by_behaviour(&self, ty: &BehaviourTypeId) -> Vec<ReactiveEntity>;
47
48    /// Connect
49    fn connect(&self, entity_instance: ReactiveEntity, behaviour_ty: &BehaviourTypeId) -> Result<(), BehaviourTransitionError>;
50
51    /// Disconnect
52    fn disconnect(&self, entity_instance: ReactiveEntity, behaviour_ty: &BehaviourTypeId) -> Result<(), BehaviourTransitionError>;
53
54    /// Reconnect
55    fn reconnect(&self, entity_instance: ReactiveEntity, behaviour_ty: &BehaviourTypeId) -> Result<(), BehaviourTransitionError>;
56}