private void OnCollisionEnter(Collision other) { bool interaction = LayerUtils.IsLayer(other.gameObject.layer, interactionMask); if (!interaction) { return; } OnCollision?.Invoke(other.gameObject); }
public virtual bool IsValidMove(MovementInstruction instruction, int?entityLayer = null) { Vector2Int target = GetCartesianPosition() + instruction.Direction; AbstractTile tile = grid.GetTile(target); int layer = entityLayer ?? gameObject.layer; if (tile == null) { return(false); } Debug.Log(tile.transform.position); return(LayerUtils.IsLayer(layer, tile.entityWhiteList)); }
// ---------------------------------------------------------------- // Physics Events // ---------------------------------------------------------------- private void OnTriggerEnter2D(Collider2D coll) { // IGNORE all collsions for first moment after birth. if (timeUntilDie > MaxLifetime - 0.1f) { return; } if (coll.isTrigger) { return; } // Ignore if THEY're a trigger too (i.e. DispGround and ToggleGround). // Ground?? Die! if (LayerUtils.IsLayer(coll.gameObject, Layers.Ground)) { Die(); } }
private bool MayCling(Collider2D col) { // We may only cling to Ground or Platforms. return(LayerUtils.IsLayer(col.gameObject, Layers.Ground) || LayerUtils.IsLayer(col.gameObject, Layers.Platform)); }