Skip to content

Commit

Permalink
Add wizard robe functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
NoooneyDude committed Oct 27, 2020
1 parent c14fe19 commit 4a420b1
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 7 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using UnityEngine;
using System.Collections;
using System.Collections;
using UnityEngine;
using Systems.Explosions;

namespace Items.Others.Magical
{
Expand All @@ -13,7 +14,15 @@ public class FireballPunishment : SpellBookPunishment

public override void Punish(ConnectedPlayer player)
{
Spawn.ServerPrefab(explosionPrefab, player.Script.WorldPos);
GameObject explosionObject = Spawn.ServerPrefab(explosionPrefab, player.Script.WorldPos).GameObject;
if (explosionObject.TryGetComponent<ExplosionComponent>(out var explosion))
{
explosion.Explode(MatrixManager.AtPoint(player.Script.WorldPos, true).Matrix);
}
else
{
Logger.LogError($"No explosion component found on {explosionObject}! Was the right prefab assigned?");
}
}
}
}
1 change: 1 addition & 0 deletions UnityProject/Assets/Scripts/Items/Traits/CommonTraits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ public class CommonTraits : SingletonScriptableObject<CommonTraits>
public ItemTrait RawCottonBundle;
public ItemTrait RawDurathreadBundle;
public ItemTrait Loomable;
public ItemTrait WizardGarb;
}
24 changes: 24 additions & 0 deletions UnityProject/Assets/Scripts/Systems/Spells/Spell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,30 @@ public virtual bool ValidateCast(ConnectedPlayer caster)
return false;
}

if (SpellData is WizardSpellData data && data.RequiresWizardGarb && CheckWizardGarb(caster.Script.Equipment) == false)
{
return false;
}

return true;
}

private bool CheckWizardGarb(Equipment casterEquipment)
{
var outerwear = casterEquipment.ItemStorage.GetNamedItemSlot(NamedSlot.outerwear);
if (outerwear.IsEmpty || outerwear.ItemAttributes.HasTrait(CommonTraits.Instance.WizardGarb) == false)
{
Chat.AddExamineMsg(casterEquipment.gameObject, "<color=red>You don't feel strong enough without your robe!</color>");
return false;
}

var headwear = casterEquipment.ItemStorage.GetNamedItemSlot(NamedSlot.head);
if (headwear.IsEmpty || headwear.ItemAttributes.HasTrait(CommonTraits.Instance.WizardGarb) == false)
{
Chat.AddExamineMsg(casterEquipment.gameObject, "<color=red>You don't feel strong enough without your hat!</color>");
return false;
}

return true;
}

Expand Down

0 comments on commit 4a420b1

Please sign in to comment.