Skip to content

Commit

Permalink
Merge pull request #66 from RimNauts/main
Browse files Browse the repository at this point in the history
Minor update
  • Loading branch information
sindre0830 authored Jun 14, 2023
2 parents 4116d6d + b901bd5 commit 19e65c6
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 1 deletion.
Binary file modified Assemblies/RimNauts2.dll
Binary file not shown.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Changelog
- Add flickable comp to delivery cannon to turn the power on/off
- Add a 'manual' mode to the delivery cannon allowing the user to send delivery when pressing a button
2 changes: 2 additions & 0 deletions Defs/ThingDefs_Items/DeliveryCannon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@
<max_capacity>200</max_capacity>
</li>
<li Class="RimNauts2.Things.Comps.DeliveryCannonTargeter_Properties"></li>
<li Class="RimNauts2.Things.Comps.DeliveryCannonMode_Properties"/>
<li Class="CompProperties_Power">
<compClass>CompPowerTrader</compClass>
<basePowerConsumption>600</basePowerConsumption>
<shortCircuitInRain>false</shortCircuitInRain>
</li>
<li Class="CompProperties_Flickable"/>
</comps>
<inspectorTabs>
<li>ITab_Storage</li>
Expand Down
8 changes: 8 additions & 0 deletions Languages/English/Keyed/Other.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@
<RimNauts.quests_in_space>Allow quests on NEOs</RimNauts.quests_in_space>
<RimNauts.module_required>Requires 1 {0}</RimNauts.module_required>
<RimNauts.only_module>Can only send 1 module into orbit, please remove everything else</RimNauts.only_module>
<RimNauts.Label.delivery_cannon_mode_auto>Change firing mode to manual</RimNauts.Label.delivery_cannon_mode_auto>
<RimNauts.Description.delivery_cannon_mode_auto>Change to manual firing</RimNauts.Description.delivery_cannon_mode_auto>
<RimNauts.Label.delivery_cannon_mode_manual>Change firing mode to automatic</RimNauts.Label.delivery_cannon_mode_manual>
<RimNauts.Description.delivery_cannon_mode_manual>Change to automatic firing</RimNauts.Description.delivery_cannon_mode_manual>
<RimNauts.Label.delivery_cannon_send_delivery>Send delivery</RimNauts.Label.delivery_cannon_send_delivery>
<RimNauts.Description.delivery_cannon_send_delivery>Order the delivery cannon to fire once ready</RimNauts.Description.delivery_cannon_send_delivery>
<RimNauts.Label.delivery_cannon_stop_delivery>Cancel delivery</RimNauts.Label.delivery_cannon_stop_delivery>
<RimNauts.Description.delivery_cannon_stop_delivery>Stop the the delivery cannon from firing</RimNauts.Description.delivery_cannon_stop_delivery>
</LanguageData>
2 changes: 1 addition & 1 deletion Source/RimNauts2/RimNauts2/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace RimNauts2 {
public static class Info {
public static readonly string name = "RimNauts 2";
public static readonly string version = "4.17.1";
public static readonly string version = "4.18.0";
}

public static class Style {
Expand Down
1 change: 1 addition & 0 deletions Source/RimNauts2/RimNauts2/RimNauts2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<Compile Include="Things\Building\PodLauncher.cs" />
<Compile Include="Things\Comps\BuildRoof.cs" />
<Compile Include="Things\Comps\DeliveryCannonCharger.cs" />
<Compile Include="Things\Comps\DeliveryCannonMode.cs" />
<Compile Include="Things\Comps\DeliveryCannonTargeter.cs" />
<Compile Include="Things\Comps\RemoveRoof.cs" />
<Compile Include="Things\Patch\Roof.cs" />
Expand Down
10 changes: 10 additions & 0 deletions Source/RimNauts2/RimNauts2/Things/Building/DeliveryCannon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class DeliveryCannon : RimWorld.Building_Storage {
Comps.Targeter targeter = null;
Comps.Charger charger = null;
RimWorld.CompPowerTrader power = null;
Comps.Mode mode = null;

public Comps.Targeter Targeter {
get {
Expand All @@ -35,6 +36,14 @@ public RimWorld.CompPowerTrader Power {
}
}

public Comps.Mode Mode {
get {
if (mode != null) return mode;
mode = GetComp<Comps.Mode>();
return mode;
}
}

public override void Tick() {
base.Tick();
if (effect != null) {
Expand All @@ -49,6 +58,7 @@ public override void Tick() {
if (Charger.charging()) return;
if (slotGroup.HeldThings.Count() <= 0) return;
if (!Targeter.valid_target()) return;
if (!Mode.can_fire()) return;
launch();
Charger.reset();
}
Expand Down
80 changes: 80 additions & 0 deletions Source/RimNauts2/RimNauts2/Things/Comps/DeliveryCannonMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using Verse;

namespace RimNauts2.Things.Comps {
public class DeliveryCannonMode_Properties : CompProperties {
public DeliveryCannonMode_Properties() => compClass = typeof(Mode);
}

public class Mode : ThingComp {
public DeliveryCannonMode_Properties Props => (DeliveryCannonMode_Properties) props;
public bool automatic = true;
public bool fire_once = false;

public override void PostExposeData() {
base.PostExposeData();
Scribe_Values.Look(ref automatic, "automatic", true);
Scribe_Values.Look(ref fire_once, "fire_once", false);
}

public override IEnumerable<Gizmo> CompGetGizmosExtra() {
if (automatic) {
Command_Action cmd = new Command_Action {
defaultLabel = "RimNauts.Label.delivery_cannon_mode_auto".Translate(),
defaultDesc = "RimNauts.Description.delivery_cannon_mode_auto".Translate(),
icon = ContentFinder<Texture2D>.Get("Icons/RimNauts2_DeliveryCannon_ManualMode", true),
action = new Action(change_mode)
};
yield return cmd;
} else {
Command_Action cmd = new Command_Action {
defaultLabel = "RimNauts.Label.delivery_cannon_mode_manual".Translate(),
defaultDesc = "RimNauts.Description.delivery_cannon_mode_manual".Translate(),
icon = ContentFinder<Texture2D>.Get("Icons/RimNauts2_DeliveryCannon_AutomaticMode", true),
action = new Action(change_mode)
};
yield return cmd;
if (fire_once) {
Command_Action cmd_fire = new Command_Action {
defaultLabel = "RimNauts.Label.delivery_cannon_stop_delivery".Translate(),
defaultDesc = "RimNauts.Description.delivery_cannon_stop_delivery".Translate(),
icon = ContentFinder<Texture2D>.Get("Icons/RimNauts2_DeliveryCannon_Cancel", true),
action = new Action(order_fire)
};
yield return cmd_fire;
} else {
Command_Action cmd_fire = new Command_Action {
defaultLabel = "RimNauts.Label.delivery_cannon_send_delivery".Translate(),
defaultDesc = "RimNauts.Description.delivery_cannon_send_delivery".Translate(),
icon = ContentFinder<Texture2D>.Get("UI/Commands/LaunchShip", true),
action = new Action(order_fire)
};
yield return cmd_fire;
}

}
}

public override string CompInspectStringExtra() {
return "Automatic firing mode: " + automatic;
}

public void change_mode() {
automatic = !automatic;
fire_once = false;
}

public void order_fire() {
fire_once = !fire_once;
}

public bool can_fire() {
if (automatic) return true;
if (!fire_once) return false;
fire_once = false;
return true;
}
}
}
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.

0 comments on commit 19e65c6

Please sign in to comment.