Skip to content

Commit

Permalink
Fixed conductor help localization
Browse files Browse the repository at this point in the history
added golden lamp gives +10 happiness.
  • Loading branch information
JBurlison committed Jul 25, 2019
1 parent 2306edd commit 87e3a4b
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Happiness;
using Pandaros.API.localization;
using System.Linq;
using System.Collections.Generic;

namespace Pandaros.Settlers.ColonyManagement
{
public class DecorHappiness : IHappinessCause
{
public static LocalizationHelper LocalizationHelper { get; private set; } = new LocalizationHelper(GameLoader.NAMESPACE, "Happiness");
public static Dictionary<string, float> DecorBonuses { get; set; } = new Dictionary<string, float>();

public float Evaluate(Colony colony)
{
return DecorBonuses.Sum(kvp => kvp.Value);
}

public string GetDescription(Colony colony, Players.Player player)
{
return LocalizationHelper.LocalizeOrDefault("Decor", player);
}
}
}
158 changes: 158 additions & 0 deletions Pandaros.Settlers/Pandaros.Settlers/Items/Energy/GoldenLamp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
using Jobs;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using NPC;
using Pandaros.API;
using Pandaros.API.Items;
using Pandaros.API.Jobs.Roaming;
using Pandaros.API.Models;
using Pandaros.Settlers.Energy;
using Recipes;
using System.Collections.Generic;
using System.Dynamic;
using System.IO;
using UnityEngine;

namespace Pandaros.Settlers.Items.Transportation
{
public class GoldCubeObjective : IRoamingJobObjective
{
public float WorkTime => 6;
public float WatchArea => 21;
public ItemId ItemIndex => GameLoader.NAMESPACE + ".GoldCube";
private double _nextWorkTime;

public Dictionary<string, IRoamingJobObjectiveAction> ActionCallbacks => new Dictionary<string, IRoamingJobObjectiveAction>()
{
{
GameLoader.NAMESPACE + ".ManaMachineRepair",
new ManaMachineRepairingAction()
}
};

public string ObjectiveCategory => "ManaMachine";

public string name => GameLoader.NAMESPACE + ".GoldCube";

public void DoWork(Colony colony, RoamingJobState state)
{
if (_nextWorkTime < TimeCycle.TotalHours)
{
var fuel = state.GetActionEnergy(GameLoader.NAMESPACE + ".ManaTankRefill");
var durability = state.GetActionEnergy(GameLoader.NAMESPACE + ".ManaMachineRepair");

if (fuel > 0 && durability > 0)
{
ColonyManagement.DecorHappiness.DecorBonuses[nameof(GoldCube)] = 10f;

state.SubtractFromActionEnergy(GameLoader.NAMESPACE + ".ManaTankRefill", .2f);
state.SubtractFromActionEnergy(GameLoader.NAMESPACE + ".ManaMachineRepair", .05f);

if (World.TryGetTypeAt(state.Position, out ItemTypes.ItemType itemType) && itemType.Name == GameLoader.NAMESPACE + ".GoldCubeUnlit")
ServerManager.TryChangeBlock(state.Position, ItemId.GetItemId(GameLoader.NAMESPACE + ".GoldCube"));
}
else
{
if (ColonyManagement.DecorHappiness.DecorBonuses.ContainsKey(nameof(GoldCube)))
ColonyManagement.DecorHappiness.DecorBonuses.Remove(nameof(GoldCube));

if (World.TryGetTypeAt(state.Position, out ItemTypes.ItemType itemType) && itemType.Name == GameLoader.NAMESPACE + ".GoldCube")
ServerManager.TryChangeBlock(state.Position, ItemId.GetItemId(GameLoader.NAMESPACE + ".GoldCubeUnlit"));
}

_nextWorkTime = TimeCycle.TotalHours + 1;
}
}
}

public class GoldCubeRecipe : ICSRecipe
{
public List<RecipeItem> requires => new List<RecipeItem>()
{
new RecipeItem(SettlersBuiltIn.ItemTypes.ADAMANTINE.Id, 40),
new RecipeItem(SettlersBuiltIn.ItemTypes.MANA.Id, 50),
new RecipeItem(ColonyBuiltIn.ItemTypes.GOLDINGOT.Id, 15),
new RecipeItem(SettlersBuiltIn.ItemTypes.REFINEDEMERALD.Id, 15),
new RecipeItem(SettlersBuiltIn.ItemTypes.REFINEDRUBY.Id, 15),
new RecipeItem(SettlersBuiltIn.ItemTypes.REFINEDSAPPHIRE.Id, 15),
new RecipeItem(SettlersBuiltIn.ItemTypes.MAGICWAND.Id)
};

public List<RecipeResult> results => new List<RecipeResult>()
{
new RecipeResult(GameLoader.NAMESPACE + ".GoldCube")
};

public CraftPriority defaultPriority => CraftPriority.Medium;

public bool isOptional => true;

public int defaultLimit => 1;

public string Job => GameLoader.NAMESPACE + ".AdvancedCrafter";

public string name => GameLoader.NAMESPACE + ".GoldCube";
}

public class GoldCubeTextureMapping : CSTextureMapping
{
public override string name => GameLoader.NAMESPACE + ".GoldCube";
public override string albedo => Path.Combine(GameLoader.BLOCKS_ALBEDO_PATH, "GoldCube.png");
public override string emissive => Path.Combine(GameLoader.BLOCKS_EMISSIVE_PATH, "GoldCube.png");
public override string height => Path.Combine(GameLoader.BLOCKS_HEIGHT_PATH, "GoldCube.png");
public override string normal => Path.Combine(GameLoader.BLOCKS_NORMAL_PATH, "GoldCube.png");
}

public class GoldCubeUnlitTextureMapping : CSTextureMapping
{
public override string name => GameLoader.NAMESPACE + ".GoldCubeUnlit";
public override string albedo => Path.Combine(GameLoader.BLOCKS_ALBEDO_PATH, "GoldCube.png");
public override string height => Path.Combine(GameLoader.BLOCKS_HEIGHT_PATH, "GoldCube.png");
public override string normal => Path.Combine(GameLoader.BLOCKS_NORMAL_PATH, "GoldCube.png");
}


public class GoldCube : CSType
{
public override string name { get; set; } = GameLoader.NAMESPACE + ".GoldCube";
public override string icon { get; set; } = Path.Combine(GameLoader.ICON_PATH, "GoldCube.png");
public override string onPlaceAudio { get; set; } = "Pandaros.Settlers.Metal";
public override string onRemoveAudio { get; set; } = "Pandaros.Settlers.MetalRemove";
public override int? maxStackSize { get; set; } = 300;
public override int? destructionTime { get; set; } = 500;
public override string sideall { get; set; } = GameLoader.NAMESPACE + ".GoldCube";
public override JObject customData { get; set; } = JsonConvert.DeserializeObject<JObject>("{ \"torches\": { \"a\": { \"color\": \"#FFD700\", \"intensity\": 12.5, \"range\": 3, \"volume\": 0.5 } } }");
public override ConnectedBlock ConnectedBlock { get; set; } = new ConnectedBlock()
{
BlockType = "ManaPipe",
AutoChange = false,
CalculationType = "Pipe",
Connections = new List<BlockSide>()
{
BlockSide.Xn,
BlockSide.Xp,
BlockSide.Zn,
BlockSide.Zp,
BlockSide.Yn,
BlockSide.Yp
}
};
public override List<string> categories { get; set; } = new List<string>()
{
"Mana",
"Energy",
"Machine",
"GoldCube"
};
}

public class GoldCubeUnlit : GoldCube
{
public override string name { get; set; } = GameLoader.NAMESPACE + ".GoldCubeUnlit";
public override List<OnRemove> onRemove { get; set; } = new List<OnRemove>()
{
new OnRemove(1,1, GameLoader.NAMESPACE + ".GoldCube")
};
public override string sideall { get; set; } = GameLoader.NAMESPACE + ".GoldCubeUnlit";
}
}
17 changes: 17 additions & 0 deletions Pandaros.Settlers/Pandaros.Settlers/Pandaros.Settlers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
<Compile Include="AI\SettlerEvaluation.cs" />
<Compile Include="AI\SettlerReasoning.cs" />
<Compile Include="ColonyManagement\ColonistsBought.cs" />
<Compile Include="ColonyManagement\DecorHappiness.cs" />
<Compile Include="ColonyManagement\NotEnoughBeds.cs" />
<Compile Include="ColonyManagement\CloseBeds.cs" />
<Compile Include="ColonyManagement\ColonistDied.cs" />
Expand All @@ -163,6 +164,7 @@
<Compile Include="Items\Energy\ManaPump.cs" />
<Compile Include="Items\Energy\ManaTank.cs" />
<Compile Include="Items\Armor\Magical\BootsOfFalling.cs" />
<Compile Include="Items\Energy\GoldenLamp.cs" />
<Compile Include="Items\ItemCache.cs" />
<Compile Include="Items\Transportation\TrainStation.cs" />
<Compile Include="Jobs\Construction\ArchitectBuilder.cs" />
Expand Down Expand Up @@ -1077,6 +1079,9 @@
</None>
</ItemGroup>
<ItemGroup>
<Content Include="icons\GoldCube.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="icons\inventory.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -2633,6 +2638,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Textures\albedo\basket.png" />
<Content Include="Textures\albedo\GoldCube.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Textures\albedo\infiniteAdamantine.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -2696,6 +2704,9 @@
<Content Include="Textures\emissive\Artificer_emissive.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Textures\emissive\GoldCube.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Textures\emissive\Manapump_Emissive.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -2765,6 +2776,9 @@
<Content Include="Textures\height\furnaceUnlitTop.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Textures\height\GoldCube.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Textures\height\grassGeneric.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -2960,6 +2974,9 @@
<Content Include="Textures\normal\furnaceUnlitTop.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Textures\normal\GoldCube.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Textures\normal\grassGeneric.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 4 additions & 13 deletions Pandaros.Settlers/Pandaros.Settlers/localization/en-US/en-US.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"types": {
"Pandaros.Settlers.GoldCube": "Golden Lamp",
"Pandaros.Settlers.TrainStation": "Train Station",
"Pandaros.Settlers.Monorail": "Monorail",
"Pandaros.Settlers.PropulsionPlatform": "Propulsion Platform",
Expand Down Expand Up @@ -123,9 +124,6 @@
"Pandaros.Settlers.AutoLoad.rawemerald": "Raw Emerald",
"Pandaros.Settlers.AutoLoad.refinedemerald": "Cut Emerald",
"Pandaros.Settlers.AutoLoad.infiniteemerald": "Emerald Ore",
"Pandaros.Settlers.AutoLoad.egg": "Egg",
"Pandaros.Settlers.AutoLoad.milk": "Milk",
"Pandaros.Settlers.AutoLoad.cake": "Cake",
"Pandaros.Settlers.AutoLoad.lamp": "Lamp",
"Pandaros.Settlers.AutoLoad.ironbar": "Iron Bar",
"Pandaros.Settlers.AutoLoad.ironbarcorner": "Iron Bar Corner",
Expand Down Expand Up @@ -191,9 +189,6 @@
"Pandaros.Settlers.AutoLoad.notwater": "Water",
"Pandaros.Settlers.AutoLoad.marblebricks": "Marble Bricks",
"Pandaros.Settlers.AutoLoad.sledgehammer": "Sledge Hammer",
"Pandaros.Settlers.AutoLoad.beef": "Beef",
"Pandaros.Settlers.AutoLoad.cheese": "Cheese",
"Pandaros.Settlers.AutoLoad.carrot": "Carrot",
"Pandaros.Settlers.AutoLoad.hammer": "Hammer",
"Pandaros.Settlers.AutoLoad.saw": "Saw",
"Pandaros.Settlers.AutoLoad.carpenter": "Carpenter",
Expand Down Expand Up @@ -274,14 +269,9 @@
"Pandaros.Settlers.AutoLoad.berrybushslab": "Berry Bush Slab",
"Pandaros.Settlers.AutoLoad.lava": "Lava",
"Pandaros.Settlers.AutoLoad.lavaslab": "Lava Slab",
"Pandaros.Settlers.AutoLoad.aloe": "Aloe",
"Pandaros.Settlers.AutoLoad.tulip": "Tulip",
"Pandaros.Settlers.AutoLoad.daisy": "Daisy",
"Pandaros.Settlers.AutoLoad.Sunflower": "Sunflower",
"Pandaros.Settlers.AutoLoad.rose": "Rose",
"Pandaros.Settlers.AutoLoad.Flowers1": "Morning Glory"
},
"typeuses": {
"Pandaros.Settlers.GoldCube": "Needs Mana! Connect a mana pipe to it! Colonists love its glow! Provides +10 happiness while running!",
"Pandaros.Settlers.TrainStation": "Place next to monorail. Must be powered by mana pipes. Adds a stop for Propulsion Platform to refuel.",
"Pandaros.Settlers.Monorail": "Rails for Propulsion Platform. Must have at least 1 station to power the Propulsion Platform.",
"Pandaros.Settlers.PropulsionPlatform": "Place on monorial. Right click to ride and get off! Stops at stations to refuel. May have more than one per railsystem.",
Expand Down Expand Up @@ -541,7 +531,8 @@
"SlowGuards": "Guard shooting rate reduced by",
"NotEnoughBeds": "Not Enough Beds",
"NotEnoughJobs": "Not Enough Jobs",
"ColonistsBought": "Slaves Bought ({0}h Remain)"
"ColonistsBought": "Slaves Bought ({0}h Remain)",
"Decor": "Great Decor!"
},
"Beds": {
"BedLocations": "Bed Information",
Expand Down
2 changes: 1 addition & 1 deletion Pandaros.Settlers/Pandaros.Settlers/modInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
},
{
"fileType": "addOrOverrideLocalization",
"relativePath": "localization/en-US/Conductor/en-US.json",
"relativePath": "localization/en-US/help/Conductor/en-US.json",
"index": -99999
},
{
Expand Down

0 comments on commit 87e3a4b

Please sign in to comment.