Skip to content

Commit

Permalink
1.0.82.935
Browse files Browse the repository at this point in the history
  • Loading branch information
SphereII committed Sep 15, 2024
1 parent a8a0e4c commit 9971933
Show file tree
Hide file tree
Showing 25 changed files with 756 additions and 38 deletions.
8 changes: 8 additions & 0 deletions Mods/0-SCore/0-SCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,16 @@
<ItemGroup>
<Compile Include="Features\Challenges\ChallengeTypeSCoreEnums.cs" />
<Compile Include="Features\Challenges\Harmony\ChallengeReadObjective.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveBigFire.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveBlockDestroyed.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveBlockDestroyedByFire.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveCompleteQuestStealth.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveCraftWithIngredient.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveDecapitation.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveEnterPOI.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveExtinguishFire.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveKillWithItem.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveStartFire.cs" />
<Compile Include="Features\Challenges\Scripts\ChallengeObjectiveStealthKillStreak.cs" />
<Compile Include="Features\Challenges\Scripts\SCoreChallengeUtils.cs" />
<Compile Include="Features\Drones\Harmony\EntityDronePatches.cs" />
Expand Down Expand Up @@ -267,6 +274,7 @@
<Compile Include="Scripts\Cache\SphereCache.cs" />
<Compile Include="Scripts\ConsoleCmd\ConsoleCmdActionFireClear.cs" />
<Compile Include="Scripts\ConsoleCmd\ConsoleCmdAdjustCVar.cs" />
<Compile Include="Scripts\ConsoleCmd\ConsoleCmdAdjustMarkup.cs" />
<Compile Include="Scripts\ConsoleCmd\ConsoleCmdReloadDialog.cs" />
<Compile Include="Scripts\ConsoleCmd\ConsoleCmdReloadSCore.cs" />
<Compile Include="Scripts\ConsoleCmd\ConsoleCmdUnitTestSCore.cs" />
Expand Down
30 changes: 30 additions & 0 deletions Mods/0-SCore/Config/Localization.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ xuiCraftFromContainersSCore,"Enemies are nearby! Remote repairing is disabled!",
ChallengeObjectiveCompleteQuestStealth,"Clear a quest with stealth only.",""
challengeObjectiveKillWithItem,"Kill [] Zombies"
challengeObjectiveStealthKillStreak,"Kill [] Zombies in a kill streak"
challengeObjectiveDecapitation,"Decapacitate [] zombies."
challengeObjectiveWith,"with a"
itemWithTags,"items with the tag of "
perceptionChallenges_key,"Perception Challenges"
Expand Down Expand Up @@ -164,4 +165,33 @@ killzombieswithstealthStreakClub,"Kill Streak using a club while sneaking."
killzombieswithstealthStreakClubDesc,"Kill multiple zombies in a row with a club while sneaking."
killzombieswithstealthStreakSpear,"Kill Streak using a spear while sneaking."
killzombieswithstealthStreakSpearDesc,"Kill multiple zombies in a row with a spear while sneaking."
SCore01challenges_key,"SCore 01 Challenges"
decap_title,"Decapitate"
challengeDecapZombies,"Decapitate Zombies"
craftWithIngredient,"Craft using the ingredient"
craftWith01_title,"Craft With Legendary Parts"
craftWith01Short,"Craft any recipe with Legendary Parts"
craftWith02_title,"Craft With Wood"
craftWith02Short,"Craft any recipe with Wood"
onblockDestroyedByFire,"Blocks destroyed by the Fire mod."
BurnWithFire01,"Burn a building down."
BurnWithFire01Desc,"Allow a building to catch fire and burn down."
onblockDestroyed,"Destroy block"
BreakBlock01,"Destroy a Retro Refrigerator ( closed )"
BreakBlock01Short,"Destroy a retro refrigerator (closed )"
BreakBlock02,"Destroy any metal block"
BreakBlock02Short,"Destroy any metal block"
BreakBlock03,"Destroy a Retro Refrigerator ( closed )"
BreakBlock03Short,"Destroy a retro refrigerator (closed ) in any poi within the pine forest"
BreakBlock04,"Destroy any metal block"
BreakBlock04Short,"Destroy any metal block in the pine forest"

SCore02challenges_key,"Fire Bug"
onStartFire,"Start a Fire"

