Beispiel #1
0
    public static void Stockpile_UpdateAction(Furniture furniture, float deltaTime)
    {
        Inventory furnitureInventory = furniture.tile.inventory;

        if (furnitureInventory != null && furnitureInventory.stackSize >= furnitureInventory.maxStackSize)
        {
            furniture.CancelJobs();
            return;
        }

        if (furniture.JobCount() > 0)
        {
            return;
        }

        if (furnitureInventory != null && furnitureInventory.stackSize == 0)
        {
            Debug.LogError("Stockpile_UpdateAction - has a zero sized stack");
            furniture.CancelJobs();
            return;
        }

        Inventory[] itemsDesired;

        if (furnitureInventory == null)
        {
            itemsDesired = Stockpile_GetItemsFromFilter();
        }
        else
        {
            Inventory desired = furnitureInventory.Clone();
            desired.maxStackSize -= desired.stackSize;
            desired.stackSize     = 0;
            itemsDesired          = new Inventory[] { desired };
        }

        Job job = new Job(
            furniture.tile,
            null,
            null,
            0f,
            itemsDesired
            );

        job.canTakeFromStockpile = false;
        job.RegisterJobWorkedCallback(Stockpile_JobWorked);
        furniture.AddJob(job);
    }
Beispiel #2
0
    private static void ChangeCurrentProductionChain(Furniture furniture, string newProductionChainName)
    {
        Parameter oldProductionChainName = furniture.Parameters[CurProductionChainParamName];
        bool      isProcessing           = furniture.Parameters[CurProcessedInvParamName].ToInt() > 0;

        // if selected production really changes and nothing is being processed now
        if (isProcessing || newProductionChainName.Equals(oldProductionChainName))
        {
            return;
        }

        furniture.CancelJobs();
        furniture.Parameters[CurProductionChainParamName].SetValue(newProductionChainName);
    }
Beispiel #3
0
    public static void MiningDroneStation_UpdateAction(Furniture furniture, float deltaTime)
    {
        Tile spawnSpotTile = furniture.GetSpawnSpotTile();

        if (spawnSpotTile.inventory != null && spawnSpotTile.inventory.stackSize >= spawnSpotTile.inventory.maxStackSize)
        {
            if (furniture.JobCount() > 0)
            {
                furniture.CancelJobs();
            }

            return;
        }


        /*if (furniture.JobCount () > 0) {
         *      if (spawnSpotTile.inventory.stackSize >= spawnSpotTile.inventory.maxStackSize) {
         *              furniture.ClearJobs ();
         *      }
         *
         *      return;
         * }
         *
         * if (spawnSpotTile.inventory.stackSize >= spawnSpotTile.inventory.maxStackSize) {
         *      return;
         * }*/

        Tile jobSpot = furniture.GetJobSpotTile();

        if (jobSpot.inventory != null && (jobSpot.inventory.inventoryType != "Steel Plate" || jobSpot.inventory.stackSize >= jobSpot.inventory.maxStackSize))
        {
            return;
        }

        Job job = new Job(
            jobSpot,
            MiningDroneStation_JobComplete,
            null,
            1f,
            null,
            true
            );

        furniture.AddJob(job);
    }
Beispiel #4
0
    public void Deconstruct()
    {
        int  x                = Tile.X;
        int  y                = Tile.Y;
        int  fwidth           = 1;
        int  fheight          = 1;
        bool linksToNeighbour = false;

        if (Tile.Furniture != null)
        {
            Furniture furniture = Tile.Furniture;
            fwidth           = furniture.Width;
            fheight          = furniture.Height;
            linksToNeighbour = furniture.LinksToNeighbour;
            furniture.CancelJobs();
        }

        // We call lua to decostruct
        EventActions.Trigger("OnUninstall", this);

        // Update thermalDiffusifity to default value
        World.Current.temperature.SetThermalDiffusivity(Tile.X, Tile.Y, Temperature.defaultThermalDiffusivity);

        Tile.UnplaceFurniture();

        if (Removed != null)
        {
            Removed(this);
        }

        // Do we need to recalculate our rooms?
        if (RoomEnclosure)
        {
            Room.DoRoomFloodFill(Tile);
        }

        ////World.current.InvalidateTileGraph();

        if (World.Current.tileGraph != null)
        {
            World.Current.tileGraph.RegenerateGraphAtTile(Tile);
        }

        // We should inform our neighbours that they have just lost a
        // neighbour regardless of objectType.
        // Just trigger their OnChangedCallback.
        if (linksToNeighbour == true)
        {
            for (int xpos = x - 1; xpos < x + fwidth + 1; xpos++)
            {
                for (int ypos = y - 1; ypos < y + fheight + 1; ypos++)
                {
                    Tile t = World.Current.GetTileAt(xpos, ypos);
                    if (t != null && t.Furniture != null && t.Furniture.Changed != null)
                    {
                        t.Furniture.Changed(t.Furniture);
                    }
                }
            }
        }

        // At this point, no DATA structures should be pointing to us, so we
        // should get garbage-collected.
    }
    public void Deconstruct()
    {
        Debug.Log("Deconstruct");
        int  x                = tile.X;
        int  y                = tile.Y;
        int  fwidth           = 1;
        int  fheight          = 1;
        bool linksToNeighbour = false;

        if (tile.Furniture != null)
        {
            Furniture f = tile.Furniture;
            fwidth           = f.Width;
            fheight          = f.Height;
            linksToNeighbour = f.linksToNeighbour;
            f.CancelJobs();
        }

        // We call lua to decostruct
        if (uninstallActions != null)
        {
            FurnitureActions.CallFunctionsWithFurniture(uninstallActions.ToArray(), this, 0);
        }

        // Update thermalDiffusifity to default value
        World.current.temperature.SetThermalDiffusivity(tile.X, tile.Y,
                                                        Temperature.defaultThermalDiffusivity);

        tile.UnplaceFurniture();

        if (cbOnRemoved != null)
        {
            cbOnRemoved(this);
        }
        // Do we need to recalculate our rooms?
        if (roomEnclosure)
        {
            Room.DoRoomFloodFill(this.tile);
        }

        ////World.current.InvalidateTileGraph();

        if (World.current.tileGraph != null)
        {
            World.current.tileGraph.RegenerateGraphAtTile(tile);
        }

        // We should inform our neighbours that they have just lost a
        // neighbour regardless of objectType.
        // Just trigger their OnChangedCallback.
        if (linksToNeighbour == true)
        {
            for (int xpos = x - 1; xpos < (x + fwidth + 1); xpos++)
            {
                for (int ypos = y - 1; ypos < (y + fheight + 1); ypos++)
                {
                    Tile t = World.current.GetTileAt(xpos, ypos);
                    if (t != null && t.Furniture != null && t.Furniture.cbOnChanged != null)
                    {
                        t.Furniture.cbOnChanged(t.Furniture);
                    }
                }
            }
        }

        // At this point, no DATA structures should be pointing to us, so we
        // should get garbage-collected.
    }