Beispiel #1
0
 private bool RequiresUpdate(CharacterStateUpdate oldState, CharacterStateUpdate newState)
 {
     return(true);
     //if (oldState.Health != newState.Health) return true;
     //if (oldState.InArena != newState.InArena) return true;
     //if (oldState.InRaid != newState.InRaid) return true;
     //if (oldState.Island != newState.Island) return true;
     ////if (Math.Abs(oldState.Position.magnitude - newState.Position.magnitude) > 0.01) return true;
     //if (oldState.Task != newState.Task) return true;
     //if (oldState.TaskArgument != newState.TaskArgument) return true;
     //return oldState.DuelOpponent != newState.DuelOpponent;
 }
Beispiel #2
0
        public async Task <bool> SavePlayerAsync(IPlayerController player)
        {
            var characterUpdate = new CharacterStateUpdate(
                null,
                0,
                null,
                null,
                false,
                false,
                null,
                null,
                new Position
            {
                X = 0f,
                Y = 0f,
                Z = 0f
            });

            if (lastSavedState.TryGetValue("test", out var lastUpdate))
            {
                if (!RequiresUpdate(lastUpdate, characterUpdate))
                {
                    return(false);
                }
            }

            var response = await connection.SendAsync("update_character_state", characterUpdate);

            if (response == null)
            {
                // no response from server.
                return(false);
            }

            if (response.TryGetValue <bool>(out var result))
            {
                if (result)
                {
                    lastSavedState["test"] = characterUpdate;
                    return(true);
                }
            }

            return(false);
        }