Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt at generic factory furniture (consume/produce) #1084

Merged

Conversation

dusho
Copy link
Contributor

@dusho dusho commented Sep 2, 2016

Working in generic consume/produce (discussed in #604)
Can do:

  • added optional Workshop (FurnitureWorkshop.cs) to Furniture .xml
  • furniture can handle multiple production chains (recipes)
  • can have multiple input/output slots
  • added context menu if there is more than 1 available production chain
  • load/save seems to be working (Inventory.locked is not persisted, after load, items from input are taken away - new issue, I guess)

There is new temporary Metal Furnace (that works as Metal Smelter) just to try things out. Idea is to get rid of most of repeated code in LUA for furniture that consumes and produces something
New art for Power cell press, input: 3x uranium, 2x steel plate, output: 1x power cell

@dusho dusho changed the title [WIP] Attemp at generic factory furniture (consume/produce) [WIP] Attempt at generic factory furniture (consume/produce) Sep 2, 2016
fi.PossibleProductions = new System.Collections.Generic.List<FactoryInfo.ProductionChain>();
//fi.InputSlots = new List<FactoryInfo.IntVector2>() { new FactoryInfo.IntVector2(1, 0) };
//fi.OutputSlots = new List<FactoryInfo.IntVector2>() { new FactoryInfo.IntVector2(2, 0) };
var chain1 = new FactoryInfo.ProductionChain() { Name="Iron smelting", ProcessingTime = 4.0f };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test file doesn't look formatted according to the rules in the CONTRIBUTING.md file. It's pretty hard to read.

@vogonistic
Copy link
Collaborator

+1 on adding Copper, but that could probably have been added in a small separate PR which I'd taken in a heartbeat.

In general I like the consume/produce pattern. This looks like a pretty good improvement to the current way of doing conversions on top of that.

@svmnotn
Copy link
Contributor

svmnotn commented Sep 5, 2016

@dusho this PR has some conflicts, please fix them


<JobSpotOffset X="1" Y="0" />

<FactoryInfo>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your xml has a mix of spaces and tabs, pick one or the other :)

@mikejbrown mikejbrown changed the title [WIP] Attempt at generic factory furniture (consume/produce) [Conflicts] [WIP] Attempt at generic factory furniture (consume/produce) Sep 6, 2016
…ess and power cell, context menu action on furniture still not working...
@dusho
Copy link
Contributor Author

dusho commented Sep 6, 2016

made some changes.. still having problem with context menu Action not changing my params (some problem with being a copy or something and not updating real furniture params)
Added new temp art here
image

@dusho
Copy link
Contributor Author

dusho commented Sep 9, 2016

new commit, got rid of that partial class.. factory overall renamed to workshop.. to have class FurnitureWorkshop (instead of FurnitureFactory that can be confused with design pattern)
still having issue with context menu.. last is triggered no matter which one of workshop's context items is selected

@dusho dusho changed the title [Conflicts] [WIP] Attempt at generic factory furniture (consume/produce) Attempt at generic factory furniture (consume/produce) Sep 9, 2016
@dusho
Copy link
Contributor Author

dusho commented Sep 9, 2016

merged with upstream
added copper plate and renamed raw_copper to Raw Copper for consistency with other resources
there seems to be funky behavior of jobs when items are not available (job is put into waitingJobQueue and then never put into active jobQueue, even if items are available) - not related to this commit

…the broken localization on furniture description
<?xml version="1.0" encoding="utf-8"?>
<Sprites>
<Sprite name="Raw Copper" x="0" y="0" w="1" h="1" pixelPerUnit="64" />
</Sprites>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add one line at the end

@Grenkin1988
Copy link
Contributor

FurnitureWorkshop has StyleCop errors

