Commit a764879f authored by Adam Leyshon's avatar Adam Leyshon
Browse files

Merge branch 'add_uplink' into 'develop'

Added new uplink building.

See merge request GWP/Release!4
parents 43a9267e 2acc6dae
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<ThingDef ParentName="BuildingBase">
<defName>PrimeUplink</defName>
<label>prime uplink satellite</label>
<thingClass>Glitterworld_Prime.Building_PrimeUplink</thingClass>
<size>(2,2)</size>
<graphicData>
<texPath>Things/Buildings/PrimeUplink</texPath>
<graphicClass>Graphic_Single</graphicClass>
<drawSize>2</drawSize>
</graphicData>
<altitudeLayer>Building</altitudeLayer>
<passability>Impassable</passability>
<terrainAffordanceNeeded>Medium</terrainAffordanceNeeded>
<statBases>
<MaxHitPoints>75</MaxHitPoints>
<WorkToBuild>800</WorkToBuild>
<Flammability>0.5</Flammability>
<Mass>5</Mass>
</statBases>
<description>Required for trading with GlitterWorld Prime.</description>
<drawerType>MapMeshAndRealTime</drawerType>
<drawPlaceWorkersWhileSelected>true</drawPlaceWorkersWhileSelected>
<fillPercent>0.5</fillPercent>
<costList>
<Steel>100</Steel>
<ComponentIndustrial>6</ComponentIndustrial>
</costList>
<comps>
<li Class="CompProperties_Power">
<compClass>CompPowerTrader</compClass>
<basePowerConsumption>200</basePowerConsumption>
<shortCircuitInRain>false</shortCircuitInRain>
</li>
<li Class="CompProperties_Breakdownable"/>
</comps>
<leaveResourcesWhenKilled>false</leaveResourcesWhenKilled>
<designationCategory>Misc</designationCategory>
<rotatable>false</rotatable>
<researchPrerequisites>
<li>MicroelectronicsBasics</li>
</researchPrerequisites>
</ThingDef>
</Defs>
\ No newline at end of file
......@@ -7,9 +7,10 @@
<graphicData>
<texPath>Things/Buildings/PrimeConsole</texPath>
<graphicClass>Graphic_Single</graphicClass>
<drawSize>(5,4)</drawSize>
<drawSize>(1,2)</drawSize>
<damageData>
<rect>(0,0,3,1.8)</rect>
<cornerTL>Damage/Corner</cornerTL>
<cornerTR>Damage/Corner</cornerTR>
<cornerBL>Damage/Corner</cornerBL>
<cornerBR>Damage/Corner</cornerBR>
</damageData>
......@@ -26,10 +27,10 @@
<Flammability>1.0</Flammability>
</statBases>
<description>Allows placing of orders with GlitterWorld Prime</description>
<size>(3,2)</size>
<size>(1,2)</size>
<costList>
<Steel>120</Steel>
<ComponentIndustrial>4</ComponentIndustrial>
<Steel>200</Steel>
<ComponentIndustrial>6</ComponentIndustrial>
</costList>
<interactionCellOffset>(0,0,2)</interactionCellOffset>
<hasInteractionCell>true</hasInteractionCell>
......@@ -41,7 +42,7 @@
<comps>
<li Class="CompProperties_Power">
<compClass>CompPowerTrader</compClass>
<basePowerConsumption>200</basePowerConsumption>
<basePowerConsumption>80</basePowerConsumption>
<shortCircuitInRain>true</shortCircuitInRain>
</li>
<li Class="CompProperties_Flickable"/>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using Verse;
namespace Glitterworld_Prime
{
class Building_PrimeUplink : Building
{
public static bool HasUplink()
{
Map m = Find.CurrentMap;
List<Thing> poweredList = new List<Thing>();
var alllist = m.listerThings.ThingsOfDef(DefDatabase<ThingDef>.GetNamed("PrimeUplink"));
foreach (var uplinkThing in alllist)
{
var trader = uplinkThing.TryGetComp<CompPowerTrader>();
if (trader != null && trader.PowerOn)
{
poweredList.Add(uplinkThing);
}
}
return poweredList.Count > 0;
}
}
}
......@@ -54,7 +54,7 @@ namespace Glitterworld_Prime
if (!Utilities.HasBaseNameBeenSet(myPawn.Map))
{
var floatMenuOption1 =
new FloatMenuOption("Base name has been set or Map not owned by Player".Translate(), null);
new FloatMenuOption("GWPNeedBaseName".Translate(), null);
floatMenuOptions = new List<FloatMenuOption>
{
floatMenuOption1
......@@ -72,6 +72,14 @@ namespace Glitterworld_Prime
{
Action action = delegate
{
if (!Building_PrimeUplink.HasUplink())
{
Messages.Message("GWPNeedUplink".Translate(), this,
MessageTypeDefOf.RejectInput);
return;
}
if (!Building_OrbitalTradeBeacon.AllPowered(Map).Any())
{
Messages.Message("MessageNeedBeaconToTradeWithShip".Translate(), this,
......@@ -99,4 +107,4 @@ namespace Glitterworld_Prime
#endregion
}
}
\ No newline at end of file
}
......@@ -77,11 +77,13 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TraderKindDef_PrimeTrader.cs" />
<Compile Include="DialogPrimeGetData.cs" />
<Compile Include="Building_PrimeUplink.cs" />
<Compile Include="Utilities.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
......
......@@ -39,15 +39,19 @@ namespace Glitterworld_Prime
var sf = new StackTrace().GetFrame(1);
var sw = new StringWriter();
ObjectDumper.Write(context, 0, sw);
WriteErrorMessage(sw.ToString(), sf);
WriteMessage(sw.ToString(), sf);
}
internal static void WriteMessage(string message)
internal static void WriteMessage(string message, StackFrame sf = null)
{
var sf = new StackTrace().GetFrame(1);
if (sf == null)
{
sf = new StackTrace().GetFrame(1);
}
Log.Message($"{Prefix} -> {sf.GetMethod().DeclaringType?.Name}.{sf.GetMethod().Name} -> {message}");
}
#endregion
}
}
\ No newline at end of file
}
......@@ -17,7 +17,6 @@ using RimWorld;
using Steamworks;
using Verse;
using Verse.Steam;
using SimpleJson = RestSharp.SimpleJson;
using Version = System.Version;
namespace Glitterworld_Prime
......@@ -71,7 +70,7 @@ namespace Glitterworld_Prime
if (File.Exists(idPath))
{
var userData = SimpleJson.DeserializeObject<GlitterWorldIdResponse>(File.ReadAllText(idPath));
var userData = RestSharp.SimpleJson.DeserializeObject<GlitterWorldIdResponse>(File.ReadAllText(idPath));
_userId = userData.Hash;
#if DEBUG
LogWriter.WriteMessage($"File found and loaded, User ID is {_userId}");
......@@ -92,7 +91,7 @@ namespace Glitterworld_Prime
{
var idPath = Path.Combine(GenFilePaths.SaveDataFolderPath, "GWP-Config.json");
var json = SimpleJson.SerializeObject(userData);
var json = RestSharp.SimpleJson.SerializeObject(userData);
#if DEBUG
LogWriter.WriteMessage($"Saving User ID JSON: {json}");
#endif
......@@ -365,4 +364,4 @@ namespace Glitterworld_Prime
#endregion
}
}
\ No newline at end of file
}
<?xml version="1.0" encoding="utf-8" ?>
<LanguageData>
<GWPNeedBaseName>Base name has been set or Map not owned by Player</GWPNeedBaseName>
<GWPNeedUplink>You must construct the GlitterWorld Uplink before using the console.</GWPNeedUplink>
</LanguageData>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment