public override void RestoreFromJSON(JSONClass jc, bool fromProfile, bool fromScene) { base.RestoreFromJSON(jc, fromProfile, fromScene); if (!fromScene) { return; } if (_restored) { return; } if (fromProfile) { return; } _restored = true; if (jc.HasKey("Logs")) { _logs = jc["Logs"].AsArray; } if (jc.HasKey("Snapshots")) { snapshots.AddRange(jc["Snapshots"].AsArray.Childs.Select(s => EmbodyDebugSnapshot.FromJSON(s.AsObject))); } }
public override void RestoreFromJSON(JSONClass jc, bool restorePhysical = true, bool restoreAppearance = true, JSONArray presetAtoms = null, bool setMissingToDefault = true) { if (jc.HasKey(TrackedMorphCountKey)) { for (var i = 0; i < jc[TrackedMorphCountKey].AsInt; i++) { string morphEnabledKey = TrackedMorphEnabledKey(i); string morphName = jc[TrackedMorphNameKey(i)] ?? String.Empty; bool morphEnabled = jc.HasKey(morphEnabledKey) ? jc[morphEnabledKey].AsBool : false; string morphAtom = jc[TrackedMorphAtomNameKey(i)] ?? String.Empty; if (SuperController.singleton.GetAtomByUid(morphAtom) == null) { var position = i; StartCoroutine(GetOrCreateEmptyAtom(morphAtom, (atom) => { if (atom != null) { UICreateMorphRow(position, morphName, true, atom.name, true); } })); } else { UICreateMorphRow(i, morphName, morphEnabled, morphAtom, false); } } } base.RestoreFromJSON(jc, restorePhysical, restoreAppearance, presetAtoms); }
public bool HasChildObject(string key) { if (c_ == null) { return(false); } if (!c_.HasKey(key)) { return(false); } return(c_[key] is JSONClass); }
// loading scene public override void RestoreFromJSON(JSONClass jc, bool restorePhysical = true, bool restoreAppearance = true, JSONArray presetAtoms = null, bool setMissingToDefault = true) { #if LFE_DEBUG SuperController.LogMessage($"RestoreFromJSON()"); #endif base.RestoreFromJSON(jc, restorePhysical, restoreAppearance, presetAtoms, setMissingToDefault); try { if (jc.HasKey("Settings")) { var settings = jc["Settings"].AsObject; if (settings != null) { SettingsController.LoadFrom(settings); SettingsController.SetDevice( SettingsController.GlobalSettings?.AsObject[SettingsController.DEVICE_KEY]?.Value ?? String.Empty ); SettingsController.SetIpAddress( SettingsController.GlobalSettings?.AsObject[SettingsController.CLIENT_IP_KEY]?.Value ?? String.Empty ); SettingsController.SetLocalServerIpAddress( SettingsController.GlobalSettings?.AsObject[SettingsController.SERVER_IP_KEY]?.Value ?? String.Empty ); } } if (UIController != null) { foreach (var item in UIController.StorableIsGroupEnabled) { #if LFE_DEBUG SuperController.LogMessage($"{item}"); #endif if (jc.HasKey(item.Key)) { item.Value.val = jc[item.Key]?.AsBool ?? true; #if LFE_DEBUG SuperController.LogMessage($"setting group value: {item.Key} to {item.Value.val}"); #endif } } } return; } catch (Exception e) { SuperController.LogError($"Load settings failed: {e.ToString()}"); } }
public Playback(JSONClass json, GenerateDAZMorphsControlUI morphControl) { float scale = 1; if (json.HasKey("scale")) { scale = json["scale"].AsFloat; } var keys = json["keys"].AsObject; List <Animation> animations = new List <Animation>(); foreach (var morphName in keys.Keys.ToList()) { var animString = keys[morphName].Value; var morph = morphControl.GetMorphByDisplayName(morphName); if (morph == null) { SuperController.LogError("MorphAnimation: morph not found: " + morphName); continue; } animations.Add(new Animation(morph, animString, scale)); } this.animations = animations; }
public AtomAnimationClip DeserializeClip(JSONClass clipJSON) { var animationName = clipJSON["AnimationName"].Value; var animationLayer = DeserializeString(clipJSON["AnimationLayer"], AtomAnimationClip.DefaultAnimationLayer); bool?legacyTransition = null; if (clipJSON.HasKey("Transition")) { legacyTransition = DeserializeBool(clipJSON["Transition"], false); } var clip = new AtomAnimationClip(animationName, animationLayer) { blendInDuration = DeserializeFloat(clipJSON["BlendDuration"], AtomAnimationClip.DefaultBlendDuration), loop = DeserializeBool(clipJSON["Loop"], true), autoTransitionPrevious = legacyTransition ?? DeserializeBool(clipJSON["AutoTransitionPrevious"], false), autoTransitionNext = legacyTransition ?? DeserializeBool(clipJSON["AutoTransitionNext"], false), preserveLoops = DeserializeBool(clipJSON["SyncTransitionTime"], false), ensureQuaternionContinuity = DeserializeBool(clipJSON["EnsureQuaternionContinuity"], true), nextAnimationName = clipJSON["NextAnimationName"]?.Value, nextAnimationTime = DeserializeFloat(clipJSON["NextAnimationTime"]), nextAnimationTimeRandomize = DeserializeFloat(clipJSON["NextAnimationTimeRandomize"]), autoPlay = DeserializeBool(clipJSON["AutoPlay"], false), speed = DeserializeFloat(clipJSON["Speed"], 1), weight = DeserializeFloat(clipJSON["Weight"], 1), uninterruptible = DeserializeBool(clipJSON["Uninterruptible"], false), animationLength = DeserializeFloat(clipJSON["AnimationLength"]).Snap() }; DeserializeClip(clip, clipJSON); return(clip); }
public override void RestoreFromJSON(JSONClass json, bool restorePhysical = true, bool restoreAppearance = true, JSONArray presetAtoms = null, bool setMissingToDefault = true) { restoringFromJson = true; try { CheckSavedVersion(json, () => { //should never occur if (version.CompareTo(v2_1) < 0) { return; } //needs conversion from legacy values if (json.HasKey("Breast softness")) { float val = json["Breast softness"].AsFloat; if (val <= Const.LEGACY_MAX) { legacySoftnessFromJson = val; } } if (json.HasKey("Breast gravity")) { float val = json["Breast gravity"].AsFloat; if (val <= Const.LEGACY_MAX) { legacyGravityFromJson = val; } } }); } catch (Exception) { } if (json.HasKey("Mode")) { modeChooser.val = json["Mode"]; } base.RestoreFromJSON(json, restorePhysical, restoreAppearance, presetAtoms, setMissingToDefault); }
protected void LoadJsonField(JSONClass jsonClass, string name, Action <float> setValue) { if (!jsonClass.HasKey(name)) { return; } Modified = true; setValue(jsonClass[name].AsFloat); }
private IList <IFizzUserGroup> ParseResponse(string response) { FizzLogger.D("query parse links: " + response); JSONClass json = JSONNode.Parse(response).AsObject; if (!json.HasKey("links") || !json.HasKey("groups")) { throw FizzRestClient.ERROR_INVALID_RESPONSE_FORMAT; } JSONClass links = json["links"].AsObject; ParseLinks(links); JSONArray groupsElement = json["groups"].AsArray; return(ParseGroups(groupsElement)); }
private void ParseLinks(JSONClass links) { if (links.HasKey("next")) { _next = links["next"]; } else { _next = null; } HasNext = _next != null; }
protected void LoadJsonField(JSONClass jsonClass, string name, Action <Vector3> setValue) { var nameX = $"{name}X"; var nameY = $"{name}Y"; var nameZ = $"{name}Z"; if (!jsonClass.HasKey(nameX)) { return; } Modified = true; Vector3 value; value.x = jsonClass[nameX].AsFloat; value.y = jsonClass[nameY].AsFloat; value.z = jsonClass[nameZ].AsFloat; setValue(value); }
private void ImportControllerStates(JSONClass jc) { if (jc.HasKey("ControllersState")) { var controllersState = jc["ControllersState"].AsObject; foreach (var k in controllersState.Keys) { var fc = plugin.containingAtom.freeControllers.FirstOrDefault(x => x.name == k); if (fc == null) { SuperController.LogError($"Timeline: Loaded animation had state for controller {k} but no such controller were found on this atom."); continue; } var state = controllersState[k]; fc.currentPositionState = (FreeControllerV3.PositionState)state["currentPositionState"].AsInt; fc.transform.localPosition = AtomAnimationSerializer.DeserializeVector3(state["localPosition"].AsObject); fc.currentRotationState = (FreeControllerV3.RotationState)state["currentRotationState"].AsInt; fc.transform.localRotation = AtomAnimationSerializer.DeserializeQuaternion(state["localRotation"].AsObject); } } }
public static EmbodyDebugSnapshot FromJSON(JSONClass jc) { return(new EmbodyDebugSnapshot { name = jc.HasKey("Name") ? jc["Name"].Value : null, active = jc.HasKey("Active") && jc["Active"].Value != "Null" ? jc["Active"].AsBool : (bool?)null, vrMode = jc.HasKey("VRMode") ? jc["VRMode"].Value : null, worldScale = jc.HasKey("WorldScale") ? jc["WorldScale"].AsFloat : 0f, playerHeightAdjust = jc.HasKey("PlayerHeightAdjust") ? jc["PlayerHeightAdjust"].AsFloat : 0f, navigationRig = jc.HasKey("NavigationRig") ? EmbodyTransformDebugSnapshot.FromJSON(jc["NavigationRig"]) : null, head = jc.HasKey("Head") ? EmbodyTransformDebugSnapshot.FromJSON(jc["Head"]) : null, leftHand = jc.HasKey("LeftHand") ? EmbodyTransformDebugSnapshot.FromJSON(jc["LeftHand"]) : null, rightHand = jc.HasKey("RightHand") ? EmbodyTransformDebugSnapshot.FromJSON(jc["RightHand"]) : null, viveTracker1 = jc.HasKey("ViveTracker1") ? EmbodyTransformDebugSnapshot.FromJSON(jc["ViveTracker1"]) : null, viveTracker2 = jc.HasKey("ViveTracker2") ? EmbodyTransformDebugSnapshot.FromJSON(jc["ViveTracker2"]) : null, viveTracker3 = jc.HasKey("ViveTracker3") ? EmbodyTransformDebugSnapshot.FromJSON(jc["ViveTracker3"]) : null, viveTracker4 = jc.HasKey("ViveTracker4") ? EmbodyTransformDebugSnapshot.FromJSON(jc["ViveTracker4"]) : null, viveTracker5 = jc.HasKey("ViveTracker5") ? EmbodyTransformDebugSnapshot.FromJSON(jc["ViveTracker5"]) : null, viveTracker6 = jc.HasKey("ViveTracker6") ? EmbodyTransformDebugSnapshot.FromJSON(jc["ViveTracker6"]) : null, viveTracker7 = jc.HasKey("ViveTracker7") ? EmbodyTransformDebugSnapshot.FromJSON(jc["ViveTracker7"]) : null, viveTracker8 = jc.HasKey("ViveTracker8") ? EmbodyTransformDebugSnapshot.FromJSON(jc["ViveTracker8"]) : null, pluginJSON = jc.HasKey("Plugin") ? jc["Plugin"].AsObject : null, poseJSON = jc.HasKey("Pose") ? jc["Pose"].AsArray : null }); }
public bool HasKey(string s) { return(c_?.HasKey(s) ?? false); }