private void ParseSceneObjectState(SceneObjectState state, JObject json, SceneObjectState baseState) { ParseObjectState(state, json, baseState); state.X = (float?)json.SelectToken("x") ?? state.X; state.Y = (float?)json.SelectToken("y") ?? state.Y; if (baseState != null) { var baseX = baseState.X; if (baseX == float.MinValue) { baseX = 0; } var baseY = baseState.Y; if (baseY == float.MinValue) { baseY = 0; } var dx = (float?)json.SelectToken("dx"); var dy = (float?)json.SelectToken("dy"); if (dx != null) { state.X = baseX + (float)dx; } if (dy != null) { state.Y = baseY + (float)dy; } } state.RotX = (float?)json.SelectToken("rot_x") ?? state.RotX; state.RotY = (float?)json.SelectToken("rot_y") ?? state.RotY; state.RotZ = (float?)json.SelectToken("rot_z") ?? state.RotZ; state.ScaleX = (float?)json.SelectToken("scale_x") ?? state.ScaleX; state.ScaleY = (float?)json.SelectToken("scale_y") ?? state.ScaleY; if (json["scale"] != null) { var scale = (float)json.SelectToken("scale"); state.ScaleX = scale; state.ScaleY = scale; } state.Opacity = (float?)json.SelectToken("opacity") ?? state.Opacity; state.Width = (float?)json.SelectToken("width") ?? state.Width; state.Height = (float?)json.SelectToken("height") ?? state.Height; state.FillWidth = (bool?)json.SelectToken("fill_width") ?? state.FillWidth; state.Layer = (int?)json.SelectToken("layer") ?? state.Layer; state.Order = (int?)json.SelectToken("order") ?? state.Order; }
private void ParseSceneObjectState(SceneObjectState state, JObject json) { ParseObjectState(state, json); state.X = (float?)json.SelectToken("x") ?? state.X; state.Y = (float?)json.SelectToken("y") ?? state.Y; state.RotX = (float?)json.SelectToken("rot_x") ?? state.RotX; state.RotY = (float?)json.SelectToken("rot_y") ?? state.RotY; state.RotZ = (float?)json.SelectToken("rot_z") ?? state.RotZ; state.ScaleX = (float?)json.SelectToken("scale_x") ?? state.ScaleX; state.ScaleY = (float?)json.SelectToken("scale_y") ?? state.ScaleY; if (json["scale"] != null) { var scale = (float)json.SelectToken("scale"); state.ScaleX = scale; state.ScaleY = scale; } state.Opacity = (float?)json.SelectToken("opacity") ?? state.Opacity; state.Width = (float?)json.SelectToken("width") ?? state.Width; state.Height = (float?)json.SelectToken("height") ?? state.Height; }