public void PlaceInstalledObject(string objType, Tile t) { Debug.Log("Place Installed instance"); if (!installedObjectPrototypes.ContainsKey(objType)) { Debug.LogError("installedObjectPrototypes dosen't contain a prototype for key: " + objType); return; } InstalledObject obj = InstalledObject.PlaceObject(t, installedObjectPrototypes[objType]); if (cbInstalledObjectCreated != null) { cbInstalledObjectCreated(obj); } }
/// <summary> /// Search for correct InstalledObject in dictionary and place it on a tile /// </summary> /// <param name="objectType">InstalledObject key.</param> /// <param name="tile">Tile to place InstalledObject on.</param> public InstalledObject PlaceInstalledObject(string objectType, Tile tile) { // TODO: Implement multiple tiles support // TODO: Implement rotation // Check if the dictionary contains an object with the given key (objectType) if (installedBaseObjects.ContainsKey(objectType) == false) { Debug.LogError("installedBaseObjects doesn't contain a baseObject for key: " + objectType); return(null); } // Actually place the object on a tile InstalledObject installedObject = InstalledObject.PlaceObject(installedBaseObjects[objectType], tile); // Does the roomGraph need to recalculated? Only needs to happen if installedObject CAN create rooms if (installedObject.RoomEnclosure == true) { Room.RunRoomFloodFill(installedObject); } if (installedObject == null) { // Failed to place installedObject -- most likely there was already something there. return(null); } // If the callback action has registered function, call/execute them if (cb_InstalledObjectCreated != null) { cb_InstalledObjectCreated(installedObject); // Flag current pathfinding graph as invalid, because a new object has been placed. // Only if the movementcost isn't 1 because that's the default value if (installedObject.MovementCost != 1) { InvalidateTileGraph(); } } // Add it to the global list installedObjects.Add(installedObject); return(installedObject); }