Пример #1
0
        /// <summary>
        /// Moves the specified entity towards the passed destination.
        /// </summary>
        /// <param name="entityName">Name of the entity to move.</param>
        /// <param name="destination">Destination to move towards.</param>
        public void MoveTowards(string entityName, IVector3 destination)
        {
            IMortarEntity entity = EntityManager.GetEntity(entityName);
            MovementComponent component = entity.GetComponent<MovementComponent>();

            component.Destination = destination;

            if(component.DistanceToDestination > component.DestinationReachedDistance)
            {
                component.IsMovingTowardsEntity = false;
                component.IsMoving = true;

                // ToDo: Set SystemVariable MovingEntity
                //SystemVariables.MovingEntity = name;

                StartedMoving incident = new StartedMoving();
                incident.EntityName = entityName;
                incident.Destination = destination;
                QueueEvent(incident);
            }
        }
Пример #2
0
        /// <summary>
        /// Moves the specified entity towards the passed entity.
        /// </summary>
        /// <param name="entityName">Name of the entity to move.</param>
        /// <param name="targetName">Name of the entity to move towards.</param>
        public void MoveTowardsEntity(string entityName, string targetName)
        {
            IMortarEntity entity = EntityManager.GetEntity(entityName);
            IMortarEntity target = EntityManager.GetEntity(targetName);
            MovementComponent component = entity.GetComponent<MovementComponent>();

            IVector3 destination = target.Transform.Position;
            component.Destination = destination;

            if(component.DistanceToDestination > component.DestinationReachedDistance)
            {
                component.DestinationName = targetName;
                component.IsMovingTowardsEntity = true;
                component.IsMoving = true;

                // ToDo: Set SystemVariable MovingEntity
                //SystemVariables.MovingEntity = name;

                // ToDo: StartedMovingTowardsEntity incident = new StartedMovingTowardsEntity();
                StartedMoving incident = new StartedMoving();
                incident.EntityName = entityName;
                incident.Destination = targetName;
                QueueEvent(incident);
            }
        }