Ejemplo n.º 1
0
 public override void FinishUpdate(GameActor gameActor)
 {
     if (gameActor.ThingBeingHeldByThisActor != null)
     {
         // presence is only thing important here
         SensorTarget target = SensorTargetSpares.Alloc();
         target.Init(gameActor, gameActor.ThingBeingHeldByThisActor);
         senseSet.AddOrFree(target);
     }
 }
Ejemplo n.º 2
0
        public override void FinishUpdate(GameActor gameActor)
        {
            if (terrainSensor != null)
            {
                //if (TouchEdit.HitInfo.TerrainHit)
                {
                    terrainSensor.OverrideSenseMaterial = TouchEdit.HitInfo.TerrainMaterial;
                }

                terrainSensor.FinishUpdate(gameActor);
            }
            else
            {
                if (TouchEdit.HitInfo.HaveActor)
                {
                    GameActor touchdActor = TouchEdit.HitInfo.ActorHit;

                    Vector3 actorCenter = Vector3.Transform(
                        gameActor.BoundingSphere.Center,
                        gameActor.Movement.LocalMatrix);

                    Vector3 thingCenter = Vector3.Transform(
                        touchdActor.BoundingSphere.Center,
                        touchdActor.Movement.LocalMatrix);

                    Vector3 direction = thingCenter - actorCenter;

                    float range = direction.Length();
                    if (range > 0.0f)
                    {
                        direction *= 1.0f / range; // Normalize.
                    }

                    SensorTarget target = SensorTargetSpares.Alloc();
                    target.Init(touchdActor, direction, range);
                    senseSet.AddOrFree(target);
                }

                senseSet.Add(NullActor.Instance, Vector3.Zero, float.MaxValue);
            }
        }