-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #258 from WakooMan/features/sync-time
Automatic Sync initializing bugfix (Based on 1.7.2 patch PR)
- Loading branch information
Showing
15 changed files
with
164 additions
and
10 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
21 changes: 21 additions & 0 deletions
21
source/Coop/Mod/Patch/CampaignPatches/CompanionsCampaignBehaviorPatches.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,21 @@ | ||
using HarmonyLib; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using TaleWorlds.CampaignSystem.CampaignBehaviors; | ||
|
||
namespace Coop.Mod.Patch.CampaignPatches | ||
{ | ||
[HarmonyPatch(typeof(CompanionsCampaignBehavior))] | ||
internal class CompanionsCampaignBehaviorPatches | ||
{ | ||
[HarmonyPrefix] | ||
[HarmonyPatch("CreateCompanionAndAddToSettlement")] | ||
private static bool Prefix() | ||
{ | ||
return false; | ||
} | ||
} | ||
} |
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,34 @@ | ||
using HarmonyLib; | ||
using TaleWorlds.CampaignSystem; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using NLog; | ||
|
||
namespace Coop.Mod.Patch | ||
{ | ||
[HarmonyPatch(typeof(Hero))] | ||
internal class HeroPatches | ||
{ | ||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); | ||
|
||
[HarmonyPostfix] | ||
[HarmonyPatch(MethodType.Constructor)] | ||
static void Postfix(Hero __instance) | ||
{ | ||
|
||
if(Coop.IsServer) | ||
{ | ||
string stacktrace = Environment.StackTrace; | ||
Logger.Info($"Creating new hero, {__instance.Name}"); | ||
} | ||
else if(CoopClient.Instance.ClientPlaying) | ||
{ | ||
string stacktrace = Environment.StackTrace; | ||
Logger.Info($"Creating new hero, {__instance.Name}"); | ||
} | ||
|
||
} | ||
} | ||
} |
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 System.Threading.Tasks; | ||
using TaleWorlds.CampaignSystem; | ||
using TaleWorlds.Library; | ||
|
||
namespace Coop.Mod.Patch.World | ||
{ | ||
class TimeCommands | ||
{ | ||
private const string sGroupName = "coop"; | ||
private const string sTestGroupName = "test"; | ||
private static Dictionary<string, CampaignTimeControlMode> TimeControlModes = new Dictionary<string, CampaignTimeControlMode>(); | ||
static TimeCommands() | ||
{ | ||
foreach(var e in Enum.GetValues(typeof(CampaignTimeControlMode)).Cast<CampaignTimeControlMode>()) | ||
{ | ||
TimeControlModes.Add(e.ToString(),e); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Sets time speed for to the speed given as argument. | ||
/// </summary> | ||
/// <param name="parameters">Expects a speed value to set speed</param> | ||
/// <returns>Changed value in TimeControlMode.</returns> | ||
[CommandLineFunctionality.CommandLineArgumentFunction("set_time_speed", sTestGroupName)] | ||
public static string SetTimeSpeed(List<string> parameters) | ||
{ | ||
if (parameters.Count != 1 || !int.TryParse(parameters[0], out int timeSpeed) || timeSpeed < 0 || timeSpeed > 2) | ||
{ | ||
return $"Usage: \"{sTestGroupName}.set_time_speed [time_speed (0-2)]."; | ||
} | ||
|
||
var oldTimeControlMode = Campaign.Current.TimeControlMode; | ||
Campaign.Current.SetTimeSpeed(timeSpeed); | ||
|
||
return $"Campaign TimeControlMode changed from {oldTimeControlMode} to {Campaign.Current.TimeControlMode}"; | ||
} | ||
|
||
/// <summary> | ||
/// Gets time control mode for the Campaign. | ||
/// </summary> | ||
/// <returns>TimeControlMode value.</returns> | ||
[CommandLineFunctionality.CommandLineArgumentFunction("get_time_speed", sTestGroupName)] | ||
public static string GetTimeSpeed(List<string> parameters) | ||
{ | ||
return $"Campaign TimeControlMode is {Campaign.Current.TimeControlMode}"; | ||
} | ||
} | ||
} |
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
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