Skip to content

Commit 1c9c92b

Browse files
merge
2 parents baed45b + 47122c4 commit 1c9c92b

File tree

454 files changed

+12284
-867
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

454 files changed

+12284
-867
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,7 @@ paket-files/
258258

259259
# Python Tools for Visual Studio (PTVS)
260260
__pycache__/
261-
*.pyc
261+
*.pyc
262+
263+
# Docs
264+
docs/LastBuild.log

Docs.shfbproj

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<!-- The configuration and platform will be used to determine which assemblies to include from solution and
5+
project documentation sources -->
6+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8+
<SchemaVersion>2.0</SchemaVersion>
9+
<ProjectGuid>{6bae2f52-652d-4268-923d-0e1198bdc825}</ProjectGuid>
10+
<SHFBSchemaVersion>2017.9.26.0</SHFBSchemaVersion>
11+
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual Studio adds them anyway -->
12+
<AssemblyName>Documentation</AssemblyName>
13+
<RootNamespace>Documentation</RootNamespace>
14+
<Name>Documentation</Name>
15+
<!-- SHFB properties -->
16+
<FrameworkVersion>.NET Framework 3.5</FrameworkVersion>
17+
<OutputPath>Docs\</OutputPath>
18+
<HtmlHelpName>Documentation</HtmlHelpName>
19+
<Language>en-US</Language>
20+
<HelpFileFormat>Website</HelpFileFormat>
21+
<SyntaxFilters>C#</SyntaxFilters>
22+
<PresentationStyle>VS2013</PresentationStyle>
23+
<CleanIntermediates>True</CleanIntermediates>
24+
<KeepLogFile>True</KeepLogFile>
25+
<DisableCodeBlockComponent>False</DisableCodeBlockComponent>
26+
<IndentHtml>False</IndentHtml>
27+
<BuildAssemblerVerbosity>OnlyWarningsAndErrors</BuildAssemblerVerbosity>
28+
<HelpTitle>MLAPI API Reference</HelpTitle>
29+
<HelpFileVersion>1.0.0.0</HelpFileVersion>
30+
<RootNamespaceContainer>False</RootNamespaceContainer>
31+
<NamespaceGrouping>False</NamespaceGrouping>
32+
<Preliminary>True</Preliminary>
33+
<SdkLinkTarget>Blank</SdkLinkTarget>
34+
<NamingMethod>MemberName</NamingMethod>
35+
<ContentPlacement>AboveNamespaces</ContentPlacement>
36+
<SourceCodeBasePath>MLAPI\</SourceCodeBasePath>
37+
<WarnOnMissingSourceContext>False</WarnOnMissingSourceContext>
38+
<DocumentationSources>
39+
<DocumentationSource sourceFile="MLAPI\bin\Debug\MLAPI.dll" />
40+
<DocumentationSource sourceFile="MLAPI\bin\Debug\MLAPI.xml" />
41+
</DocumentationSources>
42+
<MissingTags>Summary, Parameter, Returns, AutoDocumentCtors, TypeParameter, AutoDocumentDispose</MissingTags>
43+
<HeaderText>
44+
</HeaderText>
45+
<FooterText>
46+
</FooterText>
47+
<TransformComponentArguments>
48+
<Argument Key="logoFile" Value="MLAPI_Logo.png" />
49+
<Argument Key="logoHeight" Value="" />
50+
<Argument Key="logoWidth" Value="600" />
51+
<Argument Key="logoAltText" Value="" />
52+
<Argument Key="logoPlacement" Value="right" />
53+
<Argument Key="logoAlignment" Value="right" />
54+
<Argument Key="maxVersionParts" Value="" />
55+
<Argument Key="defaultLanguage" Value="cs" />
56+
<Argument Key="includeEnumValues" Value="true" />
57+
<Argument Key="baseSourceCodeUrl" Value="https://github.com/TwoTenPvP/MLAPI/blob/master/MLAPI/" />
58+
<Argument Key="requestExampleUrl" Value="https://github.com/TwoTenPvP/MLAPI/issues/new" />
59+
</TransformComponentArguments>
60+
</PropertyGroup>
61+
<!-- There are no properties for these groups. AnyCPU needs to appear in order for Visual Studio to perform
62+
the build. The others are optional common platform types that may appear. -->
63+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
64+
</PropertyGroup>
65+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
66+
</PropertyGroup>
67+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
68+
</PropertyGroup>
69+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
70+
</PropertyGroup>
71+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
72+
</PropertyGroup>
73+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
74+
</PropertyGroup>
75+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' ">
76+
</PropertyGroup>
77+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
78+
</PropertyGroup>
79+
<!-- Import the SHFB build targets -->
80+
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
81+
<!-- The pre-build and post-build event properties must appear *after* the targets file import in order to be
82+
evaluated correctly. -->
83+
<PropertyGroup>
84+
<PreBuildEvent>
85+
</PreBuildEvent>
86+
<PostBuildEvent>
87+
</PostBuildEvent>
88+
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
89+
</PropertyGroup>
90+
</Project>

