1
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BITFALL.Cosmetic;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Entities.Cosmetic
|
||||
{
|
||||
public sealed class CosmeticTextureBehaviour : EntityBehavior
|
||||
{
|
||||
[SerializeField] private Renderer[] renderers;
|
||||
[SerializeField] private Renderer[] steveRenderers;
|
||||
[SerializeField] private Renderer[] alexRenderers;
|
||||
[Inject(true)] private ICosmeticService _cosmeticService;
|
||||
|
||||
public override void OnAwake()
|
||||
{
|
||||
if (_cosmeticService is not null)
|
||||
_cosmeticService.OnCosmeticsChanged += OnCosmeticsChanged;
|
||||
}
|
||||
|
||||
private void OnCosmeticsChanged()
|
||||
{
|
||||
foreach (var cosmetic in _cosmeticService.Cosmetics)
|
||||
{
|
||||
foreach (var content in cosmetic.Contents.OfType<CosmeticTextureContent>())
|
||||
{
|
||||
foreach (var _renderer in renderers)
|
||||
{
|
||||
if (content.Texture is Texture2D texture2D)
|
||||
{
|
||||
var multiple = texture2D.width / 64;
|
||||
var color = texture2D.GetPixels32()[17 * multiple * texture2D.width + 51* multiple];
|
||||
var isSteve = color.a is 1;
|
||||
Debug.Log(color);
|
||||
steveRenderers.ForEach(x => x.enabled = isSteve);
|
||||
alexRenderers.ForEach(x => x.enabled = !isSteve);
|
||||
}
|
||||
_renderer.material.mainTexture = content.Texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user