Exemplo n.º 1
0
        protected override void OnExecuteEvent(VEntity entity)
        {
            DeathEventComponent ecDeath     = VEntityComponentSystemManager.GetVComponent <DeathEventComponent>(entity);
            VEntity             dyingEntity = ecsManager.GetVEntityById(ecDeath.id);

            if (dyingEntity != null)
            {
                HealthComponent h = dyingEntity.GetVComponent <HealthComponent>();
                if (h != null && h.currHealth > 0)
                {
                    return;
                }

                ecsManager.MarkRemovalEntity(dyingEntity);

                // remove the entity from all relevant things
                UnitsList unitsList = ecsManager.GetVSingletonComponent <UnitsList>();
                unitsList.unitIds.Remove(dyingEntity.id);
                PositionTrackSystem positionTrackSystem = ecsManager.GetSystem <PositionTrackSystem>();
                positionTrackSystem.Untrack(dyingEntity.id);

                ecsManager.QueueAnimationEvent("DeathAnimation", component: new DeathAnimationEvent {
                    deathTransform = dyingEntity.GetVComponent <PositionDisplayComponent>().mainTransform,
                    dyingEntityId  = dyingEntity.id
                });
            }
        }
Exemplo n.º 2
0
        protected override void OnExecuteEvent(VEntity entity)
        {
            MovementEvent       moveEvent           = VEntityComponentSystemManager.GetVComponent <MovementEvent>(entity);
            PositionTrackSystem positionTrackSystem = ecsManager.GetSystem <PositionTrackSystem>();

            // check to make sure that the square is unoccupied
            bool isUnoccupied = true;

            foreach (VEntity v in positionTrackSystem.GetAtCoord(moveEvent.targetCoord))
            {
                if (VEntityComponentSystemManager.HasVComponent <MovementBlockComponent>(v))
                {
                    isUnoccupied = false;
                }
            }

            if (isUnoccupied)
            {
                PositionComponent movedPosition = ecsManager.GetVComponent <PositionComponent>(moveEvent.sourceId);
                Coord             prevPosition  = movedPosition.position;
                movedPosition.position = moveEvent.targetCoord;
                positionTrackSystem.Update(movedPosition.position, moveEvent.sourceId);

                ecsManager.QueueAnimationEvent(ecsManager.CreateEntity("MoveAnim", component: new MovementAnimationEvent {
                    entityToMove = moveEvent.sourceId,
                    from         = prevPosition,
                    to           = moveEvent.targetCoord
                }));
            }
        }
Exemplo n.º 3
0
        public VEntity GetCellAtCoord(Coord c)
        {
            PositionTrackSystem   positionTracker = ecsManager.GetSystem <PositionTrackSystem>();
            IEnumerable <VEntity> entitiesAtCoord = positionTracker.GetAtCoord(c);

            foreach (VEntity v in entitiesAtCoord)
            {
                if (v.HasVComponent <TerrainCellComponent>())
                {
                    return(v);
                }
            }

            return(null);
        }