Skip to content

Commit

Permalink
Recipes and constructable destination data
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaPiggy committed Sep 16, 2024
1 parent e3f0025 commit 10a49b4
Show file tree
Hide file tree
Showing 42 changed files with 1,634 additions and 122 deletions.
8 changes: 8 additions & 0 deletions Winch.Examples/ExampleItems/Assets/Dialogues/Steve.yarn
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ exampleitems.steve: Test #gasp #line:exampleitems.steve.test
<<SetIntVariable exampleitems.steve.portrait-state 0>>
-> New #quest #line:exampleitems.steve.new
<<SetIntVariable exampleitems.steve.portrait-state 1>>
===
title: ExampleItems_Steve_RecipeShown
---
exampleitems.steve: Shown #gasp #line:exampleitems.steve.recipeshown
===
title: ExampleItems_Steve_RecipeBuilt
---
exampleitems.steve: Built #gasp #line:exampleitems.steve.recipebuilt
===
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"columns": 4,
"rows": 2,
"mainItemData": "exampleitems.diamond",
"mainItemType": "GENERAL",
"mainItemSubtype": "TRINKET",
"itemsInThisBelongToPlayer": false,
"canAddItemsInQuestMode": true,
"hasUnderlay": false,
"gridKey": "EXAMPLE_RECIPE"
}
217 changes: 110 additions & 107 deletions Winch.Examples/ExampleItems/Assets/Localization/en.json
Original file line number Diff line number Diff line change
@@ -1,116 +1,119 @@
{
"exampleitems.steve.name": "Steve",
"exampleitems.alex.name": "Alex",
"exampleitems.diamond.name": "Diamond",
"exampleitems.diamond.desc": "A strange blue gem with unusual sharp corners. A faint light shines within.",
"exampleitems.mccod.name": "Raw Cod",
"exampleitems.mccod.desc": "Cod are common bucketable aquatic passive mobs found in oceans and a source of raw cod and occasionally bones or bone meal.",
"exampleitems.mcsalmon.name": "Raw Salmon",
"exampleitems.mcsalmon.desc": "Salmon are common bucketable aquatic passive mobs found in oceans and rivers that are a source of raw salmon and occasionally bones or bone meal.",
"exampleitems.mctropical.name": "Tropical Fish",
"exampleitems.mctropical.desc": "Tropical Fish are common bucketable aquatic passive mobs found in oceans, mangrove swamps and lush caves.",
"exampleitems.mcpufferfish.name": "Pufferfish",
"exampleitems.mcpufferfish.desc": "Pufferfish are bucketable aquatic mobs found in oceans. Although they never seek out mobs to attack, they defensively inflate themselves when approached too closely by players, axolotls, or non-aquatic mobs, dealing damage and inflicting Poison on them.",
"exampleitems.rainbowfiddlercrab.name": "Rainbow Fiddler Crab",
"exampleitems.rainbowfiddlercrab.desc": "Crabs are passive mobs with a large arm that are found in mangrove swamps.",
"exampleitems.torch.name": "Torch",
"exampleitems.torch.desc": "A wooden torch that gives off a faint glow when it is lit.",
"exampleitems.nautilus.name": "Nautilus Shell",
"exampleitems.nautilus.desc": "A shell of an extinct cephalopod.",
"exampleitems.musicdisc.name": "Music Disc",
"exampleitems.musicdisc.desc": "An old disc that can play a certain tune if put into a jukebox.",
"exampleitems.rod.name": "Fishing Rod",
"exampleitems.rod.desc": "A wooden rod with string and a hook.",
"exampleitems.furnace.name": "Furnace",
"exampleitems.furnace.desc": "A stone furnace.",
"exampleitems.cobweb.name": "Cobweb",
"exampleitems.cobweb.desc": "A cobweb.",
"exampleitems.pot.name": "Pot",
"exampleitems.pot.desc": "A clay pot.",
"exampleitems.cobwebmaterial.name": "Cobweb (Material)",
"exampleitems.cobwebmaterial.desc": "A cobweb. Collects dredge items instead of fish.",
"exampleitems.potmaterial.name": "Pot (Material)",
"exampleitems.potmaterial.desc": "A clay pot. Collects dredge items instead of fish.",
"exampleitems.bucket.name": "Iron Bucket",
"exampleitems.bucket.desc": "An iron bucket. Collects ooze.",
"exampleitems.heartofthesea.name": "Heart Of The Sea",
"exampleitems.heartofthesea.desc": "An elusive treasure that doesn't just make waves, it gives anyone nearby total control of their underwater environment.",
"exampleitems.durable.name": "Durable",
"exampleitems.durable.desc": "???",
"exampleitems.ice.name": "Ice Block",
"exampleitems.ice.desc": "A block of ice.",
"exampleitems.milk.name": "Milk Bucket",
"exampleitems.milk.desc": "An iron bucket full of milk.",
"exampleitems.nonspatial.name": "Non Spatial",
"exampleitems.nonspatial.desc": "???",
"exampleitems.message.name": "Message Name",
"exampleitems.message.desc": "Message Desc",
"exampleitems.message.body": "Message Body",
"exampleitems.note.name": "Note Name",
"exampleitems.note.desc": "Note Desc",
"exampleitems.note.body": "Note Body",
"exampleitems.journal.name": "Journal Name",
"exampleitems.journal.desc": "Journal Desc",
"exampleitems.journal.body": "Journal Body",
"exampleitems.book.name": "Book Name",
"exampleitems.book.desc": "Book Desc",
"exampleitems.book.completedDesc": "Book CompletedDesc",
"exampleitems.testability.name": "Ability Name",
"exampleitems.testability.desc": "Ability Desc",
"exampleitems.testability.shortDesc": "Ability ShortDesc",
"exampleitems.steve.name": "Steve",
"exampleitems.alex.name": "Alex",
"exampleitems.diamond.name": "Diamond",
"exampleitems.diamond.desc": "A strange blue gem with unusual sharp corners. A faint light shines within.",
"exampleitems.mccod.name": "Raw Cod",
"exampleitems.mccod.desc": "Cod are common bucketable aquatic passive mobs found in oceans and a source of raw cod and occasionally bones or bone meal.",
"exampleitems.mcsalmon.name": "Raw Salmon",
"exampleitems.mcsalmon.desc": "Salmon are common bucketable aquatic passive mobs found in oceans and rivers that are a source of raw salmon and occasionally bones or bone meal.",
"exampleitems.mctropical.name": "Tropical Fish",
"exampleitems.mctropical.desc": "Tropical Fish are common bucketable aquatic passive mobs found in oceans, mangrove swamps and lush caves.",
"exampleitems.mcpufferfish.name": "Pufferfish",
"exampleitems.mcpufferfish.desc": "Pufferfish are bucketable aquatic mobs found in oceans. Although they never seek out mobs to attack, they defensively inflate themselves when approached too closely by players, axolotls, or non-aquatic mobs, dealing damage and inflicting Poison on them.",
"exampleitems.rainbowfiddlercrab.name": "Rainbow Fiddler Crab",
"exampleitems.rainbowfiddlercrab.desc": "Crabs are passive mobs with a large arm that are found in mangrove swamps.",
"exampleitems.torch.name": "Torch",
"exampleitems.torch.desc": "A wooden torch that gives off a faint glow when it is lit.",
"exampleitems.nautilus.name": "Nautilus Shell",
"exampleitems.nautilus.desc": "A shell of an extinct cephalopod.",
"exampleitems.musicdisc.name": "Music Disc",
"exampleitems.musicdisc.desc": "An old disc that can play a certain tune if put into a jukebox.",
"exampleitems.rod.name": "Fishing Rod",
"exampleitems.rod.desc": "A wooden rod with string and a hook.",
"exampleitems.furnace.name": "Furnace",
"exampleitems.furnace.desc": "A stone furnace.",
"exampleitems.cobweb.name": "Cobweb",
"exampleitems.cobweb.desc": "A cobweb.",
"exampleitems.pot.name": "Pot",
"exampleitems.pot.desc": "A clay pot.",
"exampleitems.cobwebmaterial.name": "Cobweb (Material)",
"exampleitems.cobwebmaterial.desc": "A cobweb. Collects dredge items instead of fish.",
"exampleitems.potmaterial.name": "Pot (Material)",
"exampleitems.potmaterial.desc": "A clay pot. Collects dredge items instead of fish.",
"exampleitems.bucket.name": "Iron Bucket",
"exampleitems.bucket.desc": "An iron bucket. Collects ooze.",
"exampleitems.heartofthesea.name": "Heart Of The Sea",
"exampleitems.heartofthesea.desc": "An elusive treasure that doesn't just make waves, it gives anyone nearby total control of their underwater environment.",
"exampleitems.durable.name": "Durable",
"exampleitems.durable.desc": "???",
"exampleitems.ice.name": "Ice Block",
"exampleitems.ice.desc": "A block of ice.",
"exampleitems.milk.name": "Milk Bucket",
"exampleitems.milk.desc": "An iron bucket full of milk.",
"exampleitems.nonspatial.name": "Non Spatial",
"exampleitems.nonspatial.desc": "???",
"exampleitems.message.name": "Message Name",
"exampleitems.message.desc": "Message Desc",
"exampleitems.message.body": "Message Body",
"exampleitems.note.name": "Note Name",
"exampleitems.note.desc": "Note Desc",
"exampleitems.note.body": "Note Body",
"exampleitems.journal.name": "Journal Name",
"exampleitems.journal.desc": "Journal Desc",
"exampleitems.journal.body": "Journal Body",
"exampleitems.book.name": "Book Name",
"exampleitems.book.desc": "Book Desc",
"exampleitems.book.completedDesc": "Book CompletedDesc",
"exampleitems.testability.name": "Ability Name",
"exampleitems.testability.desc": "Ability Desc",
"exampleitems.testability.shortDesc": "Ability ShortDesc",

"exampleitems.dock.name": "Generic Dock",
"exampleitems.largedock.name": "Large Dock",
"exampleitems.makeshiftdock.name": "Makeshift Dock",
"exampleitems.stonedock.name": "Stone Dock",
"exampleitems.plainstonedock.name": "Plain Stone Dock",
"exampleitems.rockdock.name": "Rock Dock",
"exampleitems.destination.rock": "Rock",
"exampleitems.dock.name": "Generic Dock",
"exampleitems.largedock.name": "Large Dock",
"exampleitems.makeshiftdock.name": "Makeshift Dock",
"exampleitems.stonedock.name": "Stone Dock",
"exampleitems.plainstonedock.name": "Plain Stone Dock",
"exampleitems.rockdock.name": "Rock Dock",
"exampleitems.destination.rock": "Rock",

"exampleconfig.separator.title": "Separator",
"exampleconfig.toggle.title": "Toggle",
"exampleconfig.toggle.tooltip": "An on/off dropdown",
"exampleconfig.text.title": "Text",
"exampleconfig.text.tooltip": "A text box",
"exampleconfig.integer.title": "Integer",
"exampleconfig.integer.tooltip": "A number without any decimals",
"exampleconfig.decimal.title": "Decimal",
"exampleconfig.decimal.tooltip": "A number with decimals",
"exampleconfig.slider.title": "Slider",
"exampleconfig.slider.tooltip": "A slider value between min and max numbers",
"exampleconfig.dropdown.title": "Dropdown",
"exampleconfig.dropdown.tooltip": "A dropdown menu with options",
"exampleconfig.dropdown.option.one": "First",
"exampleconfig.dropdown.option.two": "Second",
"exampleconfig.dropdown.option.three": "Third",
"exampleconfig.color.title": "Color",
"exampleconfig.color.tooltip": "A dropdown menu with stock colors",
"exampleconfig.separator.title": "Separator",
"exampleconfig.toggle.title": "Toggle",
"exampleconfig.toggle.tooltip": "An on/off dropdown",
"exampleconfig.text.title": "Text",
"exampleconfig.text.tooltip": "A text box",
"exampleconfig.integer.title": "Integer",
"exampleconfig.integer.tooltip": "A number without any decimals",
"exampleconfig.decimal.title": "Decimal",
"exampleconfig.decimal.tooltip": "A number with decimals",
"exampleconfig.slider.title": "Slider",
"exampleconfig.slider.tooltip": "A slider value between min and max numbers",
"exampleconfig.dropdown.title": "Dropdown",
"exampleconfig.dropdown.tooltip": "A dropdown menu with options",
"exampleconfig.dropdown.option.one": "First",
"exampleconfig.dropdown.option.two": "Second",
"exampleconfig.dropdown.option.three": "Third",
"exampleconfig.color.title": "Color",
"exampleconfig.color.tooltip": "A dropdown menu with stock colors",

"exampleconfig.input": "Input",
"exampleconfig.output": "Output",
"exampleitems.recipe.name": "Recipe Name",
"exampleitems.recipe.description": "Recipe Description",

"line:exampleitems.rock": "A rock",
"line:exampleitems.input": "Opening quest input grid",
"line:exampleitems.output": "Opening quest output grid",
"exampleconfig.input": "Input",
"exampleconfig.output": "Output",

"line:exampleitems.steve.test": "exampleitems.steve: Test",
"line:exampleitems.steve.intro": "exampleitems.steve: Hi",
"line:exampleitems.steve.old": "Old",
"line:exampleitems.steve.new": "New",
"line:exampleitems.rock": "A rock",
"line:exampleitems.input": "Opening quest input grid",
"line:exampleitems.output": "Opening quest output grid",

"line:exampleitems.alex.test": "exampleitems.alex: Test",
"line:exampleitems.steve.test": "exampleitems.steve: Test",
"line:exampleitems.steve.intro": "exampleitems.steve: Hi",
"line:exampleitems.steve.old": "Old",
"line:exampleitems.steve.new": "New",

"line:exampleitems.collector.walk": "You walk in and place the Heart of the Sea on a table by the Collector.",
"line:exampleitems.collector.hand": "COLLECTOR_NAME_KEY: Oh? What is that you have in your hand?",
"line:exampleitems.collector.heart": "Heart of the Sea",
"line:exampleitems.collector.noidea": "I have absolutely no idea",
"line:exampleitems.collector.blockysphere": "COLLECTOR_NAME_KEY: It looks like a sphere but it is blocky.",
"line:exampleitems.collector.wonder": "COLLECTOR_NAME_KEY: I wonder what \"heart\" means.",
"line:exampleitems.collector.what": "COLLECTOR_NAME_KEY: You found it, but have no idea what it is?",
"line:exampleitems.collector.eminating": "COLLECTOR_NAME_KEY: I sense some power eminating from it.",
"line:exampleitems.collector.notsure": "COLLECTOR_NAME_KEY: I'm not sure what I should give you for this...",
"line:exampleitems.collector.hmmm": "COLLECTOR_NAME_KEY: Hmmm...",
"line:exampleitems.collector.this": "COLLECTOR_NAME_KEY: Actually, how about this.",
"line:exampleitems.collector.book": "He closes the crimson book.",
"line:exampleitems.collector.leave": "COLLECTOR_NAME_KEY: Ok you can leave now."
"line:exampleitems.alex.test": "exampleitems.alex: Test",

"line:exampleitems.collector.walk": "You walk in and place the Heart of the Sea on a table by the Collector.",
"line:exampleitems.collector.hand": "COLLECTOR_NAME_KEY: Oh? What is that you have in your hand?",
"line:exampleitems.collector.heart": "Heart of the Sea",
"line:exampleitems.collector.noidea": "I have absolutely no idea",
"line:exampleitems.collector.blockysphere": "COLLECTOR_NAME_KEY: It looks like a sphere but it is blocky.",
"line:exampleitems.collector.wonder": "COLLECTOR_NAME_KEY: I wonder what \"heart\" means.",
"line:exampleitems.collector.what": "COLLECTOR_NAME_KEY: You found it, but have no idea what it is?",
"line:exampleitems.collector.eminating": "COLLECTOR_NAME_KEY: I sense some power eminating from it.",
"line:exampleitems.collector.notsure": "COLLECTOR_NAME_KEY: I'm not sure what I should give you for this...",
"line:exampleitems.collector.hmmm": "COLLECTOR_NAME_KEY: Hmmm...",
"line:exampleitems.collector.this": "COLLECTOR_NAME_KEY: Actually, how about this.",
"line:exampleitems.collector.book": "He closes the crimson book.",
"line:exampleitems.collector.leave": "COLLECTOR_NAME_KEY: Ok you can leave now."
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"titleString": "quest-grid.deliver-materials",
"isSaved": true,
"allowEquipmentInstallation": true,
"allowManualExit": true,
"allowStorageAccess": false,
"gridConfiguration": "exampleitems.recipe",
"gridKey": "EXAMPLE_RECIPE",
"presetGrid": {
"spatialItems": [
{
"id": "exampleitems.diamond",
"x": 0,
"y": 0,
"z": 0
},
{
"id": "exampleitems.diamond",
"x": 3,
"y": 1,
"z": 180
}
]
},
"presetGridMode": "SILHOUETTE",
"questGridExitMode": "REVISITABLE",
"startingDurabilityProportion": 1.0,
"completeConditions": [
{
"type": "ItemCount",
"item": "exampleitems.diamond",
"count": 2
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"questGridConfig": "exampleitems.input",
"itemProduced": "exampleitems.milk",
"onRecipeShownDialogueNodeName": "ExampleItems_Steve_RecipeShown",
"onRecipeBuiltDialogueNodeName": "ExampleItems_Steve_RecipeBuilt",
"quantityProduced": 1,
"researchRequired": 1,
"cost": 50
}
1 change: 1 addition & 0 deletions Winch.Examples/ExampleItems/ExampleEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ public static class ExampleEnums
public static readonly ItemSubtype EXAMPLE;
public static readonly GridKey EXAMPLE_INPUT;
public static readonly GridKey EXAMPLE_OUTPUT;
public static readonly GridKey EXAMPLE_RECIPE;
}
53 changes: 53 additions & 0 deletions Winch.Examples/ExampleItems/ExampleRecipeData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Localization;
using Winch.Core;
using Winch.Data.Recipe;
using Winch.Util;

namespace ExampleItems;

public class ExampleRecipeData : ModdedRecipeData
{
public override LocalizedString GetItemNameKey() => LocalizationUtil.CreateStringsReference("exampleitems.recipe.name");
public override LocalizedString GetItemDescriptionKey() => LocalizationUtil.CreateStringsReference("exampleitems.recipe.description");
public override Color GetItemNameColor() => Color.blue;
public override Color GetItemDescriptionColor() => Color.yellow;
public override Sprite GetSprite() => TextureUtil.GetSprite("RepairIcon");
public override Sprite GetTooltipIcon() => TextureUtil.GetSprite("JunkIcon");

public override int GetQuantityProduced() => 1;

public override int GetWidth() => 2;
public override int GetHeight() => 2;

public override bool IsOneTimeAndAlreadyOwned()
{
WinchCore.Log.Warn("IsOneTimeAndAlreadyOwned");
return ExampleSaveBehaviour.Instance.saveData.recipeCrafted;
}

public override void OnRecipeCompleted()
{
WinchCore.Log.Warn("OnRecipeCompleted");
ExampleSaveBehaviour.Instance.saveData.recipeCrafted = true;
}

public ExampleRecipeData()
{
recipeId = "exampleitems.recipe";
questGridConfig = "exampleitems.recipe";
cost = 1;
quantityProduced = 1;
researchRequired = 1;
onRecipeShownDialogueNodeName = "ExampleItems_Steve_RecipeShown";
onRecipeBuiltDialogueNodeName = "ExampleItems_Steve_RecipeBuilt";
name = recipeId;
this.DontDestroyOnLoad();
Register();
}
}
9 changes: 9 additions & 0 deletions Winch.Examples/ExampleItems/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public static class Loader

public static ExampleSaveParticipant Participant = new ExampleSaveParticipant();

public static ExampleRecipeData exampleRecipeData;

public static ItemData MilkBucket => ItemUtil.GetModdedItemData("exampleitems.milk");
public static VibrationData MilkBucketVibrationData => VibrationUtil.GetModdedVibrationData("exampleitems.milk");

Expand All @@ -21,6 +23,8 @@ public static void Initialize()
SaveUtil.RegisterDataParticipant(Participant);
new GameObject(nameof(ExampleSaveBehaviour)).AddComponent<ExampleSaveBehaviour>();

exampleRecipeData = ScriptableObject.CreateInstance<ExampleRecipeData>().DontDestroyOnLoad();

PoiUtil.AddModdedHarvestableParticlePrefab("MinecraftClownfishParticles", AssetBundleUtil.GetPrefab("exampleitems.bundle", "MinecraftClownfishParticles"));
PoiUtil.AddModdedHarvestableParticlePrefab("MinecraftCodParticles", AssetBundleUtil.GetPrefab("exampleitems.bundle", "MinecraftCodParticles"));
PoiUtil.AddModdedHarvestableParticlePrefab("MinecraftCodParticlesOriginal", AssetBundleUtil.GetPrefab("exampleitems.bundle", "MinecraftCodParticlesOriginal"));
Expand Down Expand Up @@ -99,6 +103,11 @@ private static void OnGameLoaded()
var pontoonSpeakers = DockUtil.GetDockData("dock.pontoon-gc").Speakers;
pontoonSpeakers.SafeAdd(CharacterUtil.GetModdedSpeakerData("exampleitems.alex"));
pontoonSpeakers.SafeAdd(CharacterUtil.GetModdedSpeakerData("exampleitems.steve"));

var rnd = DockUtil.GetConstructableDestinationData("destination.tir-rnd");
rnd.GetRecipeListTier(BuildingTierId.RND_TIER_1).recipes.Add(exampleRecipeData);
var factory = DockUtil.GetConstructableDestinationData("destination.tir-factory");
factory.GetRecipeListTier(BuildingTierId.FACTORY_TIER_3).recipes.Add(RecipeUtil.GetItemRecipeData("exampleitems.recipeitem"));
}

private static void OnGameStarted()
Expand Down
Loading

0 comments on commit 10a49b4

Please sign in to comment.