Exemplo n.º 1
0
        private void Initialize(
            TSVector2 position,
            FP radians,
            VoltShape[] shapesToAdd)
        {
            this.Position = position;
            this.Angle    = radians;
            this.Facing   = VoltMath.Polar(radians);

#if DEBUG
            for (int i = 0; i < shapesToAdd.Length; i++)
            {
                VoltDebug.Assert(shapesToAdd[i].IsInitialized);
            }
#endif

            if ((this.shapes == null) || (this.shapes.Length < shapesToAdd.Length))
            {
                this.shapes = new VoltShape[shapesToAdd.Length];
            }
            Array.Copy(shapesToAdd, this.shapes, shapesToAdd.Length);
            this.shapeCount = shapesToAdd.Length;
            for (int i = 0; i < this.shapeCount; i++)
            {
                this.shapes[i].AssignBody(this);
            }

#if DEBUG
            this.IsInitialized = true;
#endif
        }
Exemplo n.º 2
0
 public void Set(TSVector2 position, FP radians)
 {
     this.Position = position;
     this.Angle    = radians;
     this.Facing   = VoltMath.Polar(radians);
     this.OnPositionUpdated();
 }
Exemplo n.º 3
0
 private void IntegrateVelocity()
 {
     this.Position +=
         this.World.DeltaTime * this.LinearVelocity + this.BiasVelocity;
     this.Angle +=
         this.World.DeltaTime * this.AngularVelocity + this.BiasRotation;
     this.Facing = VoltMath.Polar(this.Angle);
 }
Exemplo n.º 4
0
        public void PerformExplosion(
            TSVector2 origin,
            FP radius,
            VoltExplosionCallback callback,
            VoltBodyFilter targetFilter    = null,
            VoltBodyFilter occlusionFilter = null,
            int ticksBehind = 0,
            int rayCount    = 32)
        {
            if (ticksBehind < 0)
            {
                throw new ArgumentOutOfRangeException("ticksBehind");
            }

            // Get all target bodies
            this.PopulateFiltered(
                origin,
                radius,
                targetFilter,
                ticksBehind,
                ref this.targetBodies);

            // Get all occluding bodies
            this.PopulateFiltered(
                origin,
                radius,
                occlusionFilter,
                ticksBehind,
                ref this.occludingBodies);

            VoltRayCast ray;
            FP          rayWeight      = 1.0f / rayCount;
            FP          angleIncrement = (TSMath.Pi * 2.0f) * rayWeight;

            for (int i = 0; i < rayCount; i++)
            {
                TSVector2 normal = VoltMath.Polar(angleIncrement * i);
                ray = new VoltRayCast(origin, normal, radius);

                FP minDistance =
                    this.GetOccludingDistance(ray, ticksBehind);
                minDistance += VoltWorld.EXPLOSION_OCCLUDER_SLOP;

                this.TestTargets(ray, callback, ticksBehind, minDistance, rayWeight);
            }
        }