Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DFUVR/DFUVR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<Compile Include="MenuTransition.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Sheath.cs" />
<Compile Include="SheathController.cs" />
<Compile Include="SheathCollision.cs" />
<Compile Include="SlotCollision.cs" />
<Compile Include="Slots.cs" />
Expand All @@ -130,6 +130,7 @@
<Compile Include="TriggerProvider.cs" />
<Compile Include="Var.cs" />
<Compile Include="WatchController.cs" />
<Compile Include="Weapon.cs" />
<Compile Include="WeaponCollision.cs" />
<Compile Include="WinAPIMonitor.cs" />
</ItemGroup>
Expand Down
51 changes: 45 additions & 6 deletions DFUVR/HandLabel.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DaggerfallWorkshop.Game.Items;
using UnityEngine;
using UnityEngine.XR;

namespace DFUVR
{
public class HandLabel : MonoBehaviour
{
public bool rightHand;
public bool isMainHand;
public XRNode xrHandNode;
public InputDevice inputDevice;
public KeyCode grabButton;
public GameObject freeHandObject;

public DaggerfallUnityItem weaponItem;
public GameObject weaponObject;

public void Init(bool isMainHand, XRNode xrHandNode, InputDevice inputDevice, KeyCode grabButton)
{
this.isMainHand = isMainHand;
this.xrHandNode = xrHandNode;
this.inputDevice = inputDevice;
this.grabButton = grabButton;
}

void Start()
{
Plugin.LoggerInstance.LogInfo("added Handlabel");
}

public void RemoveHeldWeapon()
{
SetWeapon(null, null, null);
}

public void SetWeapon(DaggerfallUnityItem weaponItem, GameObject weaponObject, HandObject handObject)
{
if (this.weaponObject != null)
Destroy(this.weaponObject);

this.weaponObject = weaponObject;
this.weaponItem = weaponItem;

if (weaponObject != null)
{
weaponObject.transform.SetParent(gameObject.transform);

if (handObject != null)
{
weaponObject.transform.localPosition = handObject.unsheatedPositionOffset;
weaponObject.transform.localRotation = handObject.unsheatedRotationOffset;
}

weaponObject.SetActive(true);
}
}
}
}
6 changes: 3 additions & 3 deletions DFUVR/HandObjectLoadList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ private HandObjectLoadList(string assetBundlePath, Action<GameObject> postAction
new HandObjectLoadList("AssetBundles/weapons", null, typeof(WeaponCollision), typeof(MeshCollider), new[] { WeaponTypes.LongBlade, WeaponTypes.LongBlade_Magic }, "Sword", Vector3.zero, Quaternion.identity, Vector3.zero, Quaternion.identity, true, true, true),
new HandObjectLoadList("AssetBundles/weapons", null, typeof(WeaponCollision), typeof(MeshCollider), new[] { WeaponTypes.Dagger, WeaponTypes.Dagger_Magic }, "Steel_Dagger_512", Vector3.zero, Quaternion.Euler(0, 90, 90), Vector3.zero, Quaternion.Euler(0, 90, 90), true),
new HandObjectLoadList("AssetBundles/weapons", null, typeof(WeaponCollision), typeof(MeshCollider), new[] { WeaponTypes.Battleaxe, WeaponTypes.Battleaxe_Magic }, "MM_Axe_01_01_lod2", Vector3.zero, Quaternion.Euler(0, -90, 90), Vector3.zero, Quaternion.Euler(0, 180, 180)),
new HandObjectLoadList("AssetBundles/weapons", null, null, null, new[] { WeaponTypes.None }, "Sheath", Vector3.zero, Quaternion.identity, Vector3.zero, Quaternion.identity, true),
new HandObjectLoadList("AssetBundles/weapons", null, typeof(WeaponCollision), typeof(MeshCollider), new[] { WeaponTypes.Mace, WeaponTypes.Mace_Magic }, "mace", new Vector3(0, 0, 0.1f), Quaternion.Euler(90, 0, 0), new Vector3(0, 0, 0.1f), Quaternion.Euler(90, 0, 0)),
new HandObjectLoadList("AssetBundles/weapons", null, typeof(WeaponCollision), typeof(MeshCollider), new[] { WeaponTypes.Flail, WeaponTypes.Flail_Magic }, "mace", new Vector3(0, 0, 0.1f), Quaternion.Euler(90, 0, 0), new Vector3(0, 0, 0.1f), Quaternion.Euler(90, 0, 0)),
new HandObjectLoadList("AssetBundles/weapons", null, typeof(WeaponCollision), typeof(BoxCollider), new[] { WeaponTypes.Warhammer, WeaponTypes.Warhammer_Magic }, "Warhammer_1", Vector3.zero, Quaternion.Euler(0, 0, 90), Vector3.zero, Quaternion.identity),
Expand Down Expand Up @@ -575,9 +574,10 @@ public static void LoadAllHandObjects(Dictionary<WeaponTypes, HandObject> handOb
}
}
// this is for accessing by name later
else if (!string.IsNullOrEmpty(handObjectLoad.assetName))
if (!string.IsNullOrEmpty(handObjectLoad.assetName))
{
handObjectDictionaryByName.Add(handObjectLoad.assetName, new HandObject(handObjectLoad, gameObject));
if (!handObjectDictionaryByName.ContainsKey(handObjectLoad.assetName))
handObjectDictionaryByName.Add(handObjectLoad.assetName, new HandObject(handObjectLoad, gameObject));
}

handObjectLoad.postAction?.Invoke(gameObject);
Expand Down
Loading