public bool TryMoveEntity(FEntity ch, int tox, int toy) { FEvent moveIntoEvent = new FEvent(FEventCodes.ENTITY_TRY_MOVE_INTO); moveIntoEvent.Add("x", tox); moveIntoEvent.Add("y", toy); moveIntoEvent.Add("entity", ch); moveIntoEvent.Add("moveCancelled", false); FEvent loc1 = ch.PropagateEvent(new FEvent(FEventCodes.GET_LOCATION, "x", -1, "y", -1)); int dist = Mathf.Max(Mathf.Abs((int)loc1.Get("x") - tox), Mathf.Abs((int)loc1.Get("y") - toy)); if (dist > 1) { Debug.Log(loc1.Get("x") + "," + loc1.Get("y")); List <MapTile> tiles = GameMap.instance.PathToFrom((int)loc1.Get("x"), (int)loc1.Get("y"), tox, toy); Debug.Log(tiles[0].x + "," + tiles[0].y); return(TryMoveEntity(ch, tiles[0].x, tiles[0].y)); } List <FEntity> entitiesAtNewLocation = map.GetEntitiesAt(tox, toy); foreach (FEntity entity in entitiesAtNewLocation) { moveIntoEvent = entity.PropagateEvent(moveIntoEvent); } if ((bool)moveIntoEvent.Get("moveCancelled")) { //Nope if (moveIntoEvent.Get("moveBlockedByEntity") != null) { //End turn FEntity entity = (FEntity)moveIntoEvent.Get("blockingEntity"); FEvent meleeAttack = ch.PropagateEvent(new FEvent(FEventCodes.ENTITY_MELEE_ATTACK, "target", entity, "damage", 0)); } EndTurn(); return(false); } FEvent moveEvent = new FEvent(FEventCodes.ENTITY_MOVE); moveEvent.Add("x", tox); moveEvent.Add("y", toy); moveEvent = ch.PropagateEvent(moveEvent); EndTurn(); return(true); }