Skip to content

Commit

Permalink
2.0.0 lots of new stuff!
Browse files Browse the repository at this point in the history
  • Loading branch information
Cattlesquat committed Jan 26, 2021
1 parent d56e941 commit fce9967
Show file tree
Hide file tree
Showing 20 changed files with 397 additions and 52 deletions.
97 changes: 68 additions & 29 deletions DeathRun/DeathRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class DeathRun
public static global::Utils.ScalarMonitor countdownMonitor { get; set; } = new global::Utils.ScalarMonitor(0f);
public static global::Utils.ScalarMonitor playerMonitor { get; set; } = new global::Utils.ScalarMonitor(0f);

public static Items.FilterChip filterChip = new Items.FilterChip();

//public static bool podGravity = true;
public static float configDirty = 0;

Expand Down Expand Up @@ -89,7 +91,7 @@ public class DeathRun
public static void Patch()
{
CattleLogger.setModName(modName);
CattleLogger.PatchStart("1.4.1");
CattleLogger.PatchStart("1.9.9");

try
{
Expand Down Expand Up @@ -121,6 +123,10 @@ public static void Patch()
O2TanksCore.PatchTanks();
}

CattleLogger.Message("Items - Filter Chip");
filterChip.Patch();
KnownTechHandler.SetAnalysisTechEntry(filterChip.TechType, new List<TechType> { filterChip.TechType }, "Blueprint Unlocked");

//Console.WriteLine(typeof(NitroDamagePatcher).AssemblyQualifiedName);

CattleLogger.Message("Explosion Depth");
Expand Down Expand Up @@ -554,7 +560,6 @@ public static void Patch()
}



// CYCLOPS Depth Modules
CattleLogger.Message("Cyclops Depth Modules");
if (Config.DEATH_VEHICLES.Equals(DeathRun.config.vehicleCosts) || Config.DEATH_VEHICLES_2.Equals(DeathRun.config.vehicleCosts))
Expand Down Expand Up @@ -616,6 +621,31 @@ public static void Patch()
}
techChanges.Add(TechType.Builder, new TechData { craftAmount = 1, Ingredients = ingredients });

ingredients = new List<Ingredient>
{
new Ingredient(TechType.ComputerChip, 1),
new Ingredient(TechType.Magnetite, 2),
new Ingredient(TechType.UraniniteCrystal, 2),
new Ingredient(TechType.Benzene, 1),
};
if (Config.NORMAL.Equals(DeathRun.config.batteryCosts))
{
ingredients.Add(new Ingredient(TechType.Battery, 1));
}
techChanges.Add(TechType.StasisRifle, new TechData { craftAmount = 1, Ingredients = ingredients });

ingredients = new List<Ingredient>
{
new Ingredient(TechType.WiringKit, 1),
new Ingredient(TechType.Magnetite, 2),
new Ingredient(TechType.Lead, 2),
};
if (Config.NORMAL.Equals(DeathRun.config.batteryCosts))
{
ingredients.Add(new Ingredient(TechType.Battery, 1));
}
techChanges.Add(TechType.PropulsionCannon, new TechData { craftAmount = 1, Ingredients = ingredients });

ingredients = new List<Ingredient>
{
new Ingredient(TechType.ComputerChip, 1),
Expand All @@ -640,6 +670,30 @@ public static void Patch()
}
techChanges.Add(TechType.Builder, new TechData { craftAmount = 1, Ingredients = ingredients });

ingredients = new List<Ingredient>
{
new Ingredient(TechType.ComputerChip, 1),
new Ingredient(TechType.Magnetite, 2),
new Ingredient(TechType.UraniniteCrystal, 1),
};
if (Config.NORMAL.Equals(DeathRun.config.batteryCosts))
{
ingredients.Add(new Ingredient(TechType.Battery, 1));
}
techChanges.Add(TechType.StasisRifle, new TechData { craftAmount = 1, Ingredients = ingredients });

ingredients = new List<Ingredient>
{
new Ingredient(TechType.WiringKit, 1),
new Ingredient(TechType.Magnetite, 1),
new Ingredient(TechType.Lead, 2),
};
if (Config.NORMAL.Equals(DeathRun.config.batteryCosts))
{
ingredients.Add(new Ingredient(TechType.Battery, 1));
}
techChanges.Add(TechType.PropulsionCannon, new TechData { craftAmount = 1, Ingredients = ingredients });

