From 933a048835db99e7ce1b6d6066fdf995adddca62 Mon Sep 17 00:00:00 2001 From: Christian Schamara Date: Mon, 29 Jan 2018 09:16:06 +0100 Subject: [PATCH] Fix some mistakes and clean up actions Signed-off-by: Christian Schamara --- ootii/EnableWeaponSet.cs | 8 +------- ootii/EquipWeaponSet.cs | 21 ++++++++------------- ootii/GetStance.cs | 5 ++++- ootii/IsRunning.cs | 2 +- ootii/IsStance.cs | 21 ++++++++++++--------- ootii/IsWeaponSet.cs | 21 ++++++++++++--------- ootii/ModifyAttributeFloat.cs | 19 +++++++++++-------- ootii/SendPlayerDeath.cs | 10 ++++++---- ootii/SetAttributeFloat.cs | 7 +++++-- ootii/SetStance.cs | 5 ++++- ootii/StoreWeaponSet.cs | 7 ++----- 11 files changed, 66 insertions(+), 60 deletions(-) diff --git a/ootii/EnableWeaponSet.cs b/ootii/EnableWeaponSet.cs index a8df8fe..f7aa09a 100644 --- a/ootii/EnableWeaponSet.cs +++ b/ootii/EnableWeaponSet.cs @@ -49,15 +49,9 @@ void isWeaponSet() mBasicInventory = go.GetComponent(); - if (mBasicInventory == null) - { - Finish(); - return; - } - BasicInventorySet lWeaponSet = mBasicInventory.GetWeaponSet(mWeaponSet.Value); - if (lWeaponSet != null) + if (mBasicInventory != null && lWeaponSet != null) { lWeaponSet.IsEnabled = enable; } diff --git a/ootii/EquipWeaponSet.cs b/ootii/EquipWeaponSet.cs index acca155..3414a37 100644 --- a/ootii/EquipWeaponSet.cs +++ b/ootii/EquipWeaponSet.cs @@ -49,23 +49,18 @@ void Equip() mBasicInventory = go.GetComponent(); - if (mBasicInventory == null) - { - Finish(); - return; - } - int lWeaponSetIndex = (UseCurrentSet ? -1 : weaponSet.Value); - // Check if it's already equipped - if (mBasicInventory.IsWeaponSetEquipped(lWeaponSetIndex)) + if (mBasicInventory != null) { - Finish(); - return; - } + if (mBasicInventory.IsWeaponSetEquipped(lWeaponSetIndex)) + { + Finish(); + return; + } - // Equip - mBasicInventory.EquipWeaponSet(lWeaponSetIndex); + mBasicInventory.EquipWeaponSet(lWeaponSetIndex); + } } } } diff --git a/ootii/GetStance.cs b/ootii/GetStance.cs index 723f90b..676a704 100644 --- a/ootii/GetStance.cs +++ b/ootii/GetStance.cs @@ -54,7 +54,10 @@ void GetPlayerStance() mActorController = go.GetComponent(); - store.Value = mActorController.State.Stance; + if(mActorController != null) + { + store.Value = mActorController.State.Stance; + } } } } diff --git a/ootii/IsRunning.cs b/ootii/IsRunning.cs index 6720565..3b0abbd 100644 --- a/ootii/IsRunning.cs +++ b/ootii/IsRunning.cs @@ -63,7 +63,7 @@ void IsRun() IWalkRunMotion lMotion = mMotionController.ActiveMotion as IWalkRunMotion; - if (lMotion != null) + if (mMotionController != null && lMotion != null) { store.Value = lMotion.IsRunActive; Fsm.Event(lMotion.IsRunActive ? trueEvent : falseEvent); diff --git a/ootii/IsStance.cs b/ootii/IsStance.cs index e89833f..9ba0d7a 100644 --- a/ootii/IsStance.cs +++ b/ootii/IsStance.cs @@ -67,16 +67,19 @@ void DoCompare() mActorController = go.GetComponent(); - if (stance.Value == mActorController.State.Stance) + if (mActorController != null) { - store.Value = true; - Fsm.Event(trueEvent); - } - - else - { - store.Value = false; - Fsm.Event(falseEvent); + if (stance.Value == mActorController.State.Stance) + { + store.Value = true; + Fsm.Event(trueEvent); + } + + else + { + store.Value = false; + Fsm.Event(falseEvent); + } } } } diff --git a/ootii/IsWeaponSet.cs b/ootii/IsWeaponSet.cs index aef02f8..a074909 100644 --- a/ootii/IsWeaponSet.cs +++ b/ootii/IsWeaponSet.cs @@ -73,16 +73,19 @@ void DoCompare() int lWeaponSetIndex = (checkCurrentSet ? -1 : weaponSet.Value); - if (mBasicInventory.IsWeaponSetEquipped(lWeaponSetIndex)) + if (mBasicInventory != null) { - store.Value = true; - Fsm.Event(trueEvent); - } - - else - { - store.Value = false; - Fsm.Event(falseEvent); + if (mBasicInventory.IsWeaponSetEquipped(lWeaponSetIndex)) + { + store.Value = true; + Fsm.Event(trueEvent); + } + + else + { + store.Value = false; + Fsm.Event(falseEvent); + } } } } diff --git a/ootii/ModifyAttributeFloat.cs b/ootii/ModifyAttributeFloat.cs index 192c20a..12c09d0 100644 --- a/ootii/ModifyAttributeFloat.cs +++ b/ootii/ModifyAttributeFloat.cs @@ -61,15 +61,18 @@ void ModifyAttribute() mBasicAttributes = go.GetComponent(); - if (!perSecond) + if (mBasicAttributes != null) { - float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); - mBasicAttributes.SetAttributeValue(attribute.Value, lValue + floatValue.Value); - } - else - { - float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); - mBasicAttributes.SetAttributeValue(attribute.Value, lValue + floatValue.Value * Time.deltaTime); + if (!perSecond) + { + float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); + mBasicAttributes.SetAttributeValue(attribute.Value, lValue + floatValue.Value); + } + else + { + float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); + mBasicAttributes.SetAttributeValue(attribute.Value, lValue + floatValue.Value * Time.deltaTime); + } } } } diff --git a/ootii/SendPlayerDeath.cs b/ootii/SendPlayerDeath.cs index 5998e40..2a52831 100644 --- a/ootii/SendPlayerDeath.cs +++ b/ootii/SendPlayerDeath.cs @@ -44,10 +44,12 @@ void SendDeath() mActorCore = go.GetComponent(); - DamageMessage lDamage = DamageMessage.Allocate(); - mActorCore.OnKilled(lDamage); - lDamage.Release(); + if (mActorCore != null) + { + DamageMessage lDamage = DamageMessage.Allocate(); + mActorCore.OnKilled(lDamage); + lDamage.Release(); + } } - } } diff --git a/ootii/SetAttributeFloat.cs b/ootii/SetAttributeFloat.cs index ebe358f..210119e 100644 --- a/ootii/SetAttributeFloat.cs +++ b/ootii/SetAttributeFloat.cs @@ -57,8 +57,11 @@ void SetAttribute() mBasicAttributes = go.GetComponent(); - float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); - mBasicAttributes.SetAttributeValue(attribute.Value, floatValue.Value); + if (mBasicAttributes != null) + { + float lValue = mBasicAttributes.GetAttributeValue(attribute.Value); + mBasicAttributes.SetAttributeValue(attribute.Value, floatValue.Value); + } } } } diff --git a/ootii/SetStance.cs b/ootii/SetStance.cs index 14fdbfb..b8a0b59 100644 --- a/ootii/SetStance.cs +++ b/ootii/SetStance.cs @@ -53,7 +53,10 @@ void SetPlayerStance() mActorController = go.GetComponent(); - mActorController.State.Stance = stance.Value; + if (mActorController != null) + { + mActorController.State.Stance = stance.Value; + } } } } diff --git a/ootii/StoreWeaponSet.cs b/ootii/StoreWeaponSet.cs index 38eb68e..09303ac 100644 --- a/ootii/StoreWeaponSet.cs +++ b/ootii/StoreWeaponSet.cs @@ -50,13 +50,10 @@ void Store() mBasicInventory = go.GetComponent(); - if (mBasicInventory == null) + if (mBasicInventory != null) { - Finish(); - return; + mBasicInventory.StoreWeaponSet(-1); } - - mBasicInventory.StoreWeaponSet(-1); } } }