void IDiffResolver.BeforeDiff(Asset baseAsset, Asset asset1, Asset asset2) { Guid newId; var baseEntityAsset = (EntityAsset)baseAsset; var entityAsset1 = (EntityAsset)asset1; var entityAsset2 = (EntityAsset)asset2; // Let's remap IDs in asset2 (if it comes from a FBX or such, we need to do that) var oldBaseTree = new EntityTreeAsset(baseEntityAsset.Hierarchy); var newBaseTree = new EntityTreeAsset(entityAsset2.Hierarchy); var idRemapping = new Dictionary<Guid, Guid>(); // Try to transfer ID from old base to new base var mergeResult = AssetMerge.Merge(oldBaseTree, newBaseTree, oldBaseTree, node => { if (typeof(Guid).IsAssignableFrom(node.InstanceType) && node.BaseNode != null && node.Asset1Node != null) { idRemapping.Add((Guid)node.Asset1Node.Instance, (Guid)node.BaseNode.Instance); } return AssetMergePolicies.MergePolicyAsset2AsNewBaseOfAsset1(node); }); if (mergeResult.HasErrors) { //mergeResult.CopyTo(); } EntityAnalysis.RemapEntitiesId(entityAsset2.Hierarchy, idRemapping); }
/// <summary> /// Indicate if the referred member can be modified or not due to sealing. /// </summary> /// <param name="asset">The asset to modify</param> /// <param name="path">The path to the member to modify</param> /// <returns><value>true</value> if it can be modified</returns> public bool CanBeModified(Asset asset, MemberPath path) { if (path.GetNodeOverrides(asset).Any(x => x.IsNew())) return true; var assetBase = asset.Base; while (assetBase != null && assetBase.Asset != null) { var parent = assetBase.Asset; var parentPath = path.Resolve(asset, parent).FirstOrDefault(); // if several paths exist in parent, they should be all equal (same object instance) if (parentPath == null) break; var parentOverrides = parentPath.GetNodeOverrides(parent).ToList(); if (parentOverrides.LastOrDefault().IsSealed()) return false; if (parentOverrides.Any(x => x.IsNew())) break; assetBase = parent.Base; } return true; }
public override MergeResult Merge(Asset baseAsset, Asset newBase, List<AssetBase> newBaseParts) { var entityMerge = new EntityGroupAssetMerge((EntityGroupAssetBase)baseAsset, this, (EntityGroupAssetBase)newBase, newBaseParts); return entityMerge.Merge(); }
internal void OnAssetDirtyChanged(Asset asset) { Action<Asset> handler = AssetDirtyChanged; if (handler != null) handler(asset); }
internal void OnAssetDirtyChanged(Asset asset, bool oldValue, bool newValue) { if (asset == null) throw new ArgumentNullException(nameof(asset)); AssetDirtyChanged?.Invoke(asset, oldValue, newValue); }
/// <summary> /// Merge an asset with its base, and new base and parts into this instance. /// </summary> /// <param name="baseAsset">A copy of the base asset. Can be null if no base asset for newAsset</param> /// <param name="newBase">A copy of the next base asset. Can be null if no base asset for newAsset.</param> /// <param name="newBaseParts">A copy of the new base parts</param> /// <returns>The result of the merge</returns> /// <remarks>The this instance is not used by this method.</remarks> public virtual MergeResult Merge(Asset baseAsset, Asset newBase, List<AssetBasePart> newBaseParts) { var diff = new AssetDiff(baseAsset, this, newBase) { UseOverrideMode = true }; return AssetMerge.Merge(diff, AssetMergePolicies.MergePolicyAsset2AsNewBaseOfAsset1); }
internal void OnAssetDirtyChanged(Asset asset) { AssetDirtyChanged?.Invoke(asset); }
/// <summary> /// Reset the asset member to its base value. /// </summary> /// <param name="asset">The asset to reset</param> /// <param name="path">The path to the member to reset</param> /// <returns>The list of inheriting members that should to be recursively reset</returns> public IEnumerable<AssetMember> Reset(Asset asset, MemberPath path) { return Enumerable.Empty<AssetMember>(); }
/// <summary> /// Set the value of an the asset member. /// </summary> /// <param name="asset">The asset to set</param> /// <param name="path">The path to the member to set</param> /// <param name="action">The action to perform on the member</param> /// <param name="value">The value to set to the member</param> /// <returns>The list of inheriting members that should to be reset</returns> public IEnumerable<AssetMember> Set(Asset asset, MemberPath path, MemberPathAction action, object value) { return Enumerable.Empty<AssetMember>(); }
/// <summary> /// Seal the asset member. /// </summary> /// <param name="asset">The asset to seal</param> /// <param name="path">The path to the member to reset</param> /// <param name="isRecursive">Indicate if the seal is recursive or not</param> /// <returns>The list of inheriting members that should to be reset</returns> public IEnumerable<AssetMember> Seal(Asset asset, MemberPath path, bool isRecursive) { return Enumerable.Empty<AssetMember>(); }
private void OnAssetDirtyChanged(Asset asset, bool oldValue, bool newValue) { AssetDirtyChanged?.Invoke(asset, oldValue, newValue); }
private void Session_AssetDirtyChanged(Asset asset, bool oldValue, bool newValue) { // TODO: Don't update the source tracker while saving (cf AssetSourceTracker) NotifyAssetChanged(asset); }
/// <summary> /// Called when an asset changes. /// </summary> /// <param name="asset"></param> public abstract void NotifyAssetChanged(Asset asset);