浏览代码

Small Fixes + Added Tag Check

/fix-pickups
Thomas ICHÉ 4 年前
当前提交
79e5ed8b
共有 4 个文件被更改,包括 20 次插入9 次删除
  1. 2
      Editor/Pickup/PickupItemEditor.cs
  2. 2
      Runtime/Ingredients/Pickup/PickupEffectBase.cs
  3. 3
      Runtime/Ingredients/Pickup/PickupItem.cs
  4. 22
      Runtime/Ingredients/Pickup/PickupOwnerBase.cs

2
Editor/Pickup/PickupItemEditor.cs


GUILayout.FlexibleSpace();
});
EditorGUILayout.HelpBox("Add Effects to the Pickup Item by adding Pickup Effect Components to this Game Object", MessageType.Info);
EditorGUILayout.HelpBox("Add Pickup Effect components to this Game Object to see them appear in the list here", MessageType.Info);
m_RList.DoLayoutList();

2
Runtime/Ingredients/Pickup/PickupEffectBase.cs


namespace GameplayIngredients.Pickup
{
[HelpURL(Help.URL + "pickup")]
public abstract class PickupEffectBase : MonoBehaviour
public abstract class PickupEffectBase : GameplayIngredientsBehaviour
{
public abstract void ApplyPickupEffect(PickupOwnerBase owner);
}

3
Runtime/Ingredients/Pickup/PickupItem.cs


private void OnTriggerEnter(Collider other)
{
var owner = other.gameObject.GetComponent<PickupOwnerBase>();
if(owner != null)
if(other.gameObject.TryGetComponent(out PickupOwnerBase owner))
{
if(owner.PickUp(this))
{

22
Runtime/Ingredients/Pickup/PickupOwnerBase.cs


using NaughtyAttributes;
using System;
using System.Collections.Generic;
using System.Linq;
public abstract class PickupOwnerBase : MonoBehaviour
public abstract class PickupOwnerBase : GameplayIngredientsBehaviour
[ReorderableList, NoLabel]
public string[] acceptPickupTags;
foreach (var effect in pickup.effects)
// If PickupItem can be accepted
if (acceptPickupTags != null && acceptPickupTags.Contains(pickup.gameObject.tag))
effect.ApplyPickupEffect(this);
// Apply Effects
foreach (var effect in pickup.effects)
{
effect.ApplyPickupEffect(this);
}
return true;
return true;
else
return false;
}
}
}
正在加载...
取消
保存