public void PlaceInstalledObject(Vector3Int tile_position, string buildModeObjectType)
    {
        Debug.Log("PLACING:" + buildModeObjectType);
        InstalledObject object_to_place = World.InstalledObjectPrototypes[buildModeObjectType].Clone();

        object_to_place = InstalledObject.PlaceInstance(object_to_place, tile_position);
        TileBase tile = GameObject.FindObjectOfType <InstalledObjectSpriteController> ().GetTileBase(buildModeObjectType, tile_position);

        if (tile == null)
        {
            Debug.LogError("Something went wrong");
        }
        else
        {
            tilemapFoundation.SetTile(tile_position, tile);
            tilemapFoundation.GetTile(tile_position).name = buildModeObjectType;
            World.InvalidateTileGraph();
            if (object_to_place != null)
            {
                if (buildModeObjectType.Contains("Wall") || buildModeObjectType.Contains("Door") || buildModeObjectType.Contains("Window"))
                {
                    if (World.foundationGameMap.ContainsKey(tile_position) && buildModeObjectType.Contains("Door") && World.foundationGameMap[tile_position].objectType.Contains("Wall"))
                    {
                        World.foundationGameMap.Remove(tile_position);
                    }

                    World.foundationGameMap.Add(tile_position, object_to_place);
                }
            }
        }
    }
Beispiel #2
0
    // TODO: this currently assumes 1x1 objects - fix that
    public void PlaceInstalledObject(string objectType, Tile baseTile)
    {
        if (!installedObjectPrototypes.ContainsKey(objectType))
        {
            Debug.LogError("MouseController.SetTilePainter_IO - The InstalledObject \"" + objectType + "\" has no prototype.");
            return;
        }

        InstalledObject io = InstalledObject.PlaceInstance(installedObjectPrototypes[objectType], baseTile);

        // Bail out if PlaceInstance didn't work (fixes bug where sprites would be placed even for objects that were rejected)
        if (io == null)
        {
            return;
        }

        if (cb_InstalledObjectCreated != null)
        {
            cb_InstalledObjectCreated(io);
        }
    }
Beispiel #3
0
    public void PlaceInstalledObject(string ObjectType, Tile t)
    {
        // Debug.Log("Place Installed Object running succesfully");

        if (InstalledObjectPrototypes.ContainsKey(ObjectType) == false)
        {
            Debug.LogError("The prototype dictionary does not contain a definition for the passed string");
            return;
        }

        InstalledObject obj = InstalledObject.PlaceInstance(InstalledObjectPrototypes [ObjectType], t);

        if (obj == null)
        {
            return;
        }

        if (cbInstalledObjectCreated != null)
        {
            cbInstalledObjectCreated(obj);
        }
    }
Beispiel #4
0
    public void PlaceInstalledObject(string objectType, Tile t)
    {
        // TODO: This assumes 1x1 objects with no rotation.

        if (installedObjectPrototypes.ContainsKey(objectType) == false)
        {
            Debug.LogError("InstalledObjectPrototypes doesn't contain a proto for key: " + objectType);
            return;
        }

        InstalledObject obj = InstalledObject.PlaceInstance(installedObjectPrototypes[objectType], t);

        if (obj == null)
        {
            //Failed to place object, likely something there already.
            return;
        }

        if (cbInstalledObjectCreated != null)
        {
            cbInstalledObjectCreated(obj);
        }
    }
Beispiel #5
0
    public InstalledObject PlaceInstalledObject(string _objectType, Tile _t)
    {
        if (installedObjectPrototypes.ContainsKey(_objectType) == false)
        {
            Debug.LogError("installedObjectPrototypes doesn't contain a prototype for the key" + _objectType);
            return(null);
        }

        InstalledObject inObj = InstalledObject.PlaceInstance(installedObjectPrototypes[_objectType], _t);

        if (inObj == null)
        {
            //Failed to place the object
            return(null);
        }

        installedObjects.Add(inObj);

        //Do we need to recalc rooms?
        if (inObj.roomEnclosure)
        {
            Room.DoRoomFloodFill(inObj);
        }

        if (cbInstalledObjectCreated != null)
        {
            cbInstalledObjectCreated(inObj);

            if (inObj.MovementCost != 1)
            {
                //Since a furniture movement cost of 1 won't change the pathfinding system
                InvalidateTileGraph(); //reset pathfinding system
            }
        }

        return(inObj);
    }
Beispiel #6
0
    public InstalledObject PlaceInstalledObject(string objectType, Tile tile)
    {
        InstalledObject instObj;

        if (!_installedObjectPrototypes.TryGetValue(objectType, out instObj))
        {
            Debug.LogError("_installedObjectPrototypes doesn't contain the objectType!");
            return(null);
        }

        InstalledObject obj = InstalledObject.PlaceInstance(instObj, tile);

        if (obj == null)
        {
            //Failed to place object. Most likely there was already something there.
            return(null);
        }

        _installedObjects.Add(obj);

        if (obj.RoomEnclosure)
        {
            Room.DoRoomFloodFill(obj);
        }

        if (_cbInstalledObjectCreated != null)
        {
            _cbInstalledObjectCreated(obj);
            if (obj.MovementCost != 1)
            {
                InvalidateTileGraph();
            }
        }

        return(obj);
    }