WorkshopMenuActions.Add(new WorkshopContextMenu()
{
ProductionChainName = prodChainName,
Function = (furn, prod) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think more readable would be change lambda by simple method. ->

WorkshopMenuActions.Add(new WorkshopContextMenu
                {
                    ProductionChainName = chain.Name,
                    Function = ChangeCurrentProductionChain
                });

and

private static void ChangeCurrentProductionChain(Furniture furniture, string productName)
    {
        Parameter currentProdaction = furniture.Parameters[CUR_PRODUCTION_CHAIN_PARAM_NAME];
        bool isNotProcessing = furniture.Parameters[CUR_PROCESSED_INV_PARAM_NAME].ToInt() == 0;
        // if selected production really changes and nothing is being processed now
        if (productName.Equals(currentProdaction.Value) || !isNotProcessing)
        {
            return;
        }

        furniture.CancelJobs();
        furniture.Parameters[CUR_PRODUCTION_CHAIN_PARAM_NAME].SetValue(productName);
    }

@dusho dusho changed the title [StyleCop errors] Attempt at generic factory furniture (consume/produce) Attempt at generic factory furniture (consume/produce) Sep 10, 2016
@dusho
Copy link
Contributor Author

dusho commented Sep 10, 2016

incorporated comments from Grenkin1988 (thanks for great review!)
fixed StyleCop warnings

@Grenkin1988
Copy link
Contributor

You removed WorkshopContextMenu

@dusho
Copy link
Contributor Author

dusho commented Sep 10, 2016

sorry.. forgot to add newly created file. fixed

@sboigelot
Copy link
Collaborator

This branch has conflicts that must be resolved

@sboigelot sboigelot changed the title Attempt at generic factory furniture (consume/produce) [Conflict] Attempt at generic factory furniture (consume/produce) Sep 10, 2016
@dusho dusho changed the title [Conflict] Attempt at generic factory furniture (consume/produce) Attempt at generic factory furniture (consume/produce) Sep 10, 2016
@sboigelot
Copy link
Collaborator

This branch break something, the character do not find job anymore: do not happen on master:

FilippoLeon did not find a job.
UnityEngine.Debug:Log(Object)
UberLogger.Logger:ForwardToUnity(Object, LogSeverity, Object, Object[]) (at Assets/UberLogger/UberLogger.cs:504)
UberLogger.Logger:Log(String, Object, LogSeverity, Object, Object[]) (at Assets/UberLogger/UberLogger.cs:452)
Debug:ULogChannel(String, String, Object[]) (at Assets/UberLogger/Debug.cs:233)
Character:GetNewJob() (at Assets/Scripts/Models/Character.cs:608)
Character:Update_DoJob(Single) (at Assets/Scripts/Models/Character.cs:707)
Character:Update(Single) (at Assets/Scripts/Models/Character.cs:346)
World:TickEveryFrame(Single) (at Assets/Scripts/Models/World.cs:167)
WorldController:Update() (at Assets/Scripts/Controllers/WorldController.cs:162)

@sboigelot sboigelot changed the title Attempt at generic factory furniture (consume/produce) [Conflict] [Breaking] Attempt at generic factory furniture (consume/produce) Sep 11, 2016
@dusho
Copy link
Contributor Author

dusho commented Sep 11, 2016

can you describe the testcase? cause nothing different should happen for existing furniture (as it uses LUA code for update). But new code kicks in only for power cell press.. and metal furnace + there is trick with furnace that you have to pick what to smelt there in context menu (right click) , iron ore -> iron plate, copper ore -> copper plate

@sboigelot
Copy link
Collaborator

@dusho, I just tried it again. The test case is: start the game, open the unity console and check the console :)

image

The character stay stuck at the center tile and never does anything

@sboigelot sboigelot changed the title [Conflict] [Breaking] Attempt at generic factory furniture (consume/produce) [Conflict] Attempt at generic factory furniture (consume/produce) Sep 11, 2016
@sboigelot
Copy link
Collaborator

Sorry, my bad, I'm silly, we have to order them to mine now, they won't stockpile ore by themself. This is confusing

@dusho
Copy link
Contributor Author

dusho commented Sep 11, 2016

well actually something is indeed broken.. in my branch they are not picking the ice at all.. in master it works - it's beeing stockpiled
I'm confused, as I did not change stockpile lua code.. and changes in Furniture.cs are related only to Workshop code.. I don't get it.. feels like some automerge messed up something somewhere, but I can't tell where

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<Inventories>
<Inventory type="Raw Iron" maxStackSize="50" basePrice="0.8" category="inv_cat_raw"/>
<Inventory type="Ice" maxStackSize="10" basePrice="1.2" category="inv_cat_raw"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may be the issue about ice? just quick reading

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ye.. wish I saw your comment sooner :)

@dusho
Copy link
Contributor Author

dusho commented Sep 11, 2016

ok fixed.. ice got removed from inventory.xml somehow

@dusho dusho changed the title [Conflict] Attempt at generic factory furniture (consume/produce) Attempt at generic factory furniture (consume/produce) Sep 11, 2016
@sboigelot sboigelot merged commit f27f429 into TeamPorcupine:master Sep 11, 2016
@dusho dusho deleted the feature/generic-furniture-factory branch October 17, 2016 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants