private void CreateFloatingParticle(IMyEntity target)
        {
            double distance = Vector3D.Distance(m_constructionBlock.ConstructionBlock.GetPosition(), target.GetPosition());
            int    time     = (int)Math.Max(GetMinTravelTime() * 1000f, (distance / GetSpeed()) * 1000f);

            // This should be moved somewhere else.  It initializes a tracker
            if (!m_targetTracker.ContainsKey(target))
            {
                NaniteFloatingTarget floatingTarget = new NaniteFloatingTarget();
                floatingTarget.ParticleCount = 0;
                floatingTarget.StartTime     = MyAPIGateway.Session.ElapsedPlayTime.TotalMilliseconds;
                floatingTarget.LastUpdate    = MyAPIGateway.Session.ElapsedPlayTime.TotalMilliseconds;
                floatingTarget.CarryTime     = time - 1000;
                m_targetTracker.Add(target, floatingTarget);
            }

            if (NaniteParticleManager.TotalParticleCount > NaniteParticleManager.MaxTotalParticles)
            {
                return;
            }

            m_targetTracker[target].ParticleCount++;
            int size = (int)Math.Max(60f, NaniteParticleManager.TotalParticleCount);

            if ((float)m_targetTracker[target].ParticleCount / size < 1f)
            {
                return;
            }

            m_targetTracker[target].ParticleCount = 0;

            // Create Particle
            Vector4 startColor = new Vector4(0.75f, 0.75f, 0.0f, 0.75f);
            Vector4 endColor   = new Vector4(0.20f, 0.20f, 0.0f, 0.75f);

            m_constructionBlock.ParticleManager.AddParticle(startColor, endColor, GetMinTravelTime() * 1000f, GetSpeed(), target);
        }
Пример #2
0
        private void CreateFloatingParticle(IMyEntity target)
        {
            Logging.Instance.WriteLine("[Floating] Completing Floating Object Target: CreateFloatingParticle", 1);
            double distance = Vector3D.Distance(m_constructionBlock.ConstructionBlock.GetPosition(), target.GetPosition());
            int    time     = (int)Math.Max(GetMinTravelTime() * 1000f, (distance / GetSpeed()) * 1000f);

            // This should be moved somewhere else.  It initializes a tracker
            if (!m_targetTracker.ContainsKey(target))
            {
                NaniteFloatingTarget floatingTarget = new NaniteFloatingTarget();
                floatingTarget.ParticleCount = 0;
                floatingTarget.StartTime     = MyAPIGateway.Session.ElapsedPlayTime.TotalMilliseconds;
                floatingTarget.LastUpdate    = MyAPIGateway.Session.ElapsedPlayTime.TotalMilliseconds;
                floatingTarget.CarryTime     = time - 1000;
                m_targetTracker.Add(target, floatingTarget);
            }

            MyAPIGateway.Parallel.Start(() =>
            {
                try
                {
                    Vector4 startColor = new Vector4(0.75f, 0.75f, 0.0f, 0.75f);
                    Vector4 endColor   = new Vector4(0.20f, 0.20f, 0.0f, 0.75f);

                    var nearestFactory = GetNearestFactory(TargetName, target.GetPosition());
                    if (nearestFactory.ParticleManager.Particles.Count < NaniteParticleManager.MaxTotalParticles)
                    {
                        MyAPIGateway.Utilities.InvokeOnGameThread(() =>
                        {
                            nearestFactory.ParticleManager.AddParticle(startColor, endColor, GetMinTravelTime() * 1000f, GetSpeed(), target);
                        });
                    }
                }
                catch (Exception e)
                { Logging.Instance.WriteLine($"{e}"); }
            });
        }