MLAPI/Attributes/BinaryIgnore.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
3+
namespace MLAPI.Attributes
4+
{
5+
/// <summary>
6+
/// The attribute to use for variables that should be automatically. replicated from Server to Client.
7+
/// </summary>
8+
[AttributeUsage(AttributeTargets.Field)]
9+
public class BinaryIgnore : Attribute
10+
{
11+
12+
}
13+
}

MLAPI/Attributes/SyncedVar.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace MLAPI.Attributes
44
{
5+
/// <summary>
6+
/// The attribute to use for variables that should be automatically. replicated from Server to Client.
7+
/// </summary>
58
[AttributeUsage(AttributeTargets.Field)]
69
public class SyncedVar : Attribute
710
{
11+
/// <summary>
12+
/// The method name to invoke when the SyncVar get's updated.
13+
/// </summary>
814
public string hook;
9-
10-
public SyncedVar()
11-
{
12-
13-
}
1415
}
1516
}

MLAPI/Data/Channel.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using UnityEngine.Networking;
6+
7+
namespace MLAPI.Data
8+
{
9+
/// <summary>
10+
/// A data object that represents a NetworkTransport channel
11+
/// </summary>
12+
[Serializable]
13+
public class Channel
14+
{
15+
/// <summary>
16+
/// The name of the channel
17+
/// </summary>
18+
public string Name;
19+
/// <summary>
20+
/// The Transport QOS type
21+
/// </summary>
22+
public QosType Type;
23+
/// <summary>
24+
/// Wheter or not the channel should be encrypted
25+
/// </summary>
26+
public bool Encrypted;
27+
}
28+
}

MLAPI/Data/ClientIdKey.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

