Skip to content

Commit

Permalink
Fix some mistakes and clean up actions
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Schamara <[email protected]>
  • Loading branch information
Salja committed Jan 29, 2018
1 parent bace4da commit 933a048
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 60 deletions.
8 changes: 1 addition & 7 deletions ootii/EnableWeaponSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,9 @@ void isWeaponSet()

mBasicInventory = go.GetComponent<BasicInventory>();

if (mBasicInventory == null)
{
Finish();
return;
}

BasicInventorySet lWeaponSet = mBasicInventory.GetWeaponSet(mWeaponSet.Value);

if (lWeaponSet != null)
if (mBasicInventory != null && lWeaponSet != null)
{
lWeaponSet.IsEnabled = enable;
}
Expand Down
21 changes: 8 additions & 13 deletions ootii/EquipWeaponSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,18 @@ void Equip()

mBasicInventory = go.GetComponent<BasicInventory>();

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);
}
}
}
}
5 changes: 4 additions & 1 deletion ootii/GetStance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ void GetPlayerStance()

mActorController = go.GetComponent<ActorController>();

store.Value = mActorController.State.Stance;
if(mActorController != null)
{
store.Value = mActorController.State.Stance;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ootii/IsRunning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 12 additions & 9 deletions ootii/IsStance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,19 @@ void DoCompare()

mActorController = go.GetComponent<ActorController>();

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);
}
}
}
}
Expand Down
21 changes: 12 additions & 9 deletions ootii/IsWeaponSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down
19 changes: 11 additions & 8 deletions ootii/ModifyAttributeFloat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,18 @@ void ModifyAttribute()

mBasicAttributes = go.GetComponent<BasicAttributes>();

if (!perSecond)
if (mBasicAttributes != null)
{
float lValue = mBasicAttributes.GetAttributeValue<float>(attribute.Value);
mBasicAttributes.SetAttributeValue(attribute.Value, lValue + floatValue.Value);
}
else
{
float lValue = mBasicAttributes.GetAttributeValue<float>(attribute.Value);
mBasicAttributes.SetAttributeValue(attribute.Value, lValue + floatValue.Value * Time.deltaTime);
if (!perSecond)
{
float lValue = mBasicAttributes.GetAttributeValue<float>(attribute.Value);
mBasicAttributes.SetAttributeValue(attribute.Value, lValue + floatValue.Value);
}
else
{
float lValue = mBasicAttributes.GetAttributeValue<float>(attribute.Value);
mBasicAttributes.SetAttributeValue(attribute.Value, lValue + floatValue.Value * Time.deltaTime);
}
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions ootii/SendPlayerDeath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ void SendDeath()

mActorCore = go.GetComponent<ActorCore>();

DamageMessage lDamage = DamageMessage.Allocate();
mActorCore.OnKilled(lDamage);
lDamage.Release();
if (mActorCore != null)
{
DamageMessage lDamage = DamageMessage.Allocate();
mActorCore.OnKilled(lDamage);
lDamage.Release();
}
}

}
}
7 changes: 5 additions & 2 deletions ootii/SetAttributeFloat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ void SetAttribute()

mBasicAttributes = go.GetComponent<BasicAttributes>();

float lValue = mBasicAttributes.GetAttributeValue<float>(attribute.Value);
mBasicAttributes.SetAttributeValue(attribute.Value, floatValue.Value);
if (mBasicAttributes != null)
{
float lValue = mBasicAttributes.GetAttributeValue<float>(attribute.Value);
mBasicAttributes.SetAttributeValue(attribute.Value, floatValue.Value);
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion ootii/SetStance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ void SetPlayerStance()

mActorController = go.GetComponent<ActorController>();

mActorController.State.Stance = stance.Value;
if (mActorController != null)
{
mActorController.State.Stance = stance.Value;
}
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions ootii/StoreWeaponSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,10 @@ void Store()

mBasicInventory = go.GetComponent<BasicInventory>();

if (mBasicInventory == null)
if (mBasicInventory != null)
{
Finish();
return;
mBasicInventory.StoreWeaponSet(-1);
}

mBasicInventory.StoreWeaponSet(-1);
}
}
}
Expand Down

0 comments on commit 933a048

Please sign in to comment.