-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
756 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
Mods/0-SCore/Features/Challenges/Scripts/ChallengeObjectiveBigFire.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
139 changes: 139 additions & 0 deletions
139
Mods/0-SCore/Features/Challenges/Scripts/ChallengeObjectiveBlockDestroyed.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
}; | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
Mods/0-SCore/Features/Challenges/Scripts/ChallengeObjectiveBlockDestroyedByFire.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
Oops, something went wrong.