Ejemplo n.º 1
0
        // Ground-related

        public void OnPlaceClaimObsEvt(object sender, PlaceReportArgs args)
        {
            logger.Verbose($"OnPlaceClaimObsEvt(): Bike: {args.bike.bikeId} Place: {BeamPlace.PlacePos(args.xIdx, args.zIdx).ToString()}");

            apian.SendPlaceClaimObs(FrameApianTime, args.bike, args.xIdx, args.zIdx, args.entryHead, args.exitHead,
                                    ComputeScoreUpdate(args.bike, ScoreEvent.kClaimPlace, null));
        }
Ejemplo n.º 2
0
        public void OnPlaceClaimCmd(PlaceClaimMsg msg)
        {
            // Apian has said this message is authoritative
            BaseBike b = CoreData.GetBaseBike(msg.bikeId);

            if (CoreData.Ground.IndicesAreOnMap(msg.xIdx, msg.zIdx))
            {
                if (b == null)
                {
                    logger.Warn($"OnPlaceClaimCmd() Bike:{msg.bikeId} not found!"); // can happen if RemoveCmd and ClaimObs interleave
                    return;
                }

                b.UpdatePosFromCommand(msg.TimeStamp, FrameApianTime, BeamPlace.PlacePos(msg.xIdx, msg.zIdx), msg.exitHead);

                // Claim it
                BeamPlace p = CoreData.ClaimPlace(b, msg.xIdx, msg.zIdx, msg.TimeStamp + BeamPlace.kLifeTimeMs);
                if (p != null)
                {
                    ApplyScoreUpdate(msg.scoreUpdates);
                    logger.Verbose($"OnPlaceClaimCmd() Bike: {b.bikeId} claimed {BeamPlace.PlacePos( msg.xIdx, msg.zIdx).ToString()} at {msg.TimeStamp}");
                    //logger.Verbose($"                  BikePos: {b.position.ToString()}, FrameApianTime: {FrameApianTime} ");
                    //logger.Verbose($"   at Timestamp:  BikePos: {b.PosAtTime(msg.TimeStamp, FrameApianTime).ToString()}, Time: {msg.TimeStamp} ");
                    PlaceClaimedEvt?.Invoke(this, p);
                }
                else
                {
                    logger.Warn($"OnPlaceClaimCmd()) failed. Place already claimed.");
                }
            }
        }
Ejemplo n.º 3
0
        public void OnPlaceHitObsEvt(object sender, PlaceReportArgs args)
        {
            logger.Verbose($"OnPlaceHitObsEvt(): Bike: {args.bike.bikeId} Place: {BeamPlace.PlacePos(args.xIdx, args.zIdx).ToString()}");
            BeamPlace  place  = CoreData.GetPlace(args.xIdx, args.zIdx);
            ScoreEvent evType = place.bike.team == args.bike.team ? ScoreEvent.kHitFriendPlace : ScoreEvent.kHitEnemyPlace;

            apian.SendPlaceHitObs(FrameApianTime, args.bike, args.xIdx, args.zIdx, args.entryHead, args.exitHead, ComputeScoreUpdate(args.bike, evType, place));
        }
Ejemplo n.º 4
0
        public void OnPlaceHitCmd(PlaceHitMsg msg)
        {
            // Apian has already checked the the place is claimed and the bike exists
            Vector2   pos         = BeamPlace.PlacePos(msg.xIdx, msg.zIdx);
            BeamPlace p           = CoreData.GetPlace(pos);
            BaseBike  hittingBike = CoreData.GetBaseBike(msg.bikeId);

            if (p != null && hittingBike != null)
            {
                hittingBike.UpdatePosFromCommand(msg.TimeStamp, FrameApianTime, p.GetPos(), msg.exitHead);
                logger.Info($"OnPlaceHitCmd{p?.GetPos().ToString()} Now: {FrameApianTime} Ts: {msg.TimeStamp} Bike: {hittingBike?.bikeId} Pos: {p?.GetPos().ToString()}");
                ApplyScoreUpdate(msg.scoreUpdates);
                PlaceHitEvt?.Invoke(this, new PlaceHitArgs(p, hittingBike));
            }
            else
            {
                logger.Info($"OnPlaceHitCmd{p?.GetPos().ToString()} Now: {FrameApianTime} Ts: {msg.TimeStamp} Bike: {hittingBike?.bikeId} Pos: {p?.GetPos().ToString()}");
            }
        }