Skip to content

Commit

Permalink
added login widget in debug menu & removed forced login from dynamic …
Browse files Browse the repository at this point in the history
…scene loader
  • Loading branch information
lorux0 committed Dec 20, 2023
1 parent 3e60f70 commit 20f043e
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 8 deletions.
1 change: 0 additions & 1 deletion Explorer/Assets/DCL/PluginSystem/Global/ProfilePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Cysharp.Threading.Tasks;
using DCL.Profiles;
using ECS.StreamableLoading.Cache;
using System;
using System.Threading;
using Utility.Multithreading;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Arch.SystemGroups;
using Cysharp.Threading.Tasks;
using DCL.DebugUtilities;
using DCL.Web3Authentication;
using System.Threading;

namespace DCL.PluginSystem.Global
{
public class Web3AuthenticationPlugin : IDCLGlobalPlugin
{
private readonly IWeb3Authenticator web3Authenticator;
private readonly IDebugContainerBuilder debugContainerBuilder;

private CancellationTokenSource? cancellationTokenSource;

public Web3AuthenticationPlugin(IWeb3Authenticator web3Authenticator,
IDebugContainerBuilder debugContainerBuilder)
{
this.web3Authenticator = web3Authenticator;
this.debugContainerBuilder = debugContainerBuilder;
}

public void Dispose() { }

public UniTask Initialize(IPluginSettingsContainer container, CancellationToken ct) =>
UniTask.CompletedTask;

public void InjectToWorld(ref ArchSystemsWorldBuilder<Arch.Core.World> builder, in GlobalPluginArguments arguments)
{
debugContainerBuilder.AddWidget("Web3 Authentication")
.AddSingleButton("Login", Login);
}

private void Login()
{
cancellationTokenSource?.Cancel();
cancellationTokenSource?.Dispose();
cancellationTokenSource = new CancellationTokenSource();
web3Authenticator.LoginAsync(cancellationTokenSource.Token).Forget();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Explorer/Assets/DCL/PluginSystem/csc.rsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-nullable:enable
3 changes: 3 additions & 0 deletions Explorer/Assets/DCL/PluginSystem/csc.rsp.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Explorer/Assets/Scripts/Global/Dynamic/DynamicSceneLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ private async UniTask InitializationFlowAsync(CancellationToken ct)
try
{
web3Authenticator = new DappWeb3Authenticator(new UnityAppWebBrowser());
IWeb3Identity web3Identity = await web3Authenticator.LoginAsync(ct);

// First load the common global plugin
bool isLoaded;
Expand Down Expand Up @@ -125,7 +124,7 @@ void OnPluginInitialized<TPluginInterface>((TPluginInterface plugin, bool succes
}

globalWorld = dynamicWorldContainer.GlobalWorldFactory.Create(sceneSharedContainer.SceneFactory,
dynamicWorldContainer.EmptyScenesWorldFactory, staticContainer.CharacterObject, web3Identity);
dynamicWorldContainer.EmptyScenesWorldFactory, staticContainer.CharacterObject);

dynamicWorldContainer.DebugContainer.Builder.Build(debugUiRoot);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using CommunicationData.URLHelpers;
using Cysharp.Threading.Tasks;
using DCL.AvatarRendering.AvatarShape.Systems;
using DCL.AvatarRendering.Wearables;
using DCL.DebugUtilities;
using DCL.ParcelsService;
Expand Down Expand Up @@ -95,6 +94,7 @@ public void Dispose()
new MinimapPlugin(staticContainer.AssetsProvisioner, mvcManager, mapRendererContainer, placesAPIService),
new ExplorePanelPlugin(staticContainer.AssetsProvisioner, mvcManager, mapRendererContainer, placesAPIService, parcelServiceContainer.TeleportController),
new WebRequestsPlugin(staticContainer.WebRequestsContainer.AnalyticsContainer, debugBuilder),
new Web3AuthenticationPlugin(web3Authenticator, debugBuilder),
};

globalPlugins.AddRange(staticContainer.SharedPlugins);
Expand Down
5 changes: 1 addition & 4 deletions Explorer/Assets/Scripts/Global/Dynamic/GlobalWorldFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using DCL.Systems;
using DCL.Time;
using DCL.Time.Systems;
using DCL.Web3Authentication;
using DCL.WebRequests;
using ECS;
using ECS.Groups;
Expand Down Expand Up @@ -94,8 +93,7 @@ public GlobalWorldFactory(in StaticContainer staticContainer,
physicsTickProvider = staticContainer.PhysicsTickProvider;
}

public GlobalWorld Create(ISceneFactory sceneFactory, IEmptyScenesWorldFactory emptyScenesWorldFactory, ICharacterObject characterObject,
IWeb3Identity web3Identity)
public GlobalWorld Create(ISceneFactory sceneFactory, IEmptyScenesWorldFactory emptyScenesWorldFactory, ICharacterObject characterObject)
{
var world = World.Create();

Expand All @@ -114,7 +112,6 @@ public GlobalWorld Create(ISceneFactory sceneFactory, IEmptyScenesWorldFactory e
new TransformComponent { Transform = characterObject.Transform },
new PBAvatarShape
{
Id = web3Identity.Address,
BodyShape = BodyShape.MALE,
Wearables = { WearablesConstants.DefaultWearables.GetDefaultWearablesForBodyShape(BodyShape.MALE) },
Name = "Player",
Expand Down

0 comments on commit 20f043e

Please sign in to comment.