Skip to content

Commit ce65618

Browse files
Added a public static method to DaggerfallMissile allowing external classes to use the appropriate layer mask (and initialize it if it isn't). Applied this new method to the player Touch targeting check in EntityEffectsManager.CastReadySpell to completely prevent self-targeting with Touch spells.
1 parent 59e1893 commit ce65618

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

Assets/Scripts/Game/DaggerfallMissile.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,19 @@ public static DaggerfallEntityBehaviour GetEntityTargetInTouchRange(Vector3 aimP
430430
return null;
431431
}
432432

433+
//allow other classes to use the layer masks
434+
public static int GetLayerMask(bool player)
435+
{
436+
//Initialize the layer masks if they're still not
437+
if (layerMaskDefault == -1)
438+
InitializeLayerMasks();
439+
440+
if (player)
441+
return layerMaskPlayer;
442+
443+
return layerMaskDefault;
444+
}
445+
433446
#endregion
434447

435448
#region Private Methods

Assets/Scripts/Game/MagicAndEffects/EntityEffectManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ public void CastReadySpell()
414414
{
415415
Vector3 aimPosition = GameManager.Instance.MainCamera.transform.position;
416416
Vector3 aimDirection = GameManager.Instance.MainCamera.transform.forward;
417-
if (DaggerfallMissile.GetEntityTargetInTouchRange(aimPosition, aimDirection) == null)
417+
if (DaggerfallMissile.GetEntityTargetInTouchRange(aimPosition, aimDirection, DaggerfallMissile.GetLayerMask(true)) == null)
418418
{
419419
//Debug.Log("Target entity not in range for touch spell.");
420420
return;

0 commit comments

Comments
 (0)