ingredients = new List<Ingredient>
{
new Ingredient(TechType.ComputerChip, 1),
Expand All @@ -666,8 +720,8 @@ public static void Patch()

PDAHandler.EditFragmentsToScan(TechType.Beacon, 4);
PDAHandler.EditFragmentsToScan(TechType.Gravsphere, 4);
PDAHandler.EditFragmentsToScan(TechType.StasisRifle, 4);
PDAHandler.EditFragmentsToScan(TechType.PropulsionCannon, 4);
PDAHandler.EditFragmentsToScan(TechType.StasisRifle, 6);
PDAHandler.EditFragmentsToScan(TechType.PropulsionCannon, 6);
PDAHandler.EditFragmentsToScan(TechType.LaserCutter, 6);
PDAHandler.EditFragmentsToScan(TechType.LaserCutterFragment, 6);
PDAHandler.EditFragmentsToScan(TechType.BatteryCharger, 6);
Expand All @@ -679,8 +733,6 @@ public static void Patch()
PDAHandler.EditFragmentsToScan(TechType.BaseMoonpool, 5);
PDAHandler.EditFragmentsToScan(TechType.PowerTransmitter, 2);
PDAHandler.EditFragmentsToScan(TechType.BaseMapRoom, 5);
//PDAHandler.EditFragmentsToScan(TechType.BaseWaterPark, 4);
//PDAHandler.EditFragmentsToScan(TechType.Spotlight, 3);
}
else if (Config.HARD.Equals(DeathRun.config.scansRequired))
{
Expand All @@ -696,9 +748,8 @@ public static void Patch()

PDAHandler.EditFragmentsToScan(TechType.Beacon, 3);
PDAHandler.EditFragmentsToScan(TechType.Gravsphere, 3);
PDAHandler.EditFragmentsToScan(TechType.StasisRifle, 3);
PDAHandler.EditFragmentsToScan(TechType.PropulsionCannon, 3);
PDAHandler.EditFragmentsToScan(TechType.RepulsionCannon, 3);
PDAHandler.EditFragmentsToScan(TechType.StasisRifle, 4);
PDAHandler.EditFragmentsToScan(TechType.PropulsionCannon, 4);
PDAHandler.EditFragmentsToScan(TechType.LaserCutter, 4);
PDAHandler.EditFragmentsToScan(TechType.LaserCutterFragment, 4);
PDAHandler.EditFragmentsToScan(TechType.Welder, 4);
Expand All @@ -711,8 +762,6 @@ public static void Patch()
PDAHandler.EditFragmentsToScan(TechType.BaseMoonpool, 4);
PDAHandler.EditFragmentsToScan(TechType.PowerTransmitter, 2);
PDAHandler.EditFragmentsToScan(TechType.BaseMapRoom, 4);
//PDAHandler.EditFragmentsToScan(TechType.BaseWaterPark, 3);
//PDAHandler.EditFragmentsToScan(TechType.Spotlight, 2);
}


Expand Down Expand Up @@ -771,21 +820,6 @@ public static void Patch()
};
techChanges.Add(TechType.Scanner, new TechData { craftAmount = 1, Ingredients = ingredients });

ingredients = new List<Ingredient>
{
new Ingredient(TechType.ComputerChip, 1),
new Ingredient(TechType.Magnetite, 2),
new Ingredient(TechType.Titanium, 1),
};
techChanges.Add(TechType.StasisRifle, new TechData { craftAmount = 1, Ingredients = ingredients });

ingredients = new List<Ingredient>
{
new Ingredient(TechType.WiringKit, 1),
new Ingredient(TechType.Titanium, 1),
};
techChanges.Add(TechType.PropulsionCannon, new TechData { craftAmount = 1, Ingredients = ingredients });

ingredients = new List<Ingredient>
{
new Ingredient(TechType.Diamond, 2),
Expand Down Expand Up @@ -821,8 +855,13 @@ public static void Patch()
KnownTechHandler.Main.UnlockOnStart(TechType.Copper);
}

CraftDataHandler.SetQuickSlotType(TechType.FirstAidKit, QuickSlotType.Selectable);
CraftDataHandler.SetEquipmentType(TechType.FirstAidKit, EquipmentType.Hand);
CattleLogger.Message("First Aid Kits => Quick Slots");

