Add items, Pickup logic works
This commit is contained in:
35
Assets/ItemsToSell/Object.cs
Normal file
35
Assets/ItemsToSell/Object.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEngine;
|
||||
|
||||
public class Object : MonoBehaviour {
|
||||
[SerializeField] private ObjectSO _objectSo;
|
||||
|
||||
private IObjectParentHolder _objectParent;
|
||||
|
||||
public ObjectSO ObjectSo {
|
||||
get => _objectSo;
|
||||
set => _objectSo = value;
|
||||
}
|
||||
|
||||
public IObjectParentHolder getObjectParent() {
|
||||
return _objectParent;
|
||||
}
|
||||
|
||||
public void setObjectParent(IObjectParentHolder objectParent) {
|
||||
if (this._objectParent != null) {
|
||||
this._objectParent.ClearObject();
|
||||
}
|
||||
|
||||
this._objectParent = objectParent;
|
||||
if (objectParent.HasObject()) {
|
||||
Debug.LogError("Parent has already something on it?");
|
||||
}
|
||||
objectParent.SetObject(this);
|
||||
|
||||
|
||||
transform.parent = _objectParent.GetHolderTransform();
|
||||
transform.localPosition = Vector3.zero;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user