Upload from upload_mods.ps1
This commit is contained in:
154
KFAttached/KFUtilAttached/ApexWeaponHudControllerBase.cs
Normal file
154
KFAttached/KFUtilAttached/ApexWeaponHudControllerBase.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class ApexWeaponHudControllerBase : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
protected ComputeShader cptShader;
|
||||
[SerializeField, Range(0, 100)]
|
||||
protected int interPerc;
|
||||
[SerializeField]
|
||||
protected TMP_Text boundText;
|
||||
[SerializeField]
|
||||
protected TMP_Text[] miscText;
|
||||
[SerializeField]
|
||||
protected Renderer screenRenderer;
|
||||
[SerializeField]
|
||||
protected Texture maskTexture;
|
||||
[SerializeField]
|
||||
protected int matIndex;
|
||||
[SerializeField, Range(0, 32)]
|
||||
protected int depth = 0;
|
||||
[SerializeField]
|
||||
protected RenderTextureFormat renderTextureFormat = RenderTextureFormat.Default;
|
||||
[SerializeField]
|
||||
protected FilterMode filterMode = FilterMode.Point;
|
||||
[SerializeField]
|
||||
protected UnityEngine.Experimental.Rendering.GraphicsFormat graphicsFormat = UnityEngine.Experimental.Rendering.GraphicsFormat.R8G8B8A8_SRGB;
|
||||
[SerializeField]
|
||||
private string kernalName;
|
||||
[SerializeField, Range(0, 1)]
|
||||
protected float xScale = 1, yScale = 1;
|
||||
protected int kernalIndex = -1;
|
||||
protected Material mat;
|
||||
protected int xGroupCount, yGroupCount;
|
||||
protected CustomRenderTexture targetTexture;
|
||||
protected static bool shaderEnabled;
|
||||
protected static bool stateChecked = false;
|
||||
//max count, elem count, inter pixels, map size
|
||||
protected readonly int[] dataArray = new int[3];
|
||||
protected Color color = Color.white;
|
||||
|
||||
protected static readonly int id_color = Shader.PropertyToID("color");
|
||||
protected static readonly int id_dataArray = Shader.PropertyToID("dataArray");
|
||||
protected static readonly int id_Mask = Shader.PropertyToID("Mask");
|
||||
protected static readonly int id_EmissionMap = Shader.PropertyToID("EmissionMap");
|
||||
protected static readonly int id_EmissionColor = Shader.PropertyToID("_EmissionColor");
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
if (!stateChecked)
|
||||
{
|
||||
shaderEnabled = SystemInfo.supportsComputeShaders && SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.Null && !Application.isBatchMode;
|
||||
stateChecked = true;
|
||||
Console.WriteLine("Compute shader support: " + shaderEnabled);
|
||||
}
|
||||
|
||||
dataArray[0] = 1;
|
||||
dataArray[1] = 0;
|
||||
dataArray[2] = interPerc;
|
||||
xGroupCount = (int)(maskTexture.width * xScale / 8);
|
||||
yGroupCount = (int)(maskTexture.height * yScale / 8);
|
||||
mat = screenRenderer.materials[matIndex];
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
if (!shaderEnabled)
|
||||
return;
|
||||
|
||||
if (targetTexture == null)
|
||||
{
|
||||
targetTexture = new CustomRenderTexture(maskTexture.width, maskTexture.height, renderTextureFormat)
|
||||
{
|
||||
enableRandomWrite = true,
|
||||
updateMode = CustomRenderTextureUpdateMode.OnDemand,
|
||||
depth = depth,
|
||||
useMipMap = false,
|
||||
autoGenerateMips = false,
|
||||
filterMode = filterMode,
|
||||
graphicsFormat = graphicsFormat,
|
||||
wrapMode = TextureWrapMode.Clamp
|
||||
};
|
||||
}
|
||||
|
||||
if (!targetTexture.IsCreated())
|
||||
targetTexture.Create();
|
||||
|
||||
mat.SetTexture("_EmissionMap", targetTexture);
|
||||
mat.SetColor(id_EmissionColor, Color.white);
|
||||
mat.EnableKeyword("_EMISSION");
|
||||
if (cptShader.HasKernel(kernalName))
|
||||
kernalIndex = cptShader.FindKernel(kernalName);
|
||||
}
|
||||
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual void OnDestroy()
|
||||
{
|
||||
OnDisable();
|
||||
if (targetTexture != null)
|
||||
targetTexture.Release();
|
||||
}
|
||||
|
||||
public virtual void SetColor(Color color)
|
||||
{
|
||||
if (boundText != null)
|
||||
boundText.color = color;
|
||||
if (miscText != null)
|
||||
foreach (var t in miscText)
|
||||
t.color = color;
|
||||
|
||||
this.color = color;
|
||||
//mat.SetColor(id_EmissionColor, color);
|
||||
if (CanDispatch())
|
||||
Dispatch(dataArray);
|
||||
}
|
||||
|
||||
public virtual void SetText(string text)
|
||||
{
|
||||
if (text.StartsWith("#"))
|
||||
{
|
||||
dataArray[0] = Mathf.Max(int.Parse(text.Substring(1)), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (boundText != null)
|
||||
boundText.SetText(text);
|
||||
dataArray[1] = int.Parse(text);
|
||||
}
|
||||
|
||||
if (CanDispatch())
|
||||
Dispatch(dataArray);
|
||||
}
|
||||
|
||||
protected virtual bool CanDispatch()
|
||||
{
|
||||
return shaderEnabled && kernalIndex >= 0;
|
||||
}
|
||||
|
||||
protected virtual void Dispatch(int[] dataArray)
|
||||
{
|
||||
cptShader.SetInts(id_dataArray, dataArray);
|
||||
cptShader.SetVector(id_color, color);
|
||||
cptShader.SetTexture(kernalIndex, id_Mask, maskTexture);
|
||||
cptShader.SetTexture(kernalIndex, id_EmissionMap, targetTexture, 0);
|
||||
cptShader.Dispatch(kernalIndex, xGroupCount, yGroupCount, 1);
|
||||
//targetTexture.GenerateMips();
|
||||
//targetTexture.Update();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0e18e2e55ec5014aad7a8808cd65efa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
KFAttached/KFUtilAttached/ChargeUpController.cs
Normal file
17
KFAttached/KFUtilAttached/ChargeUpController.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("KFAttachments/Weapon Display Controllers/Charge Up controller")]
|
||||
public class ChargeUpController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private WeaponLabelControllerChargeUp controller;
|
||||
private void OnEnable()
|
||||
{
|
||||
controller.StartChargeUp();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
controller.StopChargeUp();
|
||||
}
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/ChargeUpController.cs.meta
Normal file
11
KFAttached/KFUtilAttached/ChargeUpController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ccb8b18bea7ff8843a380b9e611799de
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
KFAttached/KFUtilAttached/MuzzlePositionBinding.cs
Normal file
33
KFAttached/KFUtilAttached/MuzzlePositionBinding.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("Muzzle Position Binding")]
|
||||
public class MuzzlePositionBinding : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Transform muzzleTrans;
|
||||
[SerializeField]
|
||||
private Vector3 newMuzzlePosition;
|
||||
private Vector3 initialPosition;
|
||||
private void Awake()
|
||||
{
|
||||
if (muzzleTrans)
|
||||
initialPosition = transform.localPosition;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (muzzleTrans)
|
||||
muzzleTrans.localPosition = newMuzzlePosition;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (muzzleTrans)
|
||||
muzzleTrans.localPosition = initialPosition;
|
||||
}
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/MuzzlePositionBinding.cs.meta
Normal file
11
KFAttached/KFUtilAttached/MuzzlePositionBinding.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d4b7e316af9faf4f9697b0d60f96793
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
69
KFAttached/KFUtilAttached/RigActivationBinding.cs
Normal file
69
KFAttached/KFUtilAttached/RigActivationBinding.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Animations.Rigging;
|
||||
|
||||
[AddComponentMenu("KFAttachments/Binding Helpers/Rig Activation Binding")]
|
||||
public class RigActivationBinding : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private RigLayer[] bindings;
|
||||
[SerializeField]
|
||||
private RigLayer[] inverseBindings;
|
||||
[SerializeField]
|
||||
private RigLayer[] enableOnDisable;
|
||||
[SerializeField]
|
||||
private RigLayer[] disableOnEnable;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
//Log.Out(gameObject.name + " OnEnable!");
|
||||
if (bindings != null)
|
||||
{
|
||||
foreach (RigLayer t in bindings)
|
||||
if (t != null)
|
||||
t.active = true;
|
||||
}
|
||||
if (inverseBindings != null)
|
||||
{
|
||||
foreach (RigLayer t in inverseBindings)
|
||||
{
|
||||
if (t != null)
|
||||
t.active = false;
|
||||
}
|
||||
}
|
||||
if (disableOnEnable != null)
|
||||
{
|
||||
foreach (RigLayer t in disableOnEnable)
|
||||
{
|
||||
if (t != null)
|
||||
t.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
//Log.Out(gameObject.name + " OnDisable!");
|
||||
if (bindings != null)
|
||||
{
|
||||
foreach (RigLayer t in bindings)
|
||||
if (t != null)
|
||||
t.active = false;
|
||||
}
|
||||
if (inverseBindings != null)
|
||||
{
|
||||
foreach (RigLayer t in inverseBindings)
|
||||
{
|
||||
if (t != null)
|
||||
t.active = true;
|
||||
}
|
||||
}
|
||||
if (enableOnDisable != null)
|
||||
{
|
||||
foreach (RigLayer t in enableOnDisable)
|
||||
{
|
||||
if (t != null)
|
||||
t.active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/RigActivationBinding.cs.meta
Normal file
11
KFAttached/KFUtilAttached/RigActivationBinding.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01778f8886cb5864c842e544741586b5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
141
KFAttached/KFUtilAttached/TransformActivationBinding.cs
Normal file
141
KFAttached/KFUtilAttached/TransformActivationBinding.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("KFAttachments/Binding Helpers/Transform Activation Binding")]
|
||||
public class TransformActivationBinding : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
internal GameObject[] bindings;
|
||||
[SerializeField]
|
||||
private GameObject[] inverseBindings;
|
||||
[SerializeField]
|
||||
private GameObject[] enableOnDisable;
|
||||
[SerializeField]
|
||||
private GameObject[] disableOnEnable;
|
||||
[SerializeField]
|
||||
private GameObject[] enableOnEnable;
|
||||
[SerializeField]
|
||||
private GameObject[] disableOnDisable;
|
||||
[SerializeField]
|
||||
private string[] animatorParamBindings;
|
||||
internal AnimationTargetsAbs targets;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
//Log.Out(gameObject.name + " OnEnable!");
|
||||
if (bindings != null)
|
||||
{
|
||||
foreach (GameObject t in bindings)
|
||||
{
|
||||
if (t)
|
||||
t.SetActive(true);
|
||||
}
|
||||
}
|
||||
if (inverseBindings != null)
|
||||
{
|
||||
foreach (GameObject t in inverseBindings)
|
||||
{
|
||||
if (t)
|
||||
t.SetActive(false);
|
||||
}
|
||||
}
|
||||
if (disableOnEnable != null)
|
||||
{
|
||||
foreach (GameObject t in disableOnEnable)
|
||||
{
|
||||
if (t)
|
||||
t.SetActive(false);
|
||||
}
|
||||
}
|
||||
if (enableOnEnable != null)
|
||||
{
|
||||
foreach (GameObject t in enableOnEnable)
|
||||
{
|
||||
if (t)
|
||||
t.SetActive(true);
|
||||
}
|
||||
}
|
||||
#if NotEditor
|
||||
ThreadManager.StartCoroutine(UpdateBool(true));
|
||||
#else
|
||||
UpdateBoolEditor(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
//Log.Out(gameObject.name + " OnDisable!");
|
||||
if (bindings != null)
|
||||
{
|
||||
foreach (GameObject t in bindings)
|
||||
if (t)
|
||||
t.SetActive(false);
|
||||
}
|
||||
if (inverseBindings != null)
|
||||
{
|
||||
foreach (GameObject t in inverseBindings)
|
||||
{
|
||||
if (t)
|
||||
t.SetActive(true);
|
||||
}
|
||||
}
|
||||
if (enableOnDisable != null)
|
||||
{
|
||||
foreach (GameObject t in enableOnDisable)
|
||||
{
|
||||
if (t)
|
||||
t.SetActive(true);
|
||||
}
|
||||
}
|
||||
if (disableOnDisable != null)
|
||||
{
|
||||
foreach (GameObject t in disableOnDisable)
|
||||
{
|
||||
if (t)
|
||||
t.SetActive(true);
|
||||
}
|
||||
}
|
||||
#if NotEditor
|
||||
ThreadManager.StartCoroutine(UpdateBool(false));
|
||||
#else
|
||||
UpdateBoolEditor(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if NotEditor
|
||||
internal IEnumerator UpdateBool(bool enabled)
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
if (animatorParamBindings != null && targets && targets.IsAnimationSet)
|
||||
{
|
||||
foreach (string str in animatorParamBindings)
|
||||
{
|
||||
if (str != null)
|
||||
{
|
||||
targets.GraphBuilder.Player.emodel.avatarController.UpdateBool(str, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
internal void UpdateBoolEditor(bool enabled)
|
||||
{
|
||||
if (animatorParamBindings != null && targets && targets.IsAnimationSet)
|
||||
{
|
||||
IAnimatorWrapper animator = targets.GraphBuilder.WeaponWrapper;
|
||||
if (animator == null || !animator.IsValid)
|
||||
{
|
||||
Log.Warning($"animator wrapper invalid!");
|
||||
return;
|
||||
}
|
||||
foreach (string str in animatorParamBindings)
|
||||
{
|
||||
if (str != null)
|
||||
{
|
||||
animator.SetBool(str, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/TransformActivationBinding.cs.meta
Normal file
11
KFAttached/KFUtilAttached/TransformActivationBinding.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f2bc8183b119f347a32259111b5d1f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
KFAttached/KFUtilAttached/WeaponColorController.cs
Normal file
16
KFAttached/KFUtilAttached/WeaponColorController.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("KFAttachments/Weapon Display Controllers/Weapon Color Controller")]
|
||||
public class WeaponColorController : WeaponColorControllerBase
|
||||
{
|
||||
[SerializeField]
|
||||
protected Renderer[] renderers;
|
||||
|
||||
public override bool setMaterialColor(int renderer_index, int material_index, int nameId, Color data)
|
||||
{
|
||||
if (renderers == null || renderers.Length <= renderer_index || !renderers[renderer_index].gameObject.activeInHierarchy || renderers[renderer_index].materials.Length <= material_index)
|
||||
return false;
|
||||
renderers[renderer_index].materials[material_index].SetColor(nameId, data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/WeaponColorController.cs.meta
Normal file
11
KFAttached/KFUtilAttached/WeaponColorController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcfafc95230152c408908547f15202e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
6
KFAttached/KFUtilAttached/WeaponColorControllerBase.cs
Normal file
6
KFAttached/KFUtilAttached/WeaponColorControllerBase.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class WeaponColorControllerBase : MonoBehaviour
|
||||
{
|
||||
public abstract bool setMaterialColor(int renderer_index, int material_index, int nameId, Color data);
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/WeaponColorControllerBase.cs.meta
Normal file
11
KFAttached/KFUtilAttached/WeaponColorControllerBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fe7c9577b97dd8448e83857ceac21db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
KFAttached/KFUtilAttached/WeaponDataController.cs
Normal file
24
KFAttached/KFUtilAttached/WeaponDataController.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class WeaponDataController : WeaponLabelControllerBase
|
||||
{
|
||||
[SerializeField]
|
||||
private WeaponDataHandlerBase[] handlers;
|
||||
public override bool setLabelColor(int index, Color color)
|
||||
{
|
||||
if (handlers == null || index >= handlers.Length || index < 0 || !handlers[index] || !handlers[index].gameObject.activeSelf)
|
||||
return false;
|
||||
|
||||
handlers[index]?.SetColor(color);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool setLabelText(int index, string data)
|
||||
{
|
||||
if (handlers == null || index >= handlers.Length || index < 0 || !handlers[index] || !handlers[index].gameObject.activeSelf)
|
||||
return false;
|
||||
|
||||
handlers[index]?.SetText(data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/WeaponDataController.cs.meta
Normal file
11
KFAttached/KFUtilAttached/WeaponDataController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f524ab568d21bf4d8f037fe0dee9c22
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
7
KFAttached/KFUtilAttached/WeaponDataHandlerBase.cs
Normal file
7
KFAttached/KFUtilAttached/WeaponDataHandlerBase.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class WeaponDataHandlerBase : MonoBehaviour
|
||||
{
|
||||
public abstract void SetColor(Color color);
|
||||
public abstract void SetText(string text);
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/WeaponDataHandlerBase.cs.meta
Normal file
11
KFAttached/KFUtilAttached/WeaponDataHandlerBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3657194e2634c8a4a8aea7e7becd0581
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
51
KFAttached/KFUtilAttached/WeaponDataHandlerCanvasMask.cs
Normal file
51
KFAttached/KFUtilAttached/WeaponDataHandlerCanvasMask.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class WeaponDataHandlerCanvasMask : WeaponDataHandlerBase
|
||||
{
|
||||
[SerializeField]
|
||||
protected RectMask2D mask;
|
||||
[SerializeField]
|
||||
protected Image image;
|
||||
|
||||
protected float maxVal = 1, curVal = 1;
|
||||
//protected bool updated = true;
|
||||
|
||||
//protected virtual void OnEnable()
|
||||
//{
|
||||
// LayoutRebuilder.MarkLayoutForRebuild(mask.rectTransform);
|
||||
//}
|
||||
|
||||
public override void SetColor(Color color)
|
||||
{
|
||||
image.color = color;
|
||||
}
|
||||
|
||||
public override void SetText(string text)
|
||||
{
|
||||
if (text.StartsWith("#"))
|
||||
{
|
||||
maxVal = Mathf.Max(float.Parse(text.Substring(1)), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
curVal = Mathf.Max(float.Parse(text), 0);
|
||||
}
|
||||
if (curVal > maxVal)
|
||||
maxVal = curVal;
|
||||
float perc = curVal / maxVal;
|
||||
Vector4 padding = mask.padding;
|
||||
padding.w = mask.rectTransform.rect.height * Mathf.Clamp01(1 - perc);
|
||||
mask.padding = padding;
|
||||
//updated = true;
|
||||
}
|
||||
|
||||
//protected virtual void LateUpdate()
|
||||
//{
|
||||
// if (updated)
|
||||
// {
|
||||
// LayoutRebuilder.ForceRebuildLayoutImmediate(mask.rectTransform);
|
||||
// updated = false;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 013c89968af9af042960a4fec49cd708
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
71
KFAttached/KFUtilAttached/WeaponDataHandlerIndicator.cs
Normal file
71
KFAttached/KFUtilAttached/WeaponDataHandlerIndicator.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class WeaponDataHandlerIndicator : WeaponDataHandlerCanvasMask
|
||||
{
|
||||
[SerializeField]
|
||||
protected RectTransform indicator;
|
||||
[SerializeField]
|
||||
protected float offset;
|
||||
[SerializeField, ColorUsage(true, true)]
|
||||
protected Color normalColor;
|
||||
[SerializeField, ColorUsage(true, true)]
|
||||
protected Color warningColor;
|
||||
|
||||
protected float level = 0;
|
||||
|
||||
//private void Start()
|
||||
//{
|
||||
// LayoutRebuilder.MarkLayoutForRebuild(indicator.parent.GetComponent<RectTransform>());
|
||||
//}
|
||||
|
||||
//protected override void OnEnable()
|
||||
//{
|
||||
// base.OnEnable();
|
||||
// LayoutRebuilder.MarkLayoutForRebuild(indicator.parent.GetComponent<RectTransform>());
|
||||
//}
|
||||
|
||||
public override void SetText(string text)
|
||||
{
|
||||
if (text.StartsWith("$"))
|
||||
{
|
||||
level = Mathf.Clamp01(float.Parse(text.Substring(1)) / maxVal);
|
||||
SetIndicatorPos();
|
||||
//updated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
float prevMax = maxVal;
|
||||
base.SetText(text);
|
||||
if (prevMax != maxVal)
|
||||
{
|
||||
level = prevMax * level / maxVal;
|
||||
SetIndicatorPos();
|
||||
}
|
||||
}
|
||||
//Log.Out($"Setting text {text} max {maxVal} cur {curVal} level {level} indicator position {indicator.position.y} mask position {mask.padding.w}");
|
||||
if (curVal / maxVal < level)
|
||||
{
|
||||
SetColor(warningColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetColor(normalColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetIndicatorPos()
|
||||
{
|
||||
Vector3 pos = indicator.anchoredPosition;
|
||||
pos.y = mask.rectTransform.rect.height * level + offset;
|
||||
indicator.anchoredPosition = pos;
|
||||
}
|
||||
|
||||
//protected override void LateUpdate()
|
||||
//{
|
||||
// if (updated)
|
||||
// {
|
||||
// LayoutRebuilder.ForceRebuildLayoutImmediate(indicator.parent.GetComponent<RectTransform>());
|
||||
// }
|
||||
// base.LateUpdate();
|
||||
//}
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/WeaponDataHandlerIndicator.cs.meta
Normal file
11
KFAttached/KFUtilAttached/WeaponDataHandlerIndicator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e993a995fe33f8742bd17bf4b5cae305
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
KFAttached/KFUtilAttached/WeaponDataHandlerTMP.cs
Normal file
17
KFAttached/KFUtilAttached/WeaponDataHandlerTMP.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class WeaponDataHandlerTMP : WeaponDataHandlerBase
|
||||
{
|
||||
[SerializeField]
|
||||
private TMP_Text label;
|
||||
public override void SetColor(Color color)
|
||||
{
|
||||
label.color = color;
|
||||
}
|
||||
|
||||
public override void SetText(string text)
|
||||
{
|
||||
label.SetText(text);
|
||||
}
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/WeaponDataHandlerTMP.cs.meta
Normal file
11
KFAttached/KFUtilAttached/WeaponDataHandlerTMP.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6ee4e451d350e048954e14bbccf6e6b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
KFAttached/KFUtilAttached/WeaponLabelController.cs
Normal file
24
KFAttached/KFUtilAttached/WeaponLabelController.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("KFAttachments/Weapon Display Controllers/Weapon Label Controller TextMesh")]
|
||||
public class WeaponLabelController : WeaponLabelControllerBase
|
||||
{
|
||||
[SerializeField]
|
||||
private TextMesh[] labels;
|
||||
|
||||
public override bool setLabelText(int index, string data)
|
||||
{
|
||||
if (labels == null || labels.Length <= index || !labels[index] || !labels[index].gameObject.activeSelf)
|
||||
return false;
|
||||
labels[index].text = data;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool setLabelColor(int index, Color color)
|
||||
{
|
||||
if (labels == null || labels.Length <= index || !labels[index] || !labels[index].gameObject.activeSelf)
|
||||
return false;
|
||||
labels[index].color = color;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/WeaponLabelController.cs.meta
Normal file
11
KFAttached/KFUtilAttached/WeaponLabelController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a067c009a9175a34db35886e48ce0129
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
7
KFAttached/KFUtilAttached/WeaponLabelControllerBase.cs
Normal file
7
KFAttached/KFUtilAttached/WeaponLabelControllerBase.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class WeaponLabelControllerBase : MonoBehaviour
|
||||
{
|
||||
public abstract bool setLabelText(int index, string data);
|
||||
public abstract bool setLabelColor(int index, Color color);
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/WeaponLabelControllerBase.cs.meta
Normal file
11
KFAttached/KFUtilAttached/WeaponLabelControllerBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc5547a942561564bb81d0ee893e4100
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
KFAttached/KFUtilAttached/WeaponLabelControllerBatch.cs
Normal file
36
KFAttached/KFUtilAttached/WeaponLabelControllerBatch.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace KFCommonUtilityLib.KFAttached.KFUtilAttached
|
||||
{
|
||||
public class WeaponLabelControllerBatch : WeaponLabelControllerBase
|
||||
{
|
||||
[SerializeField]
|
||||
private WeaponLabelControllerBase[] controllers;
|
||||
|
||||
public override bool setLabelColor(int index, Color color)
|
||||
{
|
||||
bool flag = false;
|
||||
foreach (var controller in controllers)
|
||||
{
|
||||
if (controller && controller.isActiveAndEnabled)
|
||||
{
|
||||
flag |= controller.setLabelColor(index, color);
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public override bool setLabelText(int index, string data)
|
||||
{
|
||||
bool flag = false;
|
||||
foreach (var controller in controllers)
|
||||
{
|
||||
if (controller && controller.isActiveAndEnabled)
|
||||
{
|
||||
flag |= controller.setLabelText(index, data);
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/WeaponLabelControllerBatch.cs.meta
Normal file
11
KFAttached/KFUtilAttached/WeaponLabelControllerBatch.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bdf1f2fdda9aae4c80dd6e0bdba81d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
61
KFAttached/KFUtilAttached/WeaponLabelControllerChargeUp.cs
Normal file
61
KFAttached/KFUtilAttached/WeaponLabelControllerChargeUp.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("KFAttachments/Weapon Display Controllers/Weapon Label Controller Charge Up")]
|
||||
public class WeaponLabelControllerChargeUp : ApexWeaponHudControllerBase
|
||||
{
|
||||
[SerializeField, Range(0.001f, 1f)]
|
||||
protected float tickTime;
|
||||
[SerializeField, Range(1, 1000)]
|
||||
protected int updateTicks = 1;
|
||||
protected Coroutine curChargeProc;
|
||||
protected bool isChargeRunning = false;
|
||||
internal void StartChargeUp()
|
||||
{
|
||||
if (shaderEnabled && (curChargeProc == null || !isChargeRunning))
|
||||
curChargeProc = StartCoroutine(ChargeUp());
|
||||
}
|
||||
|
||||
internal void StopChargeUp()
|
||||
{
|
||||
if (shaderEnabled && curChargeProc != null)
|
||||
{
|
||||
StopCoroutine(curChargeProc);
|
||||
curChargeProc = null;
|
||||
isChargeRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
StopChargeUp();
|
||||
}
|
||||
|
||||
private IEnumerator ChargeUp()
|
||||
{
|
||||
isChargeRunning = true;
|
||||
float chargeLeap = (float)dataArray[0] / updateTicks;
|
||||
int[] chargeArray = new int[4];
|
||||
float curChargeCount = 0;
|
||||
dataArray.CopyTo(chargeArray, 0);
|
||||
int max = dataArray[1];
|
||||
chargeArray[1] = (int)curChargeCount;
|
||||
while (chargeArray[1] <= max)
|
||||
{
|
||||
Dispatch(chargeArray);
|
||||
if (chargeArray[1] == max)
|
||||
break;
|
||||
yield return new WaitForSecondsRealtime(tickTime);
|
||||
max = dataArray[1];
|
||||
curChargeCount += chargeLeap;
|
||||
chargeArray[1] = Mathf.Min((int)curChargeCount, max);
|
||||
}
|
||||
isChargeRunning = false;
|
||||
yield break;
|
||||
}
|
||||
|
||||
protected override bool CanDispatch()
|
||||
{
|
||||
return base.CanDispatch() && !isChargeRunning;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24181b5d7224798438ea0bb73892de70
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
KFAttached/KFUtilAttached/WeaponLabelControllerDevotion.cs
Normal file
25
KFAttached/KFUtilAttached/WeaponLabelControllerDevotion.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("KFAttachments/Weapon Display Controllers/Weapon Label Controller Devotion")]
|
||||
public class WeaponLabelControllerDevotion : WeaponLabelControllerBase
|
||||
{
|
||||
[SerializeField]
|
||||
private ApexWeaponHudControllerBase[] controllers;
|
||||
public override bool setLabelColor(int index, Color color)
|
||||
{
|
||||
if (controllers == null || index >= controllers.Length || !controllers[index] || !controllers[index].gameObject.activeSelf)
|
||||
return false;
|
||||
|
||||
controllers[index].SetColor(color);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool setLabelText(int index, string data)
|
||||
{
|
||||
if (controllers == null || index >= controllers.Length || !controllers[index] || !controllers[index].gameObject.activeSelf)
|
||||
return false;
|
||||
|
||||
controllers[index].SetText(data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bc6e113f61659f489e67db4beb49b7d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
KFAttached/KFUtilAttached/WeaponTextProController.cs
Normal file
25
KFAttached/KFUtilAttached/WeaponTextProController.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("KFAttachments/Weapon Display Controllers/Weapon Text Controller TMP")]
|
||||
public class WeaponTextProController : WeaponLabelControllerBase
|
||||
{
|
||||
[SerializeField]
|
||||
private TMP_Text[] labels;
|
||||
|
||||
public override bool setLabelText(int index, string data)
|
||||
{
|
||||
if (labels == null || labels.Length <= index || !labels[index] || !labels[index].gameObject.activeSelf)
|
||||
return false;
|
||||
labels[index].SetText(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool setLabelColor(int index, Color color)
|
||||
{
|
||||
if (labels == null || labels.Length <= index || !labels[index] || !labels[index].gameObject.activeSelf)
|
||||
return false;
|
||||
labels[index].color = color;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
11
KFAttached/KFUtilAttached/WeaponTextProController.cs.meta
Normal file
11
KFAttached/KFUtilAttached/WeaponTextProController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93439c08074a2ef42b5c4da798001216
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user