/// <summary> /// Find startup unload objects and move them from ObjectElementList to StartupUnloadObjectIndexes. Also find startup off packages and register them. /// </summary> private void UpdateListsByReference() { var isNotStartupUnloadObjectTable = new Dictionary <int, bool>(); for (var i = 0; i < this.ObjectElementList.Count; i++) { isNotStartupUnloadObjectTable.Add(i, true); } for (var i = 0; i < this.ObjectElementList.Count; i++) { var element = this.ObjectElementList[i]; var typeAttribute = element.GetAttributeByName("type"); if (typeAttribute == null) { continue; } var typeName = typeAttribute.GetTextValue(); if (typeName != "SQEX.Ebony.Framework.Entity.EntityPackageReference" && typeName != "Black.Entity.Data.CharacterEntry.CharaEntryPackage") { continue; } var startupLoadElement = element.GetElementByName("startupLoad_"); if (startupLoadElement?.GetBoolValue() == false) { isNotStartupUnloadObjectTable[i] = false; } var isTemplateTraySourceReferenceElement = element.GetElementByName("isTemplateTraySourceReference_"); if (isTemplateTraySourceReferenceElement?.GetBoolValue() == true) { isNotStartupUnloadObjectTable[i] = false; } var dataRelativeSourcePath = GetDataRelativePath(element, null); this.StartupOffPackageFilePaths.Add(dataRelativeSourcePath); var triggerTypeElement = element.GetElementByName("triggerType_"); if (triggerTypeElement == null) { continue; } var triggerTypeValueAttribute = triggerTypeElement.GetAttributeByName("value"); var triggerType = 0; if (triggerTypeValueAttribute != null) { triggerType = triggerTypeValueAttribute.ToInt(); } if (triggerType == 0) { continue; } var externalPointerInfo = new ExternalPointerInfo(9, null); externalPointerInfo.AddKey(dataRelativeSourcePath); this.Result.ExternalPointerInfos.Add(externalPointerInfo); var fixid = 0u; var packageSearchLabelIdElement = element.GetElementByName("packageSearchLabelId_"); if (packageSearchLabelIdElement != null) { var fixidAttribute = packageSearchLabelIdElement.GetAttributeByName("fixid"); if (fixidAttribute != null) { fixid = fixidAttribute.ToUInt(); } } float[] position = null; var positionElement = element.GetElementByName("position_"); if (positionElement != null) { position = positionElement.GetFloat4Value(); } float[] rotation = null; var rotationElement = element.GetElementByName("rotation_"); if (rotationElement != null) { rotation = rotationElement.GetFloat4Value(); } var triggerEnableElement = element.GetElementByName("triggerEnable_"); var triggerEnable = true; if (triggerEnableElement != null) { triggerEnable = triggerEnableElement.GetBoolValue(); } var isNotLoadedAtFlying = false; var isNotLoadedAtFlyingElement = element.GetElementByName("isNotLoadedAtFlying_"); if (isNotLoadedAtFlyingElement != null) { isNotLoadedAtFlying = isNotLoadedAtFlyingElement.GetBoolValue(); } var invalidateInitForceLoadRadiusFlag = false; var invalidateInitForceLoadRadiusFlagElement = element.GetElementByName("invalidateInitForceLoadRadiusFlag_"); if (invalidateInitForceLoadRadiusFlagElement != null) { invalidateInitForceLoadRadiusFlag = invalidateInitForceLoadRadiusFlagElement.GetBoolValue(); } var noWaitLoadingAtFlying = false; var noWaitLoadingAtFlyingElement = element.GetElementByName("noWaitLoadingAtFlying_"); if (noWaitLoadingAtFlyingElement != null) { noWaitLoadingAtFlying = noWaitLoadingAtFlyingElement.GetBoolValue(); } var importantLoading = false; var importantLoadingElement = element.GetElementByName("importantLoading_"); if (importantLoadingElement != null) { importantLoading = importantLoadingElement.GetBoolValue(); } var triggerRadius = 0.0f; var triggerRadiusElement = element.GetElementByName("triggerRadius_"); if (triggerRadiusElement != null) { triggerRadius = triggerRadiusElement.GetFloatValue(); } var triggerHeight = 1000.0f; var triggerHeightElement = element.GetElementByName("triggerHeight_"); if (triggerHeightElement != null) { triggerHeight = triggerHeightElement.GetFloatValue(); } var triggerWidth = 0.0f; var triggerWidthElement = element.GetElementByName("triggerWidth_"); if (triggerWidthElement != null) { triggerWidth = triggerWidthElement.GetFloatValue(); } var triggerDepth = 0.0f; var triggerDepthElement = element.GetElementByName("triggerDepth_"); if (triggerDepthElement != null) { triggerDepth = triggerDepthElement.GetFloatValue(); } var unloadMargin = 0.0f; var unloadMarginElement = element.GetElementByName("unloadMargin_"); if (unloadMarginElement != null) { unloadMargin = unloadMarginElement.GetFloatValue(); } var forceNowLoadingRatio = 0.0f; var forceNowLoadingRatioElement = element.GetElementByName("forceNowLoadingRatio_"); if (forceNowLoadingRatioElement != null) { forceNowLoadingRatio = forceNowLoadingRatioElement.GetFloatValue(); } float[] triggerOffset = null; var triggerOffsetElement = element.GetElementByName("triggerOffset_"); if (triggerOffsetElement != null) { triggerOffset = triggerOffsetElement.GetFloat4Value(); } string lodLowPackageName = null; var lodLowPackageNameElement = element.GetElementByName("lodLowPackageName_"); if (lodLowPackageNameElement != null) { lodLowPackageName = lodLowPackageNameElement.GetTextValue(); externalPointerInfo.AddKey(lodLowPackageName); } else { externalPointerInfo.AddKey(null); } string loadDependentPackageName = null; var loadDependentPackageNameElement = element.GetElementByName("loadDependentPackageName_"); if (loadDependentPackageNameElement != null) { loadDependentPackageName = loadDependentPackageNameElement.GetTextValue(); externalPointerInfo.AddKey(loadDependentPackageName); } else { externalPointerInfo.AddKey(null); } var isLowPackageLoad = false; var isLowPackageLoadElement = element.GetElementByName("isLowPackageLoad_"); if (isLowPackageLoadElement != null) { isLowPackageLoad = isLowPackageLoadElement.GetBoolValue(); } var name = element.GetAttributeByName("name"); externalPointerInfo.AddKey(name.GetTextValue()); var path = element.GetAttributeByName("path"); externalPointerInfo.AddKey(path.GetTextValue()); var paramsBuffer = externalPointerInfo.GetParamsBuffer(); paramsBuffer.Add(fixid); paramsBuffer.Add(position); paramsBuffer.Add(rotation); paramsBuffer.Add(triggerType); paramsBuffer.Add(triggerEnable); paramsBuffer.Add(isNotLoadedAtFlying); paramsBuffer.Add(invalidateInitForceLoadRadiusFlag); paramsBuffer.Add(noWaitLoadingAtFlying); paramsBuffer.Add(importantLoading); paramsBuffer.Add(triggerRadius); paramsBuffer.Add(triggerHeight); paramsBuffer.Add(triggerWidth); paramsBuffer.Add(triggerDepth); paramsBuffer.Add(lodLowPackageName); paramsBuffer.Add(forceNowLoadingRatio); paramsBuffer.Add(triggerOffset); paramsBuffer.Add(isLowPackageLoad); } foreach (var entry in isNotStartupUnloadObjectTable) { if (entry.Value) { continue; } var objectIndex = 0; var element = this.ObjectElementList[entry.Key]; var objectIndexAttribute = element.GetAttributeByName("objectIndex"); if (objectIndexAttribute != null) { objectIndex = objectIndexAttribute.ToInt(); } this.StartupUnloadObjectIndexes.Add(objectIndex); } /*foreach (var entry in isNotStartupUnloadObjectTable) * { * if (entry.Value) * { * continue; * } * * var objToRemove = this.ObjectElementList[entry.Key]; * this.ObjectElementList.Remove(objToRemove); * }*/ }
private bool ResolvePointer(Xmb2Element parentElement, Xmb2Element childElement, out object destination) { int referencedObjectIndex = 0; destination = this.ReadReference(childElement, out referencedObjectIndex); if (destination != null) { return(true); } var isPointerType = false; var typeAttribute = childElement.GetAttributeByName("type"); if (typeAttribute != null) { var type = typeAttribute.GetTextValue(); if (type == "pointer") { isPointerType = true; } } /*TODO * bool result; * if (!isPointerType && this.TryRegisterExternalPointerInfoAsSubPackage(destination, referencedObjectIndex, out result) * { * return result; * }*/ if (this.UncheckedObjectIndices.Contains(referencedObjectIndex)) { return(false); } if (this.StartupUnloadObjectIndexes.Contains(referencedObjectIndex)) { return(false); } var useUnresolvedPointerReferenceAttribute = childElement.GetAttributeByName("UseUnresolvedPointerReference"); if (useUnresolvedPointerReferenceAttribute?.ToBool() != true) { var resolvedReferenceAttribute = childElement.GetAttributeByName("object"); if (isPointerType) { Debug.Assert(resolvedReferenceAttribute == null, $"[EntityPackageXmlLoader] ResolvedReference not found : object path={resolvedReferenceAttribute.GetTextValue()}"); } else { var useTemplateConnectionAttribute = childElement.GetAttributeByName("UseTemplateConnection"); var unknownFlagAttribute = childElement.GetAttributeByName(4262871454); if (useTemplateConnectionAttribute?.ToBool() == true || unknownFlagAttribute?.ToBool() == true) { var prefabConnectionRelativePathAttribute = childElement.GetAttributeByName("relativePath"); var targetPackageSourcePathAttribute = childElement.GetAttributeByName("targetPackageSourcePath"); var proxyConnectionOwnerPackageNameAttribute = childElement.GetAttributeByName("ProxyConnectionOwnerPackageName"); Debug.Assert(prefabConnectionRelativePathAttribute != null, $"[EntityPackageXmlLoader] Prefab Connection : relativePath is null : object path={resolvedReferenceAttribute.GetTextValue()}, targetPackageSourcePath={targetPackageSourcePathAttribute.GetTextValue()}"); Debug.Assert(useTemplateConnectionAttribute?.ToBool() != true || proxyConnectionOwnerPackageNameAttribute?.ToBool() != false, $"[EntityPackageXmlLoader] Template Connection : targetPackageName is null : object path={resolvedReferenceAttribute.GetTextValue()}, targetPackageSourcePath={targetPackageSourcePathAttribute.GetTextValue()}"); var templateConnectionRelativePathAttribute = childElement.GetAttributeByName("relativePath"); var prefabConnectionSourceItemPathAttribute = childElement.GetAttributeByName("PrefabConnectionSourceItemPath"); ushort templateConnectionProtocol = 6; if (useTemplateConnectionAttribute?.ToBool() == false) { templateConnectionProtocol = 4; } var templateConnectionExternalPointerInfo = new ExternalPointerInfo(templateConnectionProtocol, destination); this.Result.ExternalPointerInfos.Add(templateConnectionExternalPointerInfo); templateConnectionExternalPointerInfo.AddKey(targetPackageSourcePathAttribute?.GetTextValue()); templateConnectionExternalPointerInfo.AddKey(proxyConnectionOwnerPackageNameAttribute?.GetTextValue()); templateConnectionExternalPointerInfo.AddKey(resolvedReferenceAttribute?.GetTextValue()); templateConnectionExternalPointerInfo.AddKey(templateConnectionRelativePathAttribute?.GetTextValue()); templateConnectionExternalPointerInfo.AddKey(prefabConnectionSourceItemPathAttribute?.GetTextValue()); templateConnectionExternalPointerInfo.AddKey(this.SourcePath); return(true); } Debug.Assert(resolvedReferenceAttribute?.GetTextValue() != null, "[EntityPackageXmlLoader] reference not found : object path is null"); Debug.Assert(resolvedReferenceAttribute?.GetTextValue() != "INVALID_CONNECTOR", $"[EntityPackageXmlLoader] reference not found : object path={parentElement.GetAttributeByName("path")?.GetTextValue()}, reference path={resolvedReferenceAttribute.GetTextValue()}"); } return(false); } var farReferenceAttribute = childElement.GetAttributeByName("FarReference"); var objectAttribute = childElement.GetAttributeByName("object"); var relativePathAttribute = childElement.GetAttributeByName("relativePath"); var unknownKeyAttribute = childElement.GetAttributeByName(347410431); var unresolvedPointerPackageSourceAttribute = childElement.GetAttributeByName("UnresolvedPointerPackageSource"); ushort protocol = 7; if (farReferenceAttribute?.ToBool() == false) { protocol = 1; } var externalPointerInfo = new ExternalPointerInfo(protocol, destination); this.Result.ExternalPointerInfos.Add(externalPointerInfo); externalPointerInfo.AddKey(unresolvedPointerPackageSourceAttribute?.GetTextValue()); externalPointerInfo.AddKey(objectAttribute?.GetTextValue()); externalPointerInfo.AddKey(relativePathAttribute?.GetTextValue()); externalPointerInfo.AddKey(unknownKeyAttribute?.GetTextValue()); externalPointerInfo.AddKey(this.SourcePath); if (farReferenceAttribute?.ToBool() == true) { externalPointerInfo.AddKey(childElement.GetAttributeByName(1280569575).GetTextValue()); } return(true); }