コード例 #1
0
        private void Query(CombinedAimTracer tracer,
                           ref PostureAnimation.Component anim,
                           ref BaseUnitStatus.Component status)
        {
            if (status.State != UnitState.Alive)
            {
                return;
            }

            Vector3?pos = null;

            switch (anim.AnimTarget.Type)
            {
            case AnimTargetType.None:
                break;

            case AnimTargetType.Position:
                pos = anim.AnimTarget.Position.ToWorkerPosition(this.Origin);
                break;
            }

            tracer.SetAimTarget(pos);
            tracer.Rotate(deltaTime);
        }
コード例 #2
0
        private void Query(Entity entity,
                           ref UnitActionData action,
                           ref GunComponent.Component gun,
                           ref PostureAnimation.Component anim,
                           ref BaseUnitTarget.Component target,
                           ref BaseUnitStatus.Component status,
                           ref SpatialEntityId entityId)
        {
            if (status.State != UnitState.Alive)
            {
                return;
            }

            if (UnitUtils.IsOffensive(status.Type) == false)
            {
                return;
            }

            if (target.State != TargetState.ActionTarget)
            {
                return;
            }

            var current = Time.ElapsedTime;

            var id = entityId.EntityId.Id;

            if (this.EnemyPositionsContainer == null ||
                this.EnemyPositionsContainer.TryGetValue(id, out var enemyPositions) == false)
            {
                return;
            }

            Vector3?epos = null;

            if (enemyPositions.Count > 0)
            {
                epos = enemyPositions[0].ToWorkerPosition(this.Origin);

                var container = EntityManager.GetComponentObject <PostureBoneContainer>(entity);
                Attack(container, current, epos.Value, entityId, ref gun);
            }

            var  type   = AnimTargetType.None;
            bool isDiff = false;

            if (epos != null)
            {
                isDiff = anim.AnimTarget.Position.ToWorkerPosition(this.Origin) != epos.Value;
                type   = AnimTargetType.Position;
            }

            if (anim.AnimTarget.Type != type || isDiff)
            {
                var animTarget = anim.AnimTarget;
                animTarget.Type = type;

                if (epos != null)
                {
                    animTarget.Position = epos.Value.ToWorldPosition(this.Origin);
                }

                anim.AnimTarget = animTarget;
            }
        }