quantum-space-buddies/QSB/ItemSync/WorldObjects/QSBOWItem.cs

41 lines
1.5 KiB
C#
Raw Normal View History

2021-02-25 13:52:49 +00:00
using OWML.Utils;
using QSB.WorldSync;
using UnityEngine;
2021-02-23 14:42:18 +00:00
namespace QSB.ItemSync.WorldObjects
{
2021-02-24 10:45:25 +00:00
internal class QSBOWItem<T> : WorldObject<T>, IQSBOWItem
where T : OWItem
2021-02-23 14:42:18 +00:00
{
public override void Init(T attachedObject, int id) { }
2021-02-25 13:52:49 +00:00
2021-02-25 14:53:34 +00:00
public ItemType GetItemType()
2021-02-25 21:24:10 +00:00
=> AttachedObject.GetItemType();
2021-02-25 22:46:31 +00:00
public void SetColliderActivation(bool active)
2021-02-25 21:24:10 +00:00
=> AttachedObject.SetColliderActivation(active);
2021-02-25 14:53:34 +00:00
2021-02-26 10:23:51 +00:00
public virtual void PickUpItem(Transform holdTransform)
2021-02-26 10:23:08 +00:00
=> AttachedObject.PickUpItem(holdTransform);
2021-02-25 13:52:49 +00:00
public virtual void DropItem(Vector3 position, Vector3 normal, Sector sector)
{
AttachedObject.transform.SetParent(sector.transform);
AttachedObject.transform.localScale = Vector3.one;
var localDropNormal = AttachedObject.GetValue<Vector3>("_localDropNormal");
var lhs = Quaternion.FromToRotation(AttachedObject.transform.TransformDirection(localDropNormal), normal);
AttachedObject.transform.rotation = lhs * AttachedObject.transform.rotation;
var localDropOffset = AttachedObject.GetValue<Vector3>("_localDropOffset");
AttachedObject.transform.position = sector.transform.TransformPoint(position) + AttachedObject.transform.TransformDirection(localDropOffset);
AttachedObject.SetSector(sector);
AttachedObject.SetColliderActivation(true);
}
2021-02-25 14:53:34 +00:00
2021-02-25 22:46:31 +00:00
public virtual void SocketItem(Transform socketTransform, Sector sector)
2021-02-25 14:53:34 +00:00
=> AttachedObject.SocketItem(socketTransform, sector);
public virtual void PlaySocketAnimation() { }
2021-02-25 21:24:10 +00:00
public virtual void PlayUnsocketAnimation() { }
2021-02-23 14:42:18 +00:00
}
}