private static int ToLegacyWhosball(V5RPC.Proto.Team whosball) { switch (whosball) { case Team.Self: return(1); case Team.Opponent: return(2); case Team.Nobody: return(0); default: throw new ArgumentOutOfRangeException(nameof(whosball), whosball, null); } }
public Environment(Native.Field field, V5RPC.Proto.Team whosball, ResultType gamestate, IntPtr userData) { WhosBall = ToLegacyWhosball(whosball); GameState = ToLegacyGameState(gamestate); SelfRobots = new Legacy.Robot[5]; OpponentRobots = new Legacy.OpponentRobot[5]; for (int i = 0; i < 5; i++) { SelfRobots[i] = new Legacy.Robot(field.SelfRobots[i]); OpponentRobots[i] = new Legacy.OpponentRobot(field.opponentRobots[i]); } CurrentBall = new Legacy.Ball() { Position = new Legacy.Vector3(field.ball.position) }; UserData = userData; // Useless field, just become 0 LastBall = new Legacy.Ball(); PredictedBall = new Legacy.Ball(); FieldBounds = new Legacy.Bounds(); GoalBounds = new Legacy.Bounds(); }