Beispiel #1
0
        public override async UniTask ExecuteAsync(CancellationToken cancellationToken = default)
        {
            await base.ExecuteAsync(cancellationToken);

            if (cancellationToken.CancelASAP)
            {
                return;
            }

            if (!Assigned(AvatarTexturePath)) // Check if we can map current appearance to an avatar texture path.
            {
                var avatarPath = $"{AssignedId}/{AssignedAppearance}";
                if (ActorManager.AvatarTextureExists(avatarPath) && ActorManager.GetAvatarTexturePathFor(AssignedId) != avatarPath)
                {
                    ActorManager.SetAvatarTexturePathFor(AssignedId, avatarPath);
                }
                else // Check if a default avatar texture for the character exists and assign if it does.
                {
                    var defaultAvatarPath = $"{AssignedId}/Default";
                    if (ActorManager.AvatarTextureExists(defaultAvatarPath) && ActorManager.GetAvatarTexturePathFor(AssignedId) != defaultAvatarPath)
                    {
                        ActorManager.SetAvatarTexturePathFor(AssignedId, defaultAvatarPath);
                    }
                }
            }
            else // User provided specific avatar texture path, assigning it.
            {
                if (AvatarTexturePath?.Value.EqualsFastIgnoreCase("none") ?? false)
                {
                    ActorManager.RemoveAvatarTextureFor(AssignedId);
                }
                else
                {
                    ActorManager.SetAvatarTexturePathFor(AssignedId, AvatarTexturePath);
                }
            }
        }