Skip to content

Commit

Permalink
so much more todo
Browse files Browse the repository at this point in the history
  • Loading branch information
dooly123 committed Feb 25, 2025
1 parent 6b9d7c1 commit 90bb5df
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 152 deletions.
80 changes: 39 additions & 41 deletions Basis/Packages/com.basis.framework/Avatar/BasisAvatarFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,79 +13,77 @@ namespace Basis.Scripts.Avatar
{
public static class BasisAvatarFactory
{
public static BasisLoadableBundle LoadingAvatar = new BasisLoadableBundle()
{
BasisBundleConnector = new BasisBundleConnector()
{
BasisBundleDescription = new BasisBundleDescription()
{
AssetBundleDescription = "LoadingAvatar",
AssetBundleName = "LoadingAvatar"
},
BasisBundleGenerated = new BasisBundleGenerated[]
public static BasisLoadableBundle LoadingAvatar = new BasisLoadableBundle()
{
BasisBundleConnector = new BasisBundleConnector()
{
BasisBundleDescription = new BasisBundleDescription()
{
AssetBundleDescription = BasisLocalPlayer.DefaultAvatar,
AssetBundleName = BasisLocalPlayer.DefaultAvatar
},
BasisBundleGenerated = new BasisBundleGenerated[]
{
new BasisBundleGenerated("N/A","Gameobject",string.Empty,0,true,string.Empty,string.Empty,true,string.Empty)
},
},
UnlockPassword = "N/A",
BasisRemoteBundleEncrypted = new BasisRemoteEncyptedBundle()
{
BundleURL = "LoadingAvatar",
IsLocal = true,
ConnectorURL = "LoadingAvatar",
},
BasisLocalEncryptedBundle = new BasisStoredEncryptedBundle()
{
LocalBundleFile = "LoadingAvatar",
LocalConnectorPath = "LoadingAvatar",
},
};
},
UnlockPassword = "N/A",
BasisRemoteBundleEncrypted = new BasisRemoteEncyptedBundle()
{
ConnectorURL = BasisLocalPlayer.DefaultAvatar,
IsLocal = true,
},
BasisLocalEncryptedBundle = new BasisStoredEncryptedBundle()
{
LocalConnectorPath = BasisLocalPlayer.DefaultAvatar,
},
};
public static async Task LoadAvatarLocal(BasisLocalPlayer Player,byte Mode, BasisLoadableBundle BasisLoadableBundle)
{
if (string.IsNullOrEmpty(BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL))
if (string.IsNullOrEmpty(BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL))
{
BasisDebug.LogError("Avatar Address was empty or null! Falling back to loading avatar.");
await LoadAvatarAfterError(Player);
return;
}

DeleteLastAvatar(Player, false);
LoadLoadingAvatar(Player, LoadingAvatar.BasisLocalEncryptedBundle.LocalBundleFile);
LoadLoadingAvatar(Player, LoadingAvatar.BasisLocalEncryptedBundle.LocalConnectorPath);
try
{
GameObject Output = null;
switch (Mode)
{
case 0://download
BasisDebug.Log("Requested Avatar was a AssetBundle Avatar " + BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL, BasisDebug.LogTag.Avatar);
BasisDebug.Log("Requested Avatar was a AssetBundle Avatar " + BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, BasisDebug.LogTag.Avatar);
Output = await DownloadAndLoadAvatar(BasisLoadableBundle, Player);
break;
case 1://localload
BasisDebug.Log("Requested Avatar was a Addressable Avatar " + BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL, BasisDebug.LogTag.Avatar);
BasisDebug.Log("Requested Avatar was a Addressable Avatar " + BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, BasisDebug.LogTag.Avatar);
var Para = new UnityEngine.ResourceManagement.ResourceProviders.InstantiationParameters(Player.transform.position, Quaternion.identity, null);
ChecksRequired Required = new ChecksRequired
{
UseContentRemoval = true,
DisableAnimatorEvents = false
};
(List<GameObject> GameObjects, AddressableGenericResource resource) = await AddressableResourceProcess.LoadAsGameObjectsAsync(BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL, Para, Required);
(List<GameObject> GameObjects, AddressableGenericResource resource) = await AddressableResourceProcess.LoadAsGameObjectsAsync(BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, Para, Required);

if (GameObjects.Count > 0)
{
BasisDebug.Log("Found Avatar for " + BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL, BasisDebug.LogTag.Avatar);
BasisDebug.Log("Found Avatar for " + BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, BasisDebug.LogTag.Avatar);
Output = GameObjects[0];
}
else
{
BasisDebug.LogError("Cant Find Local Avatar for " + BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL, BasisDebug.LogTag.Avatar);
BasisDebug.LogError("Cant Find Local Avatar for " + BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, BasisDebug.LogTag.Avatar);
}
break;
default:
BasisDebug.Log("Using Default, this means index was out of acceptable range! " + BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL, BasisDebug.LogTag.Avatar);
BasisDebug.Log("Using Default, this means index was out of acceptable range! " + BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, BasisDebug.LogTag.Avatar);
Output = await DownloadAndLoadAvatar(BasisLoadableBundle, Player);
break;
}
Player.AvatarMetaData = BasisBundleConversionNetwork.ConvertFromNetwork(new AvatarNetworkLoadInformation() { AvatarBundleUrl = BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL, AvatarMetaUrl = BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, UnlockPassword = BasisLoadableBundle.UnlockPassword });
Player.AvatarMetaData = BasisBundleConversionNetwork.ConvertFromNetwork(new AvatarNetworkLoadInformation() { URL = BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, UnlockPassword = BasisLoadableBundle.UnlockPassword });
Player.AvatarLoadMode = Mode;

InitializePlayerAvatar(Player, Output);
Expand All @@ -101,15 +99,15 @@ public static async Task LoadAvatarLocal(BasisLocalPlayer Player,byte Mode, Basi

public static async Task LoadAvatarRemote(BasisRemotePlayer Player,byte Mode, BasisLoadableBundle BasisLoadableBundle)
{
if (string.IsNullOrEmpty(BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL))
if (string.IsNullOrEmpty(BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL))
{
BasisDebug.LogError("Avatar Address was empty or null! Falling back to loading avatar.");
await LoadAvatarAfterError(Player);
return;
}

DeleteLastAvatar(Player,false);
LoadLoadingAvatar(Player, LoadingAvatar.BasisLocalEncryptedBundle.LocalBundleFile);
LoadLoadingAvatar(Player, LoadingAvatar.BasisLocalEncryptedBundle.LocalConnectorPath);
try
{
GameObject Output = null;
Expand All @@ -119,30 +117,30 @@ public static async Task LoadAvatarRemote(BasisRemotePlayer Player,byte Mode, Ba
Output = await DownloadAndLoadAvatar(BasisLoadableBundle, Player);
break;
case 1://localload
BasisDebug.Log("Requested Avatar was a Addressable Avatar " + BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL, BasisDebug.LogTag.Avatar);
BasisDebug.Log("Requested Avatar was a Addressable Avatar " + BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, BasisDebug.LogTag.Avatar);
ChecksRequired Required = new ChecksRequired
{
UseContentRemoval = false,
DisableAnimatorEvents = false
};
var Para = new UnityEngine.ResourceManagement.ResourceProviders.InstantiationParameters(Player.transform.position, Quaternion.identity, null);
(List<GameObject> GameObjects, AddressableGenericResource resource) = await AddressableResourceProcess.LoadAsGameObjectsAsync(BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL, Para, Required);
(List<GameObject> GameObjects, AddressableGenericResource resource) = await AddressableResourceProcess.LoadAsGameObjectsAsync(BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, Para, Required);

if (GameObjects.Count > 0)
{
BasisDebug.Log("Found Avatar for " + BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL, BasisDebug.LogTag.Avatar);
BasisDebug.Log("Found Avatar for " + BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, BasisDebug.LogTag.Avatar);
Output = GameObjects[0];
}
else
{
BasisDebug.LogError("Cant Find Local Avatar for " + BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL, BasisDebug.LogTag.Avatar);
BasisDebug.LogError("Cant Find Local Avatar for " + BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, BasisDebug.LogTag.Avatar);
}
break;
default:
Output = await DownloadAndLoadAvatar(BasisLoadableBundle, Player);
break;
}
Player.AvatarMetaData = BasisBundleConversionNetwork.ConvertFromNetwork(new AvatarNetworkLoadInformation() { AvatarBundleUrl = BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL, AvatarMetaUrl = BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, UnlockPassword = BasisLoadableBundle.UnlockPassword });
Player.AvatarMetaData = BasisBundleConversionNetwork.ConvertFromNetwork(new AvatarNetworkLoadInformation() { URL = BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, UnlockPassword = BasisLoadableBundle.UnlockPassword });
Player.AvatarLoadMode = Mode;

InitializePlayerAvatar(Player, Output);
Expand Down Expand Up @@ -204,7 +202,7 @@ public static async Task LoadAvatarAfterError(BasisPlayer Player)
DisableAnimatorEvents = false
};
var Para = new UnityEngine.ResourceManagement.ResourceProviders.InstantiationParameters(Player.transform.position, Quaternion.identity, null);
(List<GameObject> GameObjects, AddressableGenericResource resource) = await AddressableResourceProcess.LoadAsGameObjectsAsync(LoadingAvatar.BasisLocalEncryptedBundle.LocalBundleFile, Para, Required);
(List<GameObject> GameObjects, AddressableGenericResource resource) = await AddressableResourceProcess.LoadAsGameObjectsAsync(LoadingAvatar.BasisLocalEncryptedBundle.LocalConnectorPath, Para, Required);

if (GameObjects.Count != 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ public static BasisLoadableBundle ConvertFromNetwork(AvatarNetworkLoadInformatio
{
BasisRemoteBundleEncrypted = new BasisRemoteEncyptedBundle
{
ConnectorURL = AvatarNetworkLoadInformation.AvatarMetaUrl,
BundleURL = AvatarNetworkLoadInformation.AvatarBundleUrl
ConnectorURL = AvatarNetworkLoadInformation.URL,
},
BasisBundleConnector = new BasisBundleConnector(),
BasisLocalEncryptedBundle = new BasisStoredEncryptedBundle(),
Expand All @@ -24,8 +23,7 @@ public static AvatarNetworkLoadInformation ConvertToNetwork(BasisLoadableBundle
{
AvatarNetworkLoadInformation AvatarNetworkLoadInformation = new AvatarNetworkLoadInformation
{
AvatarMetaUrl = BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL,
AvatarBundleUrl = BasisLoadableBundle.BasisRemoteBundleEncrypted.BundleURL,
URL = BasisLoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL,
UnlockPassword = BasisLoadableBundle.UnlockPassword
};
return AvatarNetworkLoadInformation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static async Task<bool> DownloadStoreMetaAndBundle(BasisTrackedBundleWrap
}

// Step 4: Download the bundle file
string bundleUrl = BasisTrackedBundleWrapper.LoadableBundle.BasisRemoteBundleEncrypted.BundleURL;
string bundleUrl = BasisTrackedBundleWrapper.LoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL;

if (string.IsNullOrEmpty(bundleUrl))
{
Expand Down Expand Up @@ -143,7 +143,7 @@ public static async Task<bool> DownloadStoreMetaAndBundle(BasisTrackedBundleWrap
}

BasisDebug.Log($"Successfully downloaded bundle file for {bundleUrl}");
BasisTrackedBundleWrapper.LoadableBundle.BasisLocalEncryptedBundle.LocalBundleFile = FilePathBundle;
// BasisTrackedBundleWrapper.LoadableBundle.BasisLocalEncryptedBundle.LocalConnectorPath = FilePathBundle;
BasisTrackedBundleWrapper.LoadableBundle.BasisLocalEncryptedBundle.LocalConnectorPath = FilePathMeta;
return true;
}
Expand Down Expand Up @@ -303,7 +303,7 @@ public static async Task ProcessOnDiscMetaDataAsync(BasisTrackedBundleWrapper ba
}

// Set local paths
BasisDebug.Log($"Setting local bundle file: {BasisStoredEncyptedBundle.LocalBundleFile} Setting local meta file: {BasisStoredEncyptedBundle.LocalConnectorPath}");
BasisDebug.Log($"Setting local bundle file: {BasisStoredEncyptedBundle.LocalConnectorPath} Setting local meta file: {BasisStoredEncyptedBundle.LocalConnectorPath}");

basisTrackedBundleWrapper.LoadableBundle.BasisLocalEncryptedBundle = BasisStoredEncyptedBundle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@ private static async Task<GameObject> HandleFirstBundleLoad(BasisLoadableBundle
public static async Task HandleBundleAndMetaLoading(BasisTrackedBundleWrapper wrapper, BasisProgressReport report, CancellationToken cancellationToken)
{
bool IsMetaOnDisc = IsMetaDataOnDisc(wrapper.LoadableBundle.BasisRemoteBundleEncrypted.ConnectorURL, out OnDiscInformation MetaInfo);
/*here LD
if(MetaInfo.StoredLocal.LocalConnectorPath)
{
}
bool IsBundleOnDisc = IsBundleDataOnDisc(wrapper.LoadableBundle.BasisRemoteBundleEncrypted.BundleURL, out OnDiscInformation BundleInfo);

*/
// bool IsBundleOnDisc = IsBundleDataOnDisc(wrapper.LoadableBundle.BasisRemoteBundleEncrypted.BundleURL, out OnDiscInformation BundleInfo);
bool IsBundleOnDisc = false;
if (IsMetaOnDisc)
{
BasisDebug.Log("ProcessOnDiscMetaDataAsync", BasisDebug.LogTag.Event);
Expand Down Expand Up @@ -215,7 +217,7 @@ public static async Task HandleBundleAndMetaLoading(BasisTrackedBundleWrapper wr

AssetBundleCreateRequest bundleRequest = await BasisEncryptionToData.GenerateBundleFromFile(
wrapper.LoadableBundle.UnlockPassword,
wrapper.LoadableBundle.BasisLocalEncryptedBundle.LocalBundleFile,
wrapper.LoadableBundle.BasisLocalEncryptedBundle.LocalConnectorPath,
Generated.AssetBundleCRC,
report
);
Expand Down Expand Up @@ -296,10 +298,10 @@ public static bool IsBundleDataOnDisc(string BundleURL, out OnDiscInformation in
{
foreach (var discInfo in OnDiscData.Values)
{
if (discInfo.StoredRemote.BundleURL == BundleURL)
if (discInfo.StoredRemote.ConnectorURL == BundleURL)
{
info = discInfo;
if (File.Exists(discInfo.StoredLocal.LocalBundleFile))
if (File.Exists(discInfo.StoredLocal.LocalConnectorPath))
{
return true;
}
Expand Down Expand Up @@ -418,12 +420,14 @@ private static void CleanupFiles(BasisStoredEncryptedBundle bundle)
{
File.Delete(bundle.LocalConnectorPath);
}
/* here LD
BasisEncryptionToData.GenerateBundleFromFile(, bundle.LocalConnectorPath,bundle);
bundle.LocalConnectorPath
if (File.Exists(bundle.LocalBundleFile))
{
File.Delete(bundle.LocalBundleFile);
}
*/
}
}
Loading

0 comments on commit 90bb5df

Please sign in to comment.