MLAPI/Data/FieldType.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
namespace MLAPI.Data
22
{
3+
/// <summary>
4+
/// The datatype used to classify SyncedVars
5+
/// </summary>
36
internal enum FieldType
47
{
58
Bool,

MLAPI/Data/MessageType.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
namespace MLAPI.Data
3+
{
4+
/// <summary>
5+
/// Represents a MLAPI message type
6+
/// </summary>
7+
[Serializable]
8+
public class MessageType
9+
{
10+
/// <summary>
11+
/// The name of the messageType
12+
/// </summary>
13+
public string Name;
14+
/// <summary>
15+
/// Wheter or not the channel should have passthrough support.
16+
/// </summary>
17+
public bool Passthrough;
18+
}
19+
}

MLAPI/Data/NetId.cs

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
using MLAPI.MonoBehaviours.Core;
2+
using System;
3+
4+
namespace MLAPI.Data
5+
{
6+
/// <summary>
7+
/// Represents a ClientId structure
8+
/// </summary>
9+
public struct NetId
10+
{
11+
/// <summary>
12+
/// The hostId this client is on
13+
/// </summary>
14+
public byte HostId;
15+
/// <summary>
16+
/// The connectionId this client is assigned
17+
/// </summary>
18+
public ushort ConnectionId;
19+
/// <summary>
20+
/// Meta data about hte client
21+
/// </summary>
22+
public byte Meta;
23+
24+
/// <summary>
25+
/// Returns wheter or not the clientId represents a -1
26+
/// </summary>
27+
/// <returns><c>true</c>, if host, <c>false</c> otherwise.</returns>
28+
public bool IsHost()
29+
{
30+
return Meta == 1;
31+
}
32+
/// <summary>
33+
/// Returns if this is a invalid clientId, (-2)
34+
/// </summary>
35+
/// <returns><c>true</c>, if invalid, <c>false</c> otherwise.</returns>
36+
public bool IsInvalid()
37+
{
38+
return Meta == 2;
39+
}
40+
/// <summary>
41+
/// Static ServerNetId for comparison
42+
/// </summary>
43+
/// <value>The server net identifier.</value>
44+
public static NetId ServerNetId
45+
{
46+
get
47+
{
48+
return new NetId((byte)NetworkingManager.singleton.serverHostId, (ushort)NetworkingManager.singleton.serverConnectionId, false, false);
49+
}
50+
}
51+
/// <summary>
52+
/// Initializes a new instance of the netId struct from transport values
53+
/// </summary>
54+
/// <param name="hostId">Host identifier.</param>
55+
/// <param name="connectionId">Connection identifier.</param>
56+
/// <param name="isHost">If set to <c>true</c> is host.</param>
57+
/// <param name="isInvalid">If set to <c>true</c> is invalid.</param>
58+
public NetId(byte hostId, ushort connectionId, bool isHost, bool isInvalid)
59+
{
60+
HostId = hostId;
61+
ConnectionId = connectionId;
62+
if (isHost)
63+
Meta = 1;
64+
else if (isInvalid)
65+
Meta = 2;
66+
else
67+
Meta = 0;
68+
}
69+
70+
71+
private static byte[] tempUIntBytes = new byte[4];
72+
private static byte[] tempUShortBytes = new byte[2];
73+
/// <summary>
74+
/// Initializes a new instance of the netId struct from a clientId
75+
/// </summary>
76+
/// <param name="clientId">Client identifier.</param>
77+
public NetId(uint clientId)
78+
{
79+
tempUIntBytes = BitConverter.GetBytes(clientId);
80+
HostId = tempUIntBytes[0];
81+
ConnectionId = BitConverter.ToUInt16(tempUIntBytes, 1);
82+
Meta = tempUIntBytes[3];
83+
}
84+
/// <summary>
85+
/// Gets the clientId.
86+
/// </summary>
87+
/// <returns>The client identifier.</returns>
88+
public uint GetClientId()
89+
{
90+
tempUShortBytes = BitConverter.GetBytes(ConnectionId);
91+
tempUIntBytes[0] = HostId;
92+
tempUIntBytes[1] = tempUShortBytes[0];
93+
tempUIntBytes[2] = tempUShortBytes[1];
94+
tempUIntBytes[3] = Meta;
95+
return BitConverter.ToUInt32(tempUIntBytes, 0);
96+
}
97+
// Rider generated vvv
98+
/// <summary>
99+
/// Determines whether the specified <see cref="object"/> is equal to the current <see cref="T:MLAPI.Data.NetId"/>.
100+
/// </summary>
101+
/// <param name="obj">The <see cref="object"/> to compare with the current <see cref="T:MLAPI.Data.NetId"/>.</param>
102+
/// <returns><c>true</c> if the specified <see cref="object"/> is equal to the current <see cref="T:MLAPI.Data.NetId"/>;
103+
/// otherwise, <c>false</c>.</returns>
104+
public override bool Equals (object obj)
105+
{
106+
if (obj == null || GetType() != obj.GetType())
107+
return false;
108+
109+
NetId key = (NetId)obj;
110+
return (HostId == key.HostId) && (ConnectionId == key.ConnectionId);
111+
}
112+
// Rider generated vvv
113+
/// <summary>
114+
/// Serves as a hash function for a <see cref="T:MLAPI.Data.NetId"/> object.
115+
/// </summary>
116+
/// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a
117+
/// hash table.</returns>
118+
public override int GetHashCode()
119+
{
120+
return (int)GetClientId();
121+
}
122+
// Rider generated vvv
123+
/// <summary>
124+
/// Determines whether a specified instance of <see cref="MLAPI.Data.NetId"/> is equal to another specified <see cref="MLAPI.Data.NetId"/>.
125+
/// </summary>
126+
/// <param name="client1">The first <see cref="MLAPI.Data.NetId"/> to compare.</param>
127+
/// <param name="client2">The second <see cref="MLAPI.Data.NetId"/> to compare.</param>
128+
/// <returns><c>true</c> if <c>client1</c> and <c>client2</c> are equal; otherwise, <c>false</c>.</returns>
129+
public static bool operator ==(NetId client1, NetId client2)
130+
{
131+
return (client1.HostId == client2.HostId && client1.ConnectionId == client2.ConnectionId) || (client1.IsHost() == client2.IsHost());
132+
}
133+
// Rider generated vvv
134+
/// <summary>
135+
/// Determines whether a specified instance of <see cref="MLAPI.Data.NetId"/> is not equal to another specified <see cref="MLAPI.Data.NetId"/>.
136+
/// </summary>
137+
/// <param name="client1">The first <see cref="MLAPI.Data.NetId"/> to compare.</param>
138+
/// <param name="client2">The second <see cref="MLAPI.Data.NetId"/> to compare.</param>
139+
/// <returns><c>true</c> if <c>client1</c> and <c>client2</c> are not equal; otherwise, <c>false</c>.</returns>
140+
public static bool operator !=(NetId client1, NetId client2)
141+
{
142+
return !(client1 == client2);
143+
}
144+
}
145+
}

0 commit comments

Comments
 (0)