-
Notifications
You must be signed in to change notification settings - Fork 13
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
23 changed files
with
604 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1454024362 |
Binary file not shown.
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
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Mehni | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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
53 changes: 53 additions & 0 deletions
53
MoreFactionInteraction/More Flavour/CaravanArrivalAction_VisitMysticalShaman.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,53 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using RimWorld; | ||
using RimWorld.Planet; | ||
using Verse; | ||
|
||
namespace MoreFactionInteraction.More_Flavour | ||
{ | ||
class CaravanArrivalAction_VisitMysticalShaman : CaravanArrivalAction | ||
{ | ||
private MysticalShaman mysticalShaman; | ||
|
||
public override string Label => "VisitPeaceTalks".Translate(mysticalShaman.Label); | ||
public override string ReportString => "CaravanVisiting".Translate(this.mysticalShaman.Label); | ||
|
||
public override void Arrived(Caravan caravan) | ||
{ | ||
this.mysticalShaman.Notify_CaravanArrived(caravan: caravan); | ||
} | ||
|
||
public CaravanArrivalAction_VisitMysticalShaman() | ||
{ | ||
} | ||
|
||
public CaravanArrivalAction_VisitMysticalShaman(MysticalShaman mysticalShaman) | ||
{ | ||
this.mysticalShaman = mysticalShaman; | ||
} | ||
|
||
public static IEnumerable<FloatMenuOption> GetFloatMenuOptions(Caravan caravan, MysticalShaman mysticalShaman) | ||
{ | ||
return CaravanArrivalActionUtility.GetFloatMenuOptions(acceptanceReportGetter: | ||
() => CanVisit(caravan: caravan, mysticalShaman: mysticalShaman), arrivalActionGetter: | ||
() => new CaravanArrivalAction_VisitMysticalShaman(mysticalShaman: mysticalShaman), | ||
label: "VisitPeaceTalks".Translate(mysticalShaman.Label), | ||
caravan: caravan, pathDestination: mysticalShaman.Tile, | ||
revalidateWorldClickTarget: mysticalShaman); | ||
} | ||
|
||
public static FloatMenuAcceptanceReport CanVisit(Caravan caravan, MysticalShaman mysticalShaman) | ||
{ | ||
return mysticalShaman != null && mysticalShaman.Spawned; | ||
} | ||
|
||
public override void ExposeData() | ||
{ | ||
base.ExposeData(); | ||
Scribe_References.Look(refee: ref this.mysticalShaman, label: "mysticalShaman"); | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
MoreFactionInteraction/More Flavour/ChoiceLetter_MysticalShaman.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,77 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Verse; | ||
using RimWorld; | ||
using RimWorld.Planet; | ||
using MoreFactionInteraction.More_Flavour; | ||
|
||
namespace MoreFactionInteraction | ||
{ | ||
public class ChoiceLetter_MysticalShaman : ChoiceLetter | ||
{ | ||
public int tile; | ||
public Faction faction; | ||
public Map map; | ||
public int fee; | ||
private static readonly IntRange TimeoutDaysRange = new IntRange(min: 5, max: 15); | ||
|
||
public override IEnumerable<DiaOption> Choices | ||
{ | ||
get | ||
{ | ||
if (this.ArchivedOnly) | ||
{ | ||
yield return this.Option_Close; | ||
} | ||
else | ||
{ | ||
DiaOption accept = new DiaOption(text: "RansomDemand_Accept".Translate()) | ||
{ | ||
action = () => | ||
{ | ||
MysticalShaman mysticalShaman = (MysticalShaman)WorldObjectMaker.MakeWorldObject(def: MFI_DefOf.MFI_MysticalShaman); | ||
mysticalShaman.Tile = tile; | ||
mysticalShaman.SetFaction(newFaction: faction); | ||
int randomInRange = TimeoutDaysRange.RandomInRange; | ||
mysticalShaman.GetComponent<TimeoutComp>().StartTimeout(ticks: randomInRange * GenDate.TicksPerDay); | ||
Find.WorldObjects.Add(o: mysticalShaman); | ||
|
||
TradeUtility.LaunchSilver(map: this.map, fee: this.fee); | ||
Find.LetterStack.RemoveLetter(let: this); | ||
}, | ||
resolveTree = true | ||
}; | ||
if (!TradeUtility.ColonyHasEnoughSilver(map: this.map, fee: this.fee)) | ||
{ | ||
accept.Disable(newDisabledReason: "NeedSilverLaunchable".Translate(this.fee.ToString())); | ||
} | ||
yield return accept; | ||
|
||
DiaOption reject = new DiaOption(text: "RansomDemand_Reject".Translate()) | ||
{ | ||
action = () => | ||
{ | ||
Find.LetterStack.RemoveLetter(let: this); | ||
}, | ||
resolveTree = true | ||
}; | ||
yield return reject; | ||
yield return this.Option_Postpone; | ||
} | ||
} | ||
} | ||
|
||
public override bool CanShowInLetterStack => base.CanShowInLetterStack && Find.Maps.Contains(item: this.map); | ||
|
||
public override void ExposeData() | ||
{ | ||
base.ExposeData(); | ||
Scribe_References.Look<Map>(refee: ref this.map, label: "MFI_Shaman_Map"); | ||
Scribe_References.Look<Faction>(refee: ref this.faction, label: "MFI_Shaman_Faction"); | ||
Scribe_Values.Look(ref this.tile, "MFI_ShamanTile"); | ||
Scribe_Values.Look<int>(value: ref this.fee, label: "MFI_ShamanFee"); | ||
} | ||
} | ||
} |
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
83 changes: 83 additions & 0 deletions
83
MoreFactionInteraction/More Flavour/IncidentWorker_MysticalShaman.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,83 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using RimWorld; | ||
using Verse; | ||
using RimWorld.Planet; | ||
|
||
namespace MoreFactionInteraction | ||
{ | ||
class IncidentWorker_MysticalShaman : IncidentWorker | ||
{ | ||
private static List<Map> tmpAvailableMaps = new List<Map>(); | ||
|
||
public override float AdjustedChance => base.AdjustedChance; | ||
|
||
private const int MinDistance = 8; | ||
private const int MaxDistance = 22; | ||
private const int TimeoutTicks = GenDate.TicksPerDay; | ||
|
||
protected override bool CanFireNowSub(IncidentParms parms) | ||
{ | ||
return base.CanFireNowSub(parms: parms) && Find.AnyPlayerHomeMap != null | ||
&& !Find.WorldObjects.AllWorldObjects.Any(predicate: o => o.def == MFI_DefOf.MFI_MysticalShaman) | ||
&& Find.FactionManager.AllFactionsVisible.Where(predicate: f => f.def.techLevel <= TechLevel.Neolithic | ||
&& !f.HostileTo(other: Faction.OfPlayer)).TryRandomElement(result: out Faction result) | ||
&& TryFindTile(tile: out int num) | ||
&& TryGetRandomAvailableTargetMap (map: out Map map); | ||
} | ||
|
||
protected override bool TryExecuteWorker(IncidentParms parms) | ||
{ | ||
if (!Find.FactionManager.AllFactionsVisible.Where(predicate: f => f.def.techLevel <= TechLevel.Neolithic | ||
&& !f.HostileTo(other: Faction.OfPlayer)).TryRandomElement(result: out Faction faction)) | ||
return false; | ||
|
||
if (!TryGetRandomAvailableTargetMap(map: out Map map)) | ||
return false; | ||
|
||
if (faction == null) | ||
return false; | ||
|
||
if (map == null) | ||
return false; | ||
|
||
if (!TryFindTile(tile: out int tile)) | ||
return false; | ||
|
||
int fee = Rand.RangeInclusive(min: 400, max: 1000); | ||
|
||
ChoiceLetter_MysticalShaman choiceLetterMysticalShaman = (ChoiceLetter_MysticalShaman)LetterMaker.MakeLetter(label: this.def.letterLabel, text: "MFI_MysticalShamanLetter".Translate(faction.Name, fee.ToString()), def: this.def.letterDef); | ||
choiceLetterMysticalShaman.title = "MFI_MysticalShamanTitle".Translate().CapitalizeFirst(); | ||
choiceLetterMysticalShaman.faction = faction; | ||
choiceLetterMysticalShaman.tile = tile; | ||
choiceLetterMysticalShaman.map = map; | ||
choiceLetterMysticalShaman.fee = fee; | ||
choiceLetterMysticalShaman.StartTimeout(duration: TimeoutTicks); | ||
Find.LetterStack.ReceiveLetter(let: choiceLetterMysticalShaman); | ||
return true; | ||
} | ||
|
||
private static bool TryFindTile(out int tile) | ||
{ | ||
return TileFinder.TryFindNewSiteTile(tile: out tile, minDist: MinDistance, maxDist: MaxDistance, allowCaravans: true, preferCloserTiles: false); | ||
} | ||
|
||
private static bool TryGetRandomAvailableTargetMap(out Map map) | ||
{ | ||
tmpAvailableMaps.Clear(); | ||
List<Map> maps = Find.Maps; | ||
foreach (Map potentialTargetMap in maps) | ||
{ | ||
if (potentialTargetMap.IsPlayerHome && IncidentWorker_QuestTradeRequest.RandomNearbyTradeableSettlement(originTile: potentialTargetMap.Tile) != null) | ||
{ | ||
tmpAvailableMaps.Add(item: potentialTargetMap); | ||
} | ||
} | ||
bool result = tmpAvailableMaps.TryRandomElement(result: out map); | ||
tmpAvailableMaps.Clear(); | ||
return result; | ||
} | ||
} | ||
} |
Oops, something went wrong.