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
|
|
|
|
|
|
|
|
|
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-23 14:42:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|