if (cardObject.SpellTarget != null)
            {
                if (cardObject.SpellTarget is Card card)
                {
                    ActorRef<Card> actorRefCard = GameMode.GetActor(card);
                    Vector3 endPosition = new Vector3(GameDisplayer.GetCardDisplayerPos(actorRefCard).X,
                        GameDisplayer.GetCardDisplayerPos(actorRefCard).Y,
                        GameDisplayer.GetCardDisplayerPos(actorRefCard).Z - 0.5f);
                
                    Debug.Log($"distance is {Vector3.Distance(endPosition, transform.position)}");
                
                    lineParticleInfo.LifeTime = 100f;
                    lineParticleInfo.Parent = transform;
                    lineParticleInfo.StartPosition = transform.position;
                    lineParticleInfo.EndPosition = endPosition;
                    float scale = Vector3.Distance(endPosition, transform.position) / 7f;
                    lineParticleInfo.LocalScale = new Vector3(1, scale, 0);
                    lineParticleInfo.Rotation = CalculateLookRotation(transform.position, endPosition);
                    if (IsLocalPlayer)
                    {
                        AssetReferenceGameObject prefab = GameDisplayer.GetParticle("SpellLineToTarget");
                        lineParticleInfo.ParticlePrefab = prefab;
                        GameDisplayer.GetParticleManger().PlayParticle(lineParticleInfo);
                    }
                    else
                    {
                        AssetReferenceGameObject prefab = GameDisplayer.GetParticle("SpellLineToTargetOppo");
                        lineParticleInfo.ParticlePrefab = prefab;
                        GameDisplayer.GetParticleManger().PlayParticle(lineParticleInfo);
                    }
                }
                else if (cardObject.SpellTarget is Hero hero)
                {
                    ActorRef<Hero> actorRefHero = GameMode.GetActor(hero);
                    DisplayerPosition heroDisplayerPosition = GameDisplayer.GetHeroDisplayerPos(actorRefHero);
                    Vector3 endPosition = new Vector3(heroDisplayerPosition.X, heroDisplayerPosition.Y,
                        heroDisplayerPosition.Z - 0.5f);
                
                    Debug.Log($"distance is {Vector3.Distance(endPosition, transform.position)}");
                
                    lineParticleInfo.LifeTime = 100f;
                    lineParticleInfo.Parent = transform;
                    lineParticleInfo.StartPosition = transform.position;
                    lineParticleInfo.EndPosition = endPosition;
                    float scale = Vector3.Distance(endPosition, transform.position) / 7f;
                    lineParticleInfo.LocalScale = new Vector3(1, scale, 0);
                    lineParticleInfo.Rotation = CalculateLookRotation(transform.position, endPosition);
                    if (IsLocalPlayer)
                    {
                        AssetReferenceGameObject prefab = GameDisplayer.GetParticle("SpellLineToTarget");
                        lineParticleInfo.ParticlePrefab = prefab;
                        GameDisplayer.GetParticleManger().PlayParticle(lineParticleInfo);
                    }
                    else
                    {
                        AssetReferenceGameObject prefab = GameDisplayer.GetParticle("SpellLineToTargetOppo");
                        lineParticleInfo.ParticlePrefab = prefab;
                        GameDisplayer.GetParticleManger().PlayParticle(lineParticleInfo);
                    }
                }
            } 帮忙优化这段代码