/// <summary> /// Interact with entity on tile /// Returns false if it blocks the entity actor's movement /// </summary> /// <param name="interactor"></param> /// <param name="nextTile"></param> /// <returns></returns> private bool InteractTileEntities(Entity interactor, MapTile nextTile) { Entity activeTileEntity = nextTile.entities[0]; if (nextTile.entities.Count > 1) { // figure this out... for (int i = 0; i < nextTile.entities.Count; i++) { if (nextTile.entities[i].entityType == EntityType.Unit) { activeTileEntity = nextTile.entities[i]; break; } } } if (activeTileEntity.entityType == EntityType.Unit) { if (activeTileEntity.faction == interactor.faction) { return(false); } FighterComponent attacker = (FighterComponent)interactor.GetEntityComponent(ComponentID.Fighter); FighterComponent defender = (FighterComponent)activeTileEntity.GetEntityComponent(ComponentID.Fighter); return(DoCombat(attacker, defender)); } else if (activeTileEntity.entityType == EntityType.Item) { Debug.Log("ON AN ITEM TILE!!"); // do item pick up EntityComponent comp = interactor.GetEntityComponent(ComponentID.Inventory); if (comp == null) { return(true); } ItemComponent item = (ItemComponent)activeTileEntity.GetEntityComponent(ComponentID.Item); InventoryComponent inventory = (InventoryComponent)comp; if (inventory.AddItem(item) == true) { item.PickUp(); } return(true); } return(true); }