Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Source/API/Dummy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class Dummy : IAPI

public bool IsExecutingSyncCommandIssuedBySelf => false;

public void SetThingFilterContext(ThingFilterContext context)
{
throw new UninitializedAPI();
}

public void WatchBegin()
{
throw new UninitializedAPI();
Expand Down
26 changes: 24 additions & 2 deletions Source/API/Interfaces.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Verse;

Expand Down Expand Up @@ -475,8 +476,8 @@ public interface ISynchronizable
void Sync(SyncWorker sync);
}

/// <summary>
/// An attribute that marks a method for pause lock checking It needs a <see cref="bool"/> return type and a single <see cref="Map"/> parameter.
/// <summary>
/// An attribute that marks a method for pause lock checking It needs a <see cref="bool"/> return type and a single <see cref="Map"/> parameter.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class PauseLockAttribute : Attribute
Expand All @@ -489,6 +490,25 @@ public class PauseLockAttribute : Attribute
/// <returns><see langword="true"/> if time should be paused on the specific map</returns>
public delegate bool PauseLockDelegate(Map map);

/// <summary>
/// Objects implementing this marker interface sync their exact type and all declared fields.
/// This is useful when syncing type hierarchies by value.
/// <remarks>The synced object is created uninitialized using reflection (no constructor is called).</remarks>
/// </summary>
public interface ISyncSimple { }

/// <summary>
/// A ThingFilter context provides information for syncing ThingFilter interactions.
/// Inheriting objects should store the ThingFilter's owner in a record property.
/// The type exists because vanilla ThingFilters don't store references to their owners.
/// </summary>
public abstract record ThingFilterContext : ISyncSimple
{
public abstract ThingFilter Filter { get; }
public abstract ThingFilter ParentFilter { get; }
public virtual IEnumerable<SpecialThingFilterDef> HiddenFilters => null;
}

public interface IAPI
{
bool IsHosting { get; }
Expand All @@ -497,6 +517,8 @@ public interface IAPI
bool IsExecutingSyncCommand { get; }
bool IsExecutingSyncCommandIssuedBySelf { get; }

void SetThingFilterContext(ThingFilterContext context);

void WatchBegin();
void Watch(Type targetType, string fieldName, object target = null, object index = null);
void Watch(object target, string fieldName, object index = null);
Expand Down
20 changes: 15 additions & 5 deletions Source/API/MP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Multiplayer.API
public static class MP
{
/// <summary>Contains the API version</summary>
public const string API = "0.3";
public const string API = "0.5";

/// <value>
/// Returns <see langword="true"/> if API is initialized.
Expand Down Expand Up @@ -66,16 +66,26 @@ static MP()
/// </value>
public static string PlayerName => Sync.PlayerName;

/// <value>
/// Returns <see langword="true"/> if currently there's a sync command being executed.
/// <value>
/// Returns <see langword="true"/> if currently there's a sync command being executed.
/// </value>
public static bool IsExecutingSyncCommand => Sync.IsExecutingSyncCommand;

/// <value>
/// Returns <see langword="true"/> if currently there's a sync command being executed that was issued by the current player.
/// Returns <see langword="true"/> if currently there's a sync command being executed that was issued by the current player.
/// </value>
public static bool IsExecutingSyncCommandIssuedBySelf => Sync.IsExecutingSyncCommandIssuedBySelf;

/// <summary>
/// Used to set the ThingFilter context for interactions with ThingFilter UI.
/// Set the context before drawing the ThingFilter and then set it back to <see langword="null"/> after it's drawn.
/// <remarks>
/// This method is not "reentrant". If you call it twice without setting the context back to <see langword="null"/>, the second call will throw an exception.
/// </remarks>
/// </summary>
/// <param name="context">The ThingFilter context object</param>
public static void SetThingFilterContext(ThingFilterContext context) => Sync.SetThingFilterContext(context);

/// <summary>
/// Starts a new synchronization stack.
/// </summary>
Expand Down Expand Up @@ -245,7 +255,7 @@ static MP()
/// </code>
/// </example>
public static void RegisterSyncDialogNodeTree(MethodInfo method) => Sync.RegisterDialogNodeTree(method);

/// <summary>
/// Registers a delegate which will be called to check if the game should be paused on specific map.
/// In case async time is active, only that map will be paused, otherwise all of them will be paused.
Expand Down
2 changes: 1 addition & 1 deletion Source/API/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("0.3")]
[assembly: AssemblyVersion(MP.API)]
[assembly: AssemblyFileVersion(MP.API)]

// The following attributes are used to specify the signing key for the assembly,
Expand Down
5 changes: 3 additions & 2 deletions Source/MultiplayerAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>RimWorld.MultiplayerAPI</PackageId>
<PackageVersion>0.4</PackageVersion>
<PackageVersion>0.5</PackageVersion>
<Authors>notfood</Authors>
<PackageIconUrl>https://i.imgur.com/amy7QJE.png</PackageIconUrl>
<Owners>notfood</Owners>
Expand All @@ -24,7 +24,8 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<DebugType>None</DebugType>
<ReleaseVersion>0.4</ReleaseVersion>
<ReleaseVersion>0.5</ReleaseVersion>
<LangVersion>10</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down