public EntityFacade(
            IMonoEntity entity,
            IActorStateModel actor,
            IPauseStateModel pauseStateModel)
        {
            Entity                     = entity;
            Actor                      = actor;
            _pauseStateModel           = pauseStateModel;
            _entityLifecycleDisposable = new SerialDisposable().AddTo(Disposer);

            Entity.Setup(Actor);

            Actor.Get <TransformDataComponent>()
            .SetMonoEntity(Entity);

            HealthDataComponent = Actor.Get <HealthDataComponent>();

            HealthDataComponent.IsAlive
            .DelayFrame(1)
            .Subscribe(OnIsAliveChanged)
            .AddTo(Disposer);

            Observable.EveryUpdate()
            .Where(_ => CanTick)
            .Subscribe(_ => OnTick())
            .AddTo(Disposer);
        }
 public FollowAvatarNode(IActorStateModel actorStateModel)
 {
     _actorStateModel        = actorStateModel;
     _blackBoard             = _actorStateModel.Get <BlackBoardDataComponent>();
     _sensorDataComponent    = _actorStateModel.Get <SensorDataComponent>();
     _transformDataComponent = _actorStateModel.Get <TransformDataComponent>();
     _timeoutDataComponent   = _actorStateModel.Get <TimeoutDataComponent>();
 }
        public FirstTouchNode(
            IActorStateModel actorStateModel,
            BehaviourTreeConfig behaviourTreeConfig)
        {
            _behaviourTreeConfig = behaviourTreeConfig;

            _sensorDataComponent       = actorStateModel.Get <SensorDataComponent>();
            _relationshipDataComponent = actorStateModel.Get <RelationshipDataComponent>();
        }
        public EnterScreenNode(
            IActorStateModel actorStateModel,
            AiMovementController aiMovementController,
            ScreenSizeModel screenSizeModel)
        {
            _aiMovementController = aiMovementController;
            _screenSizeModel      = screenSizeModel;

            _originDataComponent    = actorStateModel.Get <OriginDataComponent>();
            _transformDataComponent = actorStateModel.Get <TransformDataComponent>();
        }
Beispiel #5
0
 public WanderNode(
     IActorStateModel actorStateModel,
     IRandomNumberService randomNumberService,
     ScreenSizeModel screenSizeModel)
 {
     _randomNumberService    = randomNumberService;
     _screenSizeModel        = screenSizeModel;
     _blackBoard             = actorStateModel.Get <BlackBoardDataComponent>();
     _originDataComponent    = actorStateModel.Get <OriginDataComponent>();
     _wanderDataComponent    = actorStateModel.Get <WanderDataComponent>();
     _transformDataComponent = actorStateModel.Get <TransformDataComponent>();
 }
        private float GetDistanceSquared(IActorStateModel actorA, IActorStateModel actorB)
        {
            var distance = actorA.Get <TransformDataComponent>().Position -
                           actorB.Get <TransformDataComponent>().Position;

            return(distance.sqrMagnitude);
        }
 public SwitchEntityStateNode(
     IActorStateModel actorStateModel,
     EntityState targetState)
 {
     _relationshipDataComponent = actorStateModel.Get <RelationshipDataComponent>();
     _targetState = targetState;
 }
Beispiel #8
0
 public MoveNode(
     IActorStateModel actorStateModel,
     AiMovementController aiMovementController)
 {
     _aiMovementController = aiMovementController;
     _blackBoard           = actorStateModel.Get <BlackBoardDataComponent>();
 }
Beispiel #9
0
 private void TryAddAsAvatar(IActorStateModel actor)
 {
     if (actor.Get <EntityTypeDataComponent>().EntityType == EntityType.Avatar)
     {
         Avatar = actor;
     }
 }
Beispiel #10
0
 private void TryRemoveAsAvatar(IActorStateModel actor)
 {
     if (actor.Get <EntityTypeDataComponent>().EntityType == EntityType.Avatar)
     {
         Avatar = null;
     }
 }
Beispiel #11
0
 public ResetTimeoutNode(
     IActorStateModel actorStateModel,
     TimeoutDataComponent.Storage storage)
 {
     _storage = storage;
     _timeoutDataComponent = actorStateModel.Get <TimeoutDataComponent>();
 }
Beispiel #12
0
 public IdleTimeoutNode(
     IActorStateModel actor,
     double timeoutSeconds,
     TimeoutDataComponent.Storage storage)
 {
     _timeoutDataComponent = actor.Get <TimeoutDataComponent>();
     _timeoutSeconds       = timeoutSeconds;
     _storage = storage;
 }
Beispiel #13
0
        public EntityStateNotificationSystem(IActorStateModel actor)
            : base(actor)
        {
            _relationshipDataComponent = actor.Get <RelationshipDataComponent>();

            _components = actor.GetAll <IEntityStateSensitiveDataComponent>();

            _relationshipDataComponent.Relationship
            .Subscribe(OnRelationShipChanged)
            .AddTo(Disposer);
        }
Beispiel #14
0
 public IdleTimeoutRandomNode(
     IActorStateModel actor,
     double timeoutSeconds,
     TimeoutDataComponent.Storage storage,
     double randomChance)
 {
     _timeoutDataComponent = actor.Get <TimeoutDataComponent>();
     _timeoutSeconds       = timeoutSeconds;
     _storage      = storage;
     _randomChance = randomChance;
 }
        public void Add(IActorStateModel actor, SensorType sensor)
        {
            _storages[sensor].Add(actor);

            if (!_lifetimeSubscriptions.ContainsKey(actor))
            {
                var sub = actor.Get <HealthDataComponent>().IsAlive
                          .IfFalse()
                          .Subscribe(_ => Remove(actor, sensor))
                          .AddTo(Disposer);

                _lifetimeSubscriptions.Add(actor, sub);
            }
        }
 public FindDamageReceiversNode(IActorStateModel actorStateModel)
 {
     _blackBoard          = actorStateModel.Get <BlackBoardDataComponent>();
     _sensorDataComponent = actorStateModel.Get <SensorDataComponent>();
 }
 public LightSwitchNode(IActorStateModel actorStateModel)
 {
     _lightDataComponent = actorStateModel.Get <LightDataComponent>();
 }
 public AbstractMovementController(IActorStateModel actorStateModel)
 {
     MovementDataComponent  = actorStateModel.Get <MovementDataComponent>();
     TransformDataComponent = actorStateModel.Get <TransformDataComponent>();
 }
        private bool IsEntityState(IActorStateModel model, EntityState status)
        {
            var relationshipDataComponent = model.Get <RelationshipDataComponent>();

            return(relationshipDataComponent.Relationship.Value == status);
        }
 public DamageActorNode(IActorStateModel actorStateModel)
 {
     _blackBoardDataComponent = actorStateModel.Get <BlackBoardDataComponent>();
     _damageDataComponent     = actorStateModel.Get <DamageDataComponent>();
 }
        private void StoreDamageReceiver(IActorStateModel actor)
        {
            var receiver = actor.Get <HealthDataComponent>();

            _blackBoard.DamageReceiver.Store(receiver);
        }
Beispiel #22
0
 public DeactivateSelfNode(IActorStateModel actorStateModel)
 {
     _healthDataComponent = actorStateModel.Get <HealthDataComponent>();
 }
 private bool IsFriend(IActorStateModel actor)
 {
     return(actor.Get <RelationshipDataComponent>()?.Relationship.Value == EntityState.Friend);
 }
 public NearDeathNode(IActorStateModel actorStateModel)
 {
     _healthDataComponent = actorStateModel.Get <HealthDataComponent>();
 }