Upload from upload_mods.ps1
This commit is contained in:
49
KFAttached/Misc/AimReference.cs
Normal file
49
KFAttached/Misc/AimReference.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class AimReference : MonoBehaviour
|
||||
{
|
||||
[NonSerialized]
|
||||
public Vector3 positionOffset;
|
||||
[NonSerialized]
|
||||
public Quaternion rotationOffset;
|
||||
[NonSerialized]
|
||||
public AimReferenceGroup group;
|
||||
[NonSerialized]
|
||||
public int index = -1;
|
||||
[NonSerialized]
|
||||
public ScopeBase scopeBase;
|
||||
[SerializeField]
|
||||
private GameObject scopeBindingObject;
|
||||
public bool asReference;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!group)
|
||||
{
|
||||
return;
|
||||
}
|
||||
scopeBase = GetComponentInParent<ScopeBase>();
|
||||
Transform refTrans = scopeBase ? scopeBase.transform : transform.parent;
|
||||
rotationOffset = Quaternion.Inverse(refTrans.rotation) * transform.rotation;
|
||||
positionOffset = refTrans.InverseTransformDirection(transform.position - refTrans.position);
|
||||
group.UpdateEnableStates();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (!group)
|
||||
{
|
||||
return;
|
||||
}
|
||||
group.UpdateEnableStates();
|
||||
}
|
||||
|
||||
public void UpdateEnableState(bool state)
|
||||
{
|
||||
if (scopeBindingObject)
|
||||
{
|
||||
scopeBindingObject.SetActive(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user