Exemple #1
0
 /// <summary>
 /// Check if for the context given, there are no entities at the skip layer,
 /// Sets the targeted entity and its attackness.
 /// Returns true is the entity can be attacked by default.
 /// </summary>
 public static bool _IsAttackableTarget_AndSetTransformAndAttackness(
     AttackTargetContext context, Layers targetedLayer, Layers skipLayer)
 {
     if (World.Global.Grid.HasNoTransformAt(context.position, context.direction, skipLayer) &&
         World.Global.Grid.TryGetTransformFromLayer(
             context.position, context.direction, targetedLayer, out context.normal.transform) &&
         context.transform.entity.TryGetAttackable(out var attackable))
     {
         context.attackness = attackable._attackness;
         return(_IsAttackableByDefault(context));
     }
     return(false);
 }
Exemple #2
0
 public static bool _IsBlock(AttackTargetContext context, Layers skipLayer)
 {
     return(skipLayer.HasFlag(context.transform.layer));
 }
Exemple #3
0
 public static bool _IsAttackableByDefault(AttackTargetContext context) =>
 context.attackness.HasFlag(Attackness.CAN_BE_ATTACKED | Attackness.BY_DEFAULT) &&
 (!context.attackness.HasFlag(Attackness.IF_NEXT_TO) || context.pieceIndex == 0);
Exemple #4
0
 public static bool _IsAttackableOrBlock(AttackTargetContext context) =>
 context.attackness.AreEitherSet(Attackness.CAN_BE_ATTACKED | Attackness.IS_BLOCK);