Beispiel #1
0
        public void FixedUpdate(double time)
        {
            var tFloat = (float)time;

            for (int i = 0; i < Projectiles.Length; i++)
            {
                if (!Projectiles[i].Alive)
                {
                    continue;
                }
                var length = Projectiles[i].Normal.Length() * tFloat;
                var dir    = Projectiles[i].Normal.Normalized();
                if (world.Physics.PointRaycast(
                        Projectiles[i].Owner?.PhysicsComponent?.Body,
                        Projectiles[i].Position,
                        dir,
                        length,
                        out var contactPoint,
                        out var po))
                {
                    Projectiles[i].Alive  = false;
                    Projectiles[i].Effect = null;
                    world.Renderer?.SpawnTempFx(Projectiles[i].Data.HitEffect, contactPoint);
                    if (po.Tag is GameObject go)
                    {
                        world.Server?.ProjectileHit(go, Projectiles[i].Owner, Projectiles[i].Data.Munition);
                    }
                }
                Projectiles[i].Position += (Projectiles[i].Normal * tFloat);
                world.DrawDebug(Projectiles[i].Position);
                Projectiles[i].Time += tFloat;
                if (Projectiles[i].Time >= Projectiles[i].Data.Lifetime)
                {
                    Projectiles[i].Alive  = false;
                    Projectiles[i].Effect = null;
                }
            }

            //collect sound instances
            List <ulong> toRemove = new List <ulong>();

            foreach (var kv in _instances)
            {
                if (!kv.Value.Playing)
                {
                    kv.Value.Dispose();
                    toRemove.Add(kv.Key);
                }
            }
            foreach (var k in toRemove)
            {
                _instances.Remove(k);
            }
        }
        public void FixedUpdate(TimeSpan time)
        {
            var tFloat = (float)time.TotalSeconds;

            for (int i = 0; i < Projectiles.Length; i++)
            {
                if (!Projectiles[i].Alive)
                {
                    continue;
                }
                Projectiles[i].Position += (Projectiles[i].Normal * tFloat);
                world.DrawDebug(Projectiles[i].Position);
                Projectiles[i].Time += tFloat;
                if (Projectiles[i].Time >= Projectiles[i].Data.Lifetime)
                {
                    Projectiles[i].Alive = false;
                }
            }
        }