public bool validateInput(Client.Input input) { if (Math.Abs(input.press_time.TotalMilliseconds) > 1 / 40) { return(false); } return(true); }
public void processInputs() { // Process all pending messages from clients. while (true) { LagNetwork.IMessage message = this.network.receive(); if (message == null) { break; } Client.Input input = ((LagNetwork.ClientMessage)message).input; // Update the state of the entity, based on its input. // We just ignore inputs that don't look valid; this is what prevents clients from cheating. Console.WriteLine(input.press_time.TotalMilliseconds); if (true || validateInput(input)) { int id = input.entity_id; entities[id].applyInput(input); last_processed_input[id] = input.input_sequence_number; } } }
public Slider ui_slider; // Appended public void applyInput(Client.Input input) { x += input.press_time.TotalSeconds * speed; }