From bace4da768866648c508af477eb376cc5122739a Mon Sep 17 00:00:00 2001 From: Christian Schamara Date: Sat, 27 Jan 2018 19:40:51 +0100 Subject: [PATCH] Update ootii Playmaker Actions and Add a new Actions for Enable and Disable WeaponSet Signed-off-by: Christian Schamara --- ootii/EnableWeaponSet.cs | 66 +++++++++++++++++++++++++++++++++++ ootii/GetAttributeFloat.cs | 2 +- ootii/ModifyAttributeFloat.cs | 4 +-- ootii/SetAttributeFloat.cs | 2 +- 4 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 ootii/EnableWeaponSet.cs diff --git a/ootii/EnableWeaponSet.cs b/ootii/EnableWeaponSet.cs new file mode 100644 index 0000000..a8df8fe --- /dev/null +++ b/ootii/EnableWeaponSet.cs @@ -0,0 +1,66 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. +/*--- __ECO__ __PLAYMAKER__ __ACTION__ ---*/ + +using UnityEngine; +using com.ootii.Actors.Inventory; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory("ootii")] + [Tooltip("Enable/Disable WeaponSet")] + public class EnableWeaponSet : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject Player.")] + [CheckForComponent(typeof(BasicInventory))] + public FsmOwnerDefault gameObject; + + public FsmString mWeaponSet; + + public bool enable = false; + + private BasicInventory mBasicInventory; + + public override void Reset() + { + gameObject = null; + mWeaponSet = null; + enable = false; + } + + public override void OnEnter() + { + isWeaponSet(); + Finish(); + } + + public override void OnUpdate() + { + isWeaponSet(); + } + + void isWeaponSet() + { + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + mBasicInventory = go.GetComponent(); + + if (mBasicInventory == null) + { + Finish(); + return; + } + + BasicInventorySet lWeaponSet = mBasicInventory.GetWeaponSet(mWeaponSet.Value); + + if (lWeaponSet != null) + { + lWeaponSet.IsEnabled = enable; + } + } + } +} diff --git a/ootii/GetAttributeFloat.cs b/ootii/GetAttributeFloat.cs index 8f9b916..1683676 100644 --- a/ootii/GetAttributeFloat.cs +++ b/ootii/GetAttributeFloat.cs @@ -59,7 +59,7 @@ void GetAttribute() if (mBasicAttributes != null) { - float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); + float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); store.Value = mBasicAttributes.GetAttributeValue(attribute.Value, lValue); } } diff --git a/ootii/ModifyAttributeFloat.cs b/ootii/ModifyAttributeFloat.cs index d3d419f..192c20a 100644 --- a/ootii/ModifyAttributeFloat.cs +++ b/ootii/ModifyAttributeFloat.cs @@ -63,12 +63,12 @@ void ModifyAttribute() if (!perSecond) { - float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); + float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); mBasicAttributes.SetAttributeValue(attribute.Value, lValue + floatValue.Value); } else { - float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); + float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); mBasicAttributes.SetAttributeValue(attribute.Value, lValue + floatValue.Value * Time.deltaTime); } } diff --git a/ootii/SetAttributeFloat.cs b/ootii/SetAttributeFloat.cs index 655a3c1..ebe358f 100644 --- a/ootii/SetAttributeFloat.cs +++ b/ootii/SetAttributeFloat.cs @@ -57,7 +57,7 @@ void SetAttribute() mBasicAttributes = go.GetComponent(); - float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); + float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); mBasicAttributes.SetAttributeValue(attribute.Value, floatValue.Value); } }