Skip to content

Commit

Permalink
refactor: Changed Hitbox to HitboxBase.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Changed Hitbox to HitboxBase to better reflect it's usage.
  • Loading branch information
christides11 committed Aug 26, 2020
1 parent e66ecbb commit 89c135d
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Assets/CAF/Combat/Boxes/Hitbox2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace CAF.Combat
{
public class Hitbox2D : Hitbox
public class Hitbox2D : HitboxBase
{

protected Collider2D coll;
Expand Down
2 changes: 1 addition & 1 deletion Assets/CAF/Combat/Boxes/Hitbox3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace CAF.Combat
{
public class Hitbox3D : Hitbox
public class Hitbox3D : HitboxBase
{
protected Collider coll;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace CAF.Combat
{
public abstract class Hitbox : SimObject
public abstract class HitboxBase : SimObject
{
public delegate void HurtAction(GameObject hurtableHit, HitInfoBase hitInfo);
public virtual event HurtAction OnHurt;
Expand Down

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

10 changes: 5 additions & 5 deletions Assets/CAF/Entities/Managers/EntityHitboxManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class EntityHitboxManager
public event HitboxGroupEventAction OnHitboxHit;

// Hitbox Group : Hitboxes
protected Dictionary<int, List<Hitbox>> hitboxGroups = new Dictionary<int, List<Hitbox>>();
protected Dictionary<int, List<HitboxBase>> hitboxGroups = new Dictionary<int, List<HitboxBase>>();
// Hitbox ID : Hit IHurtables
protected Dictionary<int, List<IHurtable>> hurtablesHit = new Dictionary<int, List<IHurtable>>();

Expand Down Expand Up @@ -66,7 +66,7 @@ protected virtual void CleanupAllHitboxes()
/// </summary>
public virtual void TickBoxes()
{
foreach(List<Hitbox> hitboxGroup in hitboxGroups.Values)
foreach(List<HitboxBase> hitboxGroup in hitboxGroups.Values)
{
for(int i = 0; i < hitboxGroup.Count; i++)
{
Expand Down Expand Up @@ -124,7 +124,7 @@ public virtual void CreateHitboxGroup(int index)

// Variables.
BoxGroup currentGroup = combatManager.CurrentAttack.attackDefinition.boxGroups[index];
List<Hitbox> groupHitboxList = new List<Hitbox>(currentGroup.boxes.Count);
List<HitboxBase> groupHitboxList = new List<HitboxBase>(currentGroup.boxes.Count);

// Keep track of what the hitbox ID has hit.
if (!hurtablesHit.ContainsKey(currentGroup.ID))
Expand All @@ -138,7 +138,7 @@ public virtual void CreateHitboxGroup(int index)
{
// Instantiate the hitbox with the correct position and rotation.
BoxDefinition hitboxDefinition = currentGroup.boxes[i];
Hitbox hitbox = InstantiateHitbox(GetHitboxPosition(hitboxDefinition),
HitboxBase hitbox = InstantiateHitbox(GetHitboxPosition(hitboxDefinition),
GetHitboxRotation(hitboxDefinition));

// Attach the hitbox if neccessary.
Expand Down Expand Up @@ -177,7 +177,7 @@ protected virtual Vector3 GetHitboxPosition(BoxDefinition hitboxDefinition)
+ manager.GetVisualBasedDirection(Vector3.up) * hitboxDefinition.offset.y;
}

protected virtual Hitbox InstantiateHitbox(Vector3 position, Quaternion rotation)
protected virtual HitboxBase InstantiateHitbox(Vector3 position, Quaternion rotation)
{
throw new NotImplementedException("InstantiateHitbox in EntityHitboxManager must be overriden!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public EntityHitboxManager(EntityCombatManager combatManager, EntityManager mana

}

protected override Hitbox InstantiateHitbox(Vector3 position, Quaternion rotation)
protected override HitboxBase InstantiateHitbox(Vector3 position, Quaternion rotation)
{
return GameObject.Instantiate(((EntityManager)manager).hitboxPrefab, position, rotation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class EntityManager : CAF.Entities.EntityManager
public Collider2D coll;
public EntityDefinition entityDefinition;
public HealthManager healthManager;
public Hitbox hitboxPrefab;
public HitboxBase hitboxPrefab;
public LayerMask enemyStepLayerMask;
public float enemyStepRadius = 2;

Expand Down
2 changes: 1 addition & 1 deletion CAF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
<Compile Include="Assets\CAF\Combat\Boxes\BoxGroup.cs" />
<Compile Include="Assets\CAF\Combat\Boxes\BoxGroupType.cs" />
<Compile Include="Assets\CAF\Combat\Boxes\BoxShapes.cs" />
<Compile Include="Assets\CAF\Combat\Boxes\Hitbox.cs" />
<Compile Include="Assets\CAF\Combat\Boxes\Hitbox2D.cs" />
<Compile Include="Assets\CAF\Combat\Boxes\Hitbox3D.cs" />
<Compile Include="Assets\CAF\Combat\Boxes\HitboxBase.cs" />
<Compile Include="Assets\CAF\Combat\Boxes\Hurtbox.cs" />
<Compile Include="Assets\CAF\Combat\Boxes\HurtboxState.cs" />
<Compile Include="Assets\CAF\Combat\ChargeDefinition.cs" />
Expand Down

0 comments on commit 89c135d

Please sign in to comment.