private void syncPositionAndRotation(ZDO zdo, float dt) { if (zdo == null) { return; } var vr_data = zdo.GetByteArray("vr_data"); if (vr_data == null) { return; } ZPackage pkg = new ZPackage(vr_data); var currentDataRevision = zdo.m_dataRevision; if (currentDataRevision != lastDataRevision) { // New data revision since last sync so we reset our deltaT counter deltaTimeCounter = 0f; // Save the current data revision so we can detect the next new data package lastDataRevision = currentDataRevision; } deltaTimeCounter += dt; deltaTimeCounter = Mathf.Min(deltaTimeCounter, 2f); extractAndUpdate(pkg, ref camera, ref clientTempRelPosCamera, hasTempRelPos); extractAndUpdate(pkg, ref leftHand, ref clientTempRelPosLeft, hasTempRelPos); extractAndUpdate(pkg, ref rightHand, ref clientTempRelPosRight, hasTempRelPos); maybeAddVrik(); hasTempRelPos = true; readFingers(pkg); maybePullBow(pkg.ReadBool()); }
private static ZDOIDSet GetPlanPieces(ZDO blueprintZDO) { byte[] data = blueprintZDO.GetByteArray(PlanPiece.zdoBlueprintPiece); if (data == null) { return(null); } return(ZDOIDSet.From(new ZPackage(data))); }
private static void LoadConfigReferences(ZDO zdo, List <KeyValuePair <GameObject, int> > dropList) { try { #if DEBUG Log.LogDebug($"Unpacking config references for zdo {zdo.m_uid}"); #endif if (dropList is null) { #if DEBUG Log.LogDebug($"Drop list is empty. Skipping unpacking of zdo {zdo.m_uid}"); #endif return; } var serialized = zdo.GetByteArray(ZDOKey); if (serialized is null) { #if DEBUG Log.LogDebug($"Found nothing to unpack for zdo {zdo.m_uid}"); #endif return; } using (MemoryStream memStream = new MemoryStream(serialized)) { BinaryFormatter binaryFormatter = new BinaryFormatter(); var responseObject = binaryFormatter.Deserialize(memStream); if (responseObject is List <DropConfig> configPackage) { #if DEBUG Log.LogDebug($"Deserialized config package for zdo {zdo.m_uid}"); Log.LogDebug($"\t" + configPackage.Join(x => $"{x.Index}:{x.ConfigKey}")); #endif foreach (var entry in configPackage) { var configSections = entry.ConfigKey.SplitBy('.'); if (configSections.Count != 2) { Log.LogWarning($"Incorrect Drop That config section header '{entry.ConfigKey}' for zdo {zdo.m_uid}"); return; } if (entry.IsList) { if (ConfigurationManager.CharacterDropLists.TryGet(configSections[0], out CharacterDropListConfiguration listConfig)) { if (listConfig.TryGet(configSections[1], out CharacterDropItemConfiguration itemConfig)) { TempDropListCache.SetDrop(dropList, entry.Index, new DropExtended { Config = itemConfig, }); } } } else if (ConfigurationManager.CharacterDropConfigs.TryGet(configSections[0], out CharacterDropMobConfiguration mobConfig)) { if (mobConfig.TryGet(configSections[1], out CharacterDropItemConfiguration itemConfig)) { TempDropListCache.SetDrop(dropList, entry.Index, new DropExtended { Config = itemConfig, }); } } } } } } catch (Exception e) { Log.LogError("Error while attempting to attach and apply configurations to items.", e); } }