// &&&&&&&&&&&&& remove // private void _updatePosition(float secs, long frameApianTime) // { // if (secs == 0 || speed == 0) // return; // Vector2 upcomingPoint = UpcomingGridPoint(); // float timeToPoint = Vector2.Distance(position, upcomingPoint) / speed; // Vector2 newPos = position; // Heading newHead = heading; // if (secs >= timeToPoint) // { // logger.Debug($"_updatePosition() Bike: {bikeId} MsToPoint: {(long)(timeToPoint*1000)}"); // secs -= timeToPoint; // newPos = upcomingPoint; // newHead = GameConstants.NewHeadForTurn(heading, pendingTurn); // pendingTurn = TurnDir.kUnset; // DoAtGridPoint(upcomingPoint, heading, newHead, frameApianTime);// + (long)(timeToPoint*1000)); // Using the offset makes odd things happen on the server // heading = newHead; // } // newPos += GameConstants.UnitOffset2ForHeading(heading) * secs * speed; // position = newPos; // } // private float _rollbackTime(float secs) // { // // Propagate the bike backwards in time by "secs" or almost the length of time that // // takes it backwards to the previous point - whichever is shorter // // This is to try to minimize message delays. // // If, for instance, a bike command is received that we know happened .08 secs ago, // // then the code handling the command can roll the bike back, apply the ecommand, and then // // call bike.update(rolledBackTime) to have effectively back-applied the command. // // it's not really safe to go backwards across a gridpoint, so that's as far as we'll go back. // // It returns the amount of time rolled back as a positive float. // if (speed == 0 || secs <= 0) // return 0; // Vector2 upcomingPoint = UpcomingGridPoint(); // float timeToNextPoint = Vector2.Distance(position, upcomingPoint) / speed; // float timeSinceLastPoint = Mathf.Max(0,((Ground.gridSize * .8f) / speed) - timeToNextPoint); // Note QUITE all the way back // secs = Mathf.Min(secs, timeSinceLastPoint); // position -= GameConstants.UnitOffset2ForHeading(heading) * secs * speed; // return secs; // } // private float _rollbackTime(float secs) // { // // Propagate the bike backwards in time by "secs" to apply a command that should have happened in the past // // (See above for a version that tries to avoid crossing gridpoints - this one does not anymore - the cure // // was worse than the disease) // position -= GameConstants.UnitOffset2ForHeading(heading) * secs * speed; // return secs; // } protected virtual void DoAtGridPoint(Vector2 pos, Heading entryHead, Heading exitHead, long apianTime) { BeamPlace p = gameData.GetPlace(pos); logger.Verbose($"DoAtGridPoint({pos.ToString()}) Bike: {bikeId} Time: {apianTime}"); if (p == null) { int xIdx, zIdx; (xIdx, zIdx) = Ground.NearestGridIndices(pos); // is it on the map? if (gameData.Ground.IndicesAreOnMap(xIdx, zIdx)) { // Yes. Since it's empty send a claim report // Doesn't matter if the bike is local or not - THIS peer thinks there's a claim gameData.ReportPlaceClaimed(this, xIdx, zIdx, entryHead, exitHead); } else { // Nope. Blow it up. // TODO: should going off the map be a consensus event? // Current thinking: yeah. But not now. // A thought: Could just skip the on-map check and call it a place claim and report it // GameNet can grant/not grant it depending on the consensus rules, and if inst // gets the claim it can just blow it up then. // This is stupid and temporary (rather than just getting rid of the test) // TODO: FIX THIS!!! &&&&&&& gameData.ReportPlaceClaimed(this, xIdx, zIdx, entryHead, exitHead); //gameInst.apian.SendPlaceClaimObs(apianTime, this, xIdx, zIdx, entryHead, exitHead); } } else { // Hit a marker. Report it. gameData.ReportPlaceHit(this, p.xIdx, p.zIdx, entryHead, exitHead); } }
public BeamPlace ClaimPlace(IBike bike, int xIdx, int zIdx, long expireTimeMs) { BeamPlace p = Ground.IndicesAreOnMap(xIdx, zIdx) ? (GetPlace(xIdx, zIdx) ?? SetupPlace(bike, xIdx, zIdx, expireTimeMs)) : null; return((p?.bike == bike) ? p : null); }
public static int ScoreForPoint(Ground g, Vector2 point, BeamPlace place) { return(g.PointIsOnMap(point) ? (place == null ? 5 : 1) : 0); // 5 pts for a good place, 1 for a claimed one, zero for off-map }