BurnWithFire02,"Start a fire"
BurnWithFire02Desc,"Start a fire with the Fire Mod active."
onBigFire,"Start an out of control fire"
onBigFireDesc,"Start a large, out of control fire"
onExtinguish,"Extinguish a fire"
onExtinguishDesc,"Extinguish a fire with the Fire Mod active."
9 changes: 8 additions & 1 deletion Mods/0-SCore/Features/Challenges/ChallengeTypeSCoreEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ public enum ChallengeObjectiveTypeSCore : byte {
ChallengeObjectiveEnterPOI,
ChallengeObjectiveCompleteQuestStealth,
ChallengeObjectiveKillWithItem,
ChallengeObjectiveStealthKillStreak
ChallengeObjectiveStealthKillStreak,
ChallengeObjectiveDecapitation,
ChallengeObjectiveCraftWithIngredient,
ChallengeObjectiveBlockDestroyedByFire,
ChallengeObjectiveBlockDestroyed,
ChallengeObjectiveStartFire,
ChallengeObjectiveBigFire,
ChallengeObjectiveExtinguishFire
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,55 @@ public static bool Prefix(ref BaseChallengeObjective __result, byte _currentVers
return false;
}


if ((ChallengeObjectiveTypeSCore)_type == ChallengeObjectiveTypeSCore.ChallengeObjectiveDecapitation)
{
__result = new ChallengeObjectiveDecapitation();
__result.Read(_currentVersion, _br);
return false;
}

if ((ChallengeObjectiveTypeSCore)_type == ChallengeObjectiveTypeSCore.ChallengeObjectiveCraftWithIngredient)
{
__result = new ChallengeObjectiveCraftWithIngredient();
__result.Read(_currentVersion, _br);
return false;
}
if ((ChallengeObjectiveTypeSCore)_type == ChallengeObjectiveTypeSCore.ChallengeObjectiveBlockDestroyedByFire)
{
__result = new ChallengeObjectiveBlockDestroyedByFire();
__result.Read(_currentVersion, _br);
return false;
}

if ((ChallengeObjectiveTypeSCore)_type == ChallengeObjectiveTypeSCore.ChallengeObjectiveBlockDestroyed)
{
__result = new ChallengeObjectiveBlockDestroyed();
__result.Read(_currentVersion, _br);
return false;
}

if ((ChallengeObjectiveTypeSCore)_type == ChallengeObjectiveTypeSCore.ChallengeObjectiveStartFire)
{
__result = new ChallengeObjectiveStartFire();
__result.Read(_currentVersion, _br);
return false;
}

if ((ChallengeObjectiveTypeSCore)_type == ChallengeObjectiveTypeSCore.ChallengeObjectiveBigFire)
{
__result = new ChallengeObjectiveBigFire();
__result.Read(_currentVersion, _br);
return false;
}

if ((ChallengeObjectiveTypeSCore)_type == ChallengeObjectiveTypeSCore.ChallengeObjectiveExtinguishFire)
{
__result = new ChallengeObjectiveExtinguishFire();
__result.Read(_currentVersion, _br);
return false;
}



return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using HarmonyLib;
using Challenges;
using UnityEngine;

namespace Challenges {
/*
* A new challenge objective to encourage players to be pyros
*
* <objective type="BigFire, SCore" count="20" />
*/
public class ChallengeObjectiveBigFire : BaseChallengeObjective {
public override ChallengeObjectiveType ObjectiveType =>
(ChallengeObjectiveType)ChallengeObjectiveTypeSCore.ChallengeObjectiveBigFire;

public string LocalizationKey = "onBigFire";
public override string DescriptionText => Localization.Get(LocalizationKey);


public override void HandleAddHooks() {
FireManager.Instance.OnFireUpdate += Check_Block;
}


public override void HandleRemoveHooks() {
FireManager.Instance.OnFireUpdate -= Check_Block;
}

private void Check_Block(int count) {
Current = count;
CheckObjectiveComplete();
}

public override void ParseElement(XElement e) {
base.ParseElement(e);
if (e.HasAttribute("description_key"))
LocalizationKey = e.GetAttribute("description_key");
}

public override BaseChallengeObjective Clone() {
return new ChallengeObjectiveBigFire();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Xml.Linq;
using HarmonyLib;
using Challenges;
using UnityEngine;

namespace Challenges {
/*
* A new challenge objective to destroy certain blocks by name, material, within boimes, and specific POIs.
*
* <objective type="BlockDestroyed, SCore" count="20" biome="burn_forest" poi="traderJen" />
* <objective type="BlockDestroyed, SCore" count="20" biome="pine_forest" poi_tags="wilderness" />
*/
public class ChallengeObjectiveBlockDestroyed : BaseChallengeObjective {
public override ChallengeObjectiveType ObjectiveType =>
(ChallengeObjectiveType)ChallengeObjectiveTypeSCore.ChallengeObjectiveBlockDestroyed;

public string LocalizationKey = "onblockDestroyed";

public string block;
public string material;
public string biome;
public string poi;
public string poi_tags;

public override string DescriptionText => Localization.Get(LocalizationKey);

public override void HandleAddHooks() {
QuestEventManager.Current.BlockDestroy += Check_Block;
QuestEventManager.Current.BlockChange += Check_Block;
}


public override void HandleRemoveHooks() {
QuestEventManager.Current.BlockDestroy -= Check_Block;
QuestEventManager.Current.BlockChange -= Check_Block;

}

private void Check_Block(Block blockold, Block blocknew, Vector3i blockpos) {
Check_Block(blockold, blockpos);
}
private void Check_Block(Block block1, Vector3i blockpos) {
if (!HasPrerequisite(block1)) return;
if (!HasLocationRequirement(blockpos)) return;
Current++;
CheckObjectiveComplete();
}


private bool HasPrerequisite(Block block1) {
if (!string.IsNullOrEmpty(block))
{
if (string.Equals(block, block1.GetBlockName())) return true;
}

if (!string.IsNullOrEmpty(material))
{
if (string.Equals(material, block1.blockMaterial.id)) return true;
}

return false;
}


private bool HasLocationRequirement(Vector3i blockpos) {
if (!string.IsNullOrEmpty(biome))
{
var biomeDefinition = GameManager.Instance.World.GetBiome(blockpos.x, blockpos.z);
if (biomeDefinition.m_sBiomeName != biome) return false;
}
var prefabInstance = GameManager.Instance.World.GetPOIAtPosition(new Vector3(blockpos.x, blockpos.y, blockpos.z));
if (prefabInstance == null) return false;
if (!string.IsNullOrEmpty(poi))
{
if (!prefabInstance.prefab.PrefabName.Equals(poi, StringComparison.InvariantCultureIgnoreCase))
return false;
}
if (!string.IsNullOrEmpty(poi_tags))
{
var fasttags = FastTags<TagGroup.Poi>.Parse(poi_tags);
if (prefabInstance.prefab.tags.Test_AnySet(fasttags)) return false;
}


return true;
}




public override void ParseElement(XElement e) {
base.ParseElement(e);
if (e.HasAttribute("description_key"))
LocalizationKey =e.GetAttribute("description_key");

if (e.HasAttribute("block"))
{
block = e.GetAttribute("block");
}

if (e.HasAttribute("material"))
{
material = e.GetAttribute("material");
}

if (e.HasAttribute("biome"))
{
biome = e.GetAttribute("biome");
}

if (e.HasAttribute("poiname"))
{
poi = e.GetAttribute("poiname");
}

if (e.HasAttribute("poi_tag"))
{
poi_tags = e.GetAttribute("poi_tag");
}


}

public override BaseChallengeObjective Clone() {
return new ChallengeObjectiveBlockDestroyed() {
block = block,
material = material,
biome = biome,
poi = poi,
poi_tags = poi_tags,
LocalizationKey =LocalizationKey

};
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using HarmonyLib;
using Challenges;
using UnityEngine;

namespace Challenges {
/*
* A new challenge objective to enjoy players to be pyros
*
* <objective type="BlockDestroyedByFire, SCore" count="20" />
*/
public class ChallengeObjectiveBlockDestroyedByFire : BaseChallengeObjective {
public override ChallengeObjectiveType ObjectiveType =>
(ChallengeObjectiveType)ChallengeObjectiveTypeSCore.ChallengeObjectiveBlockDestroyedByFire;

public string LocalizationKey = "onblockDestroyedByFire";
public override string DescriptionText => Localization.Get(LocalizationKey);


public override void HandleAddHooks() {
FireManager.Instance.OnDestroyed += Check_Block;
}


public override void HandleRemoveHooks() {
FireManager.Instance.OnDestroyed -= Check_Block;
}

private void Check_Block() {
Current++;
CheckObjectiveComplete();
}

public override void ParseElement(XElement e) {
base.ParseElement(e);
if (e.HasAttribute("description_key"))
LocalizationKey = e.GetAttribute("description_key");
}

public override BaseChallengeObjective Clone() {
return new ChallengeObjectiveBlockDestroyedByFire();
}
}
}
Loading

0 comments on commit 9971933

Please sign in to comment.