if (DeathRun.config.firstAidQuickSlot)
{
CraftDataHandler.SetQuickSlotType(TechType.FirstAidKit, QuickSlotType.Selectable);
CraftDataHandler.SetEquipmentType(TechType.FirstAidKit, EquipmentType.Hand);
}

Console.WriteLine("[DeathRun] Patched");

Expand Down Expand Up @@ -887,7 +926,7 @@ public static void Postfix()
if (DeathRun.patchFailed)
{
ErrorMessage.AddMessage("PATCH FAILED - Death Run patch failed to complete. See errorlog (Logoutput.Log) for details.");
DeathRunUtils.CenterMessage("PATCH FAILED", 10, 4);
DeathRunUtils.CenterMessage("PATCH FAILED", 10, 6);
}

DeathRunUtils.ShowHighScores(true);
Expand Down
4 changes: 3 additions & 1 deletion DeathRun/DeathRun.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<ItemGroup>
<Compile Include="Items\ChemosynthesisTank.cs" />
<Compile Include="Items\DummySuitItems.cs" />
<Compile Include="Items\FilterChip.cs" />
<Compile Include="Items\O2TanksCore.cs" />
<Compile Include="Items\PhotosynthesisSmallTank.cs" />
<Compile Include="Items\PhotosynthesisTank.cs" />
Expand All @@ -109,9 +110,10 @@
<Compile Include="NMBehaviours\SpecialtyTanks.cs" />
<Compile Include="NMBehaviours\BendsHUDController.cs" />
<Compile Include="Patchers\AggressionPatcher.cs" />
<Compile Include="Patchers\CompassPatcher.cs" />
<Compile Include="Patchers\SeaglidePatcher.cs" />
<Compile Include="Patchers\BatteryPatcher.cs" />
<Compile Include="Patchers\BreathPatcher.cs" />
<Compile Include="Patchers\CrushDepthPatcher.cs" />
<Compile Include="Patchers\CauseOfDeathPatcher.cs" />
<Compile Include="Patchers\CountdownPatcher.cs" />
<Compile Include="Patchers\DamagePatcher.cs" />
Expand Down
3 changes: 3 additions & 0 deletions DeathRun/DeathRunConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ public class Config : ConfigFile
[Toggle("Show Tips w/ High Scores"), OnChange(nameof(ChangedTips))]
public bool showTips = true;

[Toggle("Allow First Aid in Quickslots")]
public bool firstAidQuickSlot = true;

[Toggle("Don't Tip Escape Pod Over"), OnChange(nameof(ChangedTipOver))]
public bool podStayUpright = false;

Expand Down
4 changes: 2 additions & 2 deletions DeathRun/DeathRunUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace DeathRun

public class DeathRunUtils
{
public const string VERSION = "1.9.8";
public const string VERSION = "2.0.0";

public static CenterText[] centerMessages = new CenterText[] {
new CenterText(250f, true),
Expand Down Expand Up @@ -286,7 +286,7 @@ public static void ShowHighScores(bool should)
}

highScoreLabel.setAlign(TextAnchor.MiddleCenter);
highScoreLabel.ShowMessage("Death Run 1.9.8 - Best Scores");
highScoreLabel.ShowMessage("Death Run 2.0.0 - Best Scores");
highScoreTag.setAlign(TextAnchor.MiddleCenter);

int pick;
Expand Down
115 changes: 115 additions & 0 deletions DeathRun/Items/FilterChip.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* DeathRun mod - Cattlesquat "but standing on the shoulders of giants"
*
* A "chip slot" item that allows breathing surface air (combined with compass function)
*/

using System.Collections.Generic;
using Common;
using SMLHelper.V2.Assets;
using SMLHelper.V2.Crafting;
using UnityEngine;
using UWE;

namespace DeathRun.Items
{
public class FilterChip : Equipable
{
public FilterChip() : base(
"FilterChip",
"Integrated Air Filter",
"Makes surface air breathable. Comes with a free Compass.")
{
}

public override EquipmentType EquipmentType => EquipmentType.Chip;

public override TechType RequiredForUnlock => TechType.Cyclops; //this.TechType;

public override TechGroup GroupForPDA => TechGroup.Personal;

public override TechCategory CategoryForPDA => TechCategory.Equipment;

public override CraftTree.Type FabricatorType => CraftTree.Type.Fabricator;

public override string DiscoverMessage => $"{this.FriendlyName} Unlocked!";
//public override bool AddScannerEntry => true;

public override string[] StepsToFabricatorTab => new string[] { "Personal", "Equipment" };

public override QuickSlotType QuickSlotType => QuickSlotType.None;

public override GameObject GetGameObject()
{
string classid = CraftData.GetClassIdForTechType(TechType.Compass);
if (PrefabDatabase.TryGetPrefabFilename(classid, out string filename))
{
var prefab = Resources.Load<GameObject>(filename);
var obj = GameObject.Instantiate(prefab);

// Get the TechTags and PrefabIdentifiers
var techTag = obj.EnsureComponent<TechTag>();
var prefabIdentifier = obj.GetComponent<PrefabIdentifier>();

// Change them so they fit to our requirements.
techTag.type = TechType;
prefabIdentifier.ClassId = ClassID;

return obj;
}
return null;

/*
// Get the ElectricalDefense module prefab and instantiate it
var path = "WorldEntities/Tools/Compass";
var prefab = Resources.Load<GameObject>(path);
var obj = GameObject.Instantiate(prefab);
// Get the TechTags and PrefabIdentifiers
var techTag = obj.GetComponent<TechTag>();
var prefabIdentifier = obj.GetComponent<PrefabIdentifier>();
// Change them so they fit to our requirements.
techTag.type = TechType;
prefabIdentifier.ClassId = ClassID;
var pick = obj.GetComponent<Pickupable>();
if (pick == null)
{
CattleLogger.Message("Pickupable is Null");
} else
{
if (pick.AllowedToPickUp())
{
CattleLogger.Message("Allowed to pick up");
} else
{
CattleLogger.Message("NOT Allowed to pick up");
}
}
return obj;
*/
}

protected override TechData GetBlueprintRecipe()
{
return new TechData()
{
craftAmount = 1,
Ingredients = new List<Ingredient>()
{
new Ingredient(TechType.Compass, 1),
new Ingredient(TechType.ComputerChip, 1),
new Ingredient(TechType.Polyaniline, 1),
new Ingredient(TechType.AramidFibers, 1),
}
};
}

protected override Atlas.Sprite GetItemSprite()
{
return SpriteManager.Get(TechType.MapRoomHUDChip);
}
}
}
2 changes: 1 addition & 1 deletion DeathRun/Patchers/BatteryPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ internal class EnergyMixin_OnCraftEnd_Patcher
[HarmonyPrefix]
private static void OnCraftEndPrefix(EnergyMixin __instance, TechType techType)
{
if (!Config.NORMAL.Equals(DeathRun.config.batteryCosts))
if (!Config.NORMAL.Equals(DeathRun.config.batteryCosts) && !GameModeUtils.IsOptionActive(GameModeOption.Creative))
{
if (techType != TechType.MapRoomCamera)
{
Expand Down
12 changes: 10 additions & 2 deletions DeathRun/Patchers/BreathingPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ public class BreathingPatcher
public static bool isSurfaceAirPoisoned ()
{
if (Config.BREATHABLE.Equals(DeathRun.config.surfaceAir)) return false;
if (Config.POISONED.Equals(DeathRun.config.surfaceAir)) return true;
if (Config.POISONED.Equals(DeathRun.config.surfaceAir))
{
Inventory main2 = Inventory.main;
if (main2 != null && main2.equipment != null && main2.equipment.GetCount(DeathRun.filterChip.TechType) > 0)
{
return false;
}
return true;
}
return RadiationUtils.isRadiationActive();
}

Expand All @@ -41,7 +49,7 @@ private static bool isAirPoisoned(Player player)
if (LeakingRadiation.main.GetNumLeaks() == 0)
{
if (Config.IRRADIATED.Equals(DeathRun.config.surfaceAir)) return false;
string LDBiome = TerrainDebugGUI.main.CalculateRawBiome(Player.main);
string LDBiome = RadiationUtils.getPlayerBiome();
if (LDBiome.Contains("CrashedShip_Interior"))
{
return false;
Expand Down
Loading

0 comments on commit fce9967

Please sign in to comment.