Closed Mirlle closed 3 years ago
Sample Idea:
class TransmitInfo{
public readonly PlayerHit mPlayerHit; //Set this in constructor
public readonly int mPlayer; // This Player
struct PlayerLocation{
float x;
float y;
}
struct playersHit{
boolean ZERO;
boolean ONE;
boolean TWO;
boolean THREE;
boolean FOUR
}
public readonly int MoneyBagPicked;
}
How will we validate PlayerLocation?
All other validations (PlayersHit and Pickups) are validated using PlayerLocation
- [ ] Player position
- [ ] [Damaging player]
- [ ] Players current health
Change of plan with PlayerHit. Instead of holding it in a struct, we should hold it in a HashMap<int,int>
where the first value if 1 indicates that that player is hit. As we can assume that only one player is hit by another in a single frame, we know that there will only be one 1
value in the hashmap allowing us to discover it in O(1)
time rather than O(N)
as it was previously. Using a HashMap will also remove the restriction on the amount of players in a game
Change of plan with PlayerHit. Instead of holding it in a struct, we should hold it in a
HashMap<int,int>
where the first value if 1 indicates that that player is hit. As we can assume that only one player is hit by another in a single frame, we know that there will only be one1
value in the hashmap allowing us to discover it inO(1)
time rather thanO(N)
as it was previously. Using a HashMap will also remove the restriction on the amount of players in a game
Alternatively, As only one player is hit at a time, you could just have a field public readonly int playerHit
to record the id of the player that has been hit or -1
if no player was hit in that frame
Location.proto
PlayerHit.proto
MoneyBagPicked.proto