public PlayerState(PlayerState playerState) {//for cloning purposes Position = playerState.Position; Velocity = playerState.Velocity; PlayerColor = playerState.PlayerColor; IsTrailCyan = playerState.IsTrailCyan; IsTrailInForeground = playerState.IsTrailInForeground; CollectedPowerUpTypes = HelperClass.CloneTrick(playerState.CollectedPowerUpTypes); }
public ChangedFieldsCollection FindChangedFieldsComparedTo(IState statef)// PlayerState state) { ChangedFieldsCollection result = new ChangedFieldsCollection(); PlayerState state = (PlayerState)statef; //todo: dynamically find fields //var fieldNames = typeof(PlayerState).GetFields() // .Select(field => field.Name) // .ToList(); if (IsTrailCyan != state.IsTrailCyan) { result.AddChangedField(new ChangedField(IsTrailCyan, "IsTrailCyan", typeof(bool))); } if (PlayerColor != state.PlayerColor) { result.AddChangedField(new ChangedField(PlayerColor, "PlayerColor", typeof(PlayerColor))); } if (IsTrailInForeground != state.IsTrailInForeground) { result.AddChangedField(new ChangedField(IsTrailInForeground, "IsTrailInForeground", typeof(bool))); } if (Position != state.Position) { result.AddChangedField(new ChangedField(Position, "Position", typeof(Vector3))); } if (Velocity != state.Velocity) { result.AddChangedField(new ChangedField(Velocity, "Velocity", typeof(Vector3))); } if (HelperClass.AreTheyDifferent(CollectedPowerUpTypes, state.CollectedPowerUpTypes)) { result.AddChangedField(new ChangedField(HelperClass.CloneTrick(CollectedPowerUpTypes), "CollectedPowerUpTypes", typeof(List <PowerUpType>))); } return(result); }