public override void StartUpdate(GameActor gameActor) { senseSet.Clear(); // Calc device normals in world space. for (int i = 0; i < gameActor.ScanDevices.Count; i++) { ScanDevice device = gameActor.ScanDevices[i]; device.WorldSpaceNormal = Vector3.TransformNormal(device.Normal, gameActor.Movement.LocalMatrix); } } // end of StartUpdate()
} // end of StartUpdate() public override void ThingUpdate(GameActor gameActor, GameThing gameThing, Vector3 direction, float range) { // For each device check if the object is withing its sense space // and add it to the set if it is for (int indexDevice = 0; indexDevice < gameActor.ScanDevices.Count; ++indexDevice) { ScanDevice device = gameActor.ScanDevices[indexDevice]; if (range < device.Range) { float dot = Vector3.Dot(direction, device.WorldSpaceNormal); if (dot > device.ArcCosine) { // Add object to scan set. senseSet.Add(gameThing, direction, range); } } } } // end of ThingUpdate()