Skip to content

Commit 9d4763f

Browse files
committed
fixes for plugins, IntersectPlugin.props only set up for project references but not debugging yet
1 parent 4912c44 commit 9d4763f

File tree

46 files changed

+813
-432
lines changed

Some content is hidden

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

46 files changed

+813
-432
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,6 @@ packages/
218218
/assets/**
219219
!/assets/*.*
220220

221-
.local/
221+
.local/
222+
223+
Custom*.props

Directory.Build.props

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
<IntersectRepoPath Condition="'$(IntersectRepoPath)' == ''">$(MSBuildProjectDirectory)\..</IntersectRepoPath>
55
</PropertyGroup>
66

7-
<Import Project=".\Common.props" />
7+
<Import Project=".\Common.props"/>
88

9-
<Import Project=".\Intersect.props" />
9+
<Import Condition="Exists('$(IntersectRepoPath)/CustomCommon.props')" Project=".\CustomCommon.props" />
10+
11+
<Import Project=".\Intersect.props"/>
1012

1113
<PropertyGroup>
1214
<IntersectProjectName>$(MSBuildProjectName.Substring(10))</IntersectProjectName>

Examples/Directory.Build.props

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
<Project>
22

3-
<Import Project=".\Plugin.Common.props"/>
4-
5-
<PropertyGroup Condition="'$(IntersectDeveloperTargetsImported)' == ''">
6-
<IntersectRepoPath>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\..\..'))</IntersectRepoPath>
7-
<IntersectProjectName>$(MSBuildProjectName.Substring(10))</IntersectProjectName>
3+
<PropertyGroup>
4+
<IntersectRepoPath Condition="'$(IntersectRepoPath)' == ''">$(MSBuildProjectDirectory)\..\..</IntersectRepoPath>
5+
<_IntersectInRepo>true</_IntersectInRepo>
86
</PropertyGroup>
97

8+
<Import Project="../Directory.Build.props" />
9+
1010
<PropertyGroup>
11-
<IntersectRepoPath Condition="'$(IntersectRepoPath)' == ''">$(INTERSECT_REPO_PATH)</IntersectRepoPath>
12-
<IntersectPath Condition="'$(IntersectPath)' == ''">$(INTERSECT_PATH)</IntersectPath>
13-
<IntersectPath Condition="'$(IntersectPath)' == ''">$(IntersectRepoPath)</IntersectPath>
14-
<BaseStartWorkingDirectory>$(IntersectRepoPath)\assets\development</BaseStartWorkingDirectory>
11+
<IntersectRepoPath>$(MSBuildProjectDirectory)\..\..</IntersectRepoPath>
1512
</PropertyGroup>
1613

17-
<PropertyGroup Label="Language Properties">
18-
<Deterministic>true</Deterministic>
19-
<ImplicitUsings>enable</ImplicitUsings>
20-
<LangVersion>latest</LangVersion>
21-
<Nullable>enable</Nullable>
22-
<TargetFramework>net8.0</TargetFramework>
14+
<PropertyGroup Condition="'$(IntersectDeveloperTargetsImported)' == ''">
15+
<IntersectRepoPath>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\..\..'))</IntersectRepoPath>
16+
<IntersectProjectName>$(MSBuildProjectName.Substring(10))</IntersectProjectName>
2317
</PropertyGroup>
2418

2519
</Project>

Examples/Intersect.Examples.Plugin.Client/ExampleClientPluginEntry.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class ExampleClientPluginEntry : ClientPluginEntry
2727
private bool _disposed;
2828
private Mutex? _mutex;
2929

30-
private bool wasConnected;
30+
private bool _wasConnected;
3131

3232
/// <inheritdoc />
3333
public override void OnBootstrap(IPluginBootstrapContext context)
@@ -97,7 +97,7 @@ public override void OnStart(IClientPluginContext context)
9797
"Assets/join-our-discord.png"
9898
);
9999

100-
context.Lifecycle.LifecycleChangeState += HandleLifecycleChangeState;
100+
context.Lifecycle.LifecycleChangedState += HandleLifecycleChangedState;
101101

102102
context.Lifecycle.GameUpdate += HandleGameUpdate;
103103
}
@@ -119,26 +119,23 @@ private void HandleGameUpdate(
119119
GameUpdateArgs gameUpdateArgs
120120
)
121121
{
122-
if (!wasConnected && context.Network.IsConnected)
122+
if (!_wasConnected && context.Network.IsConnected)
123123
{
124-
wasConnected = true;
124+
_wasConnected = true;
125125

126126
context.Network.PacketSender.Send(new ExamplePluginClientPacket("This is an unprompted client packet."));
127127
}
128128
}
129129

130-
private void HandleLifecycleChangeState(
130+
private void HandleLifecycleChangedState(
131131
IClientPluginContext context,
132132
LifecycleChangeStateArgs lifecycleChangeStateArgs
133133
)
134134
{
135-
Debug.Assert(_buttonTexture != null, nameof(_buttonTexture) + " != null");
136-
137-
var activeInterface = context.Lifecycle.Interface;
138-
139135
switch (lifecycleChangeStateArgs.State)
140136
{
141137
case GameStates.Menu:
138+
var activeInterface = context.Lifecycle.Interface;
142139
AddButtonToMainMenu(context, activeInterface);
143140
break;
144141
}
@@ -169,10 +166,10 @@ IMutableInterface activeInterface
169166
return;
170167
}
171168

172-
button.SetStateTexture(buttonTexture, buttonTexture.Name, ComponentState.Normal);
169+
button.SetAllStatesTexture(buttonTexture);
173170
button.SetSize(buttonTexture.Width, buttonTexture.Height);
174-
button.CurAlignments?.Add(Alignments.Bottom);
175-
button.CurAlignments?.Add(Alignments.Right);
171+
button.Alignment = [Alignments.CenterV, Alignments.Right];
172+
button.AlignmentPadding = new Padding(8);
176173
button.ProcessAlignments();
177174
}
178175

Examples/Intersect.Examples.Plugin.Client/Intersect.Examples.Plugin.Client.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
66
<RootNamespace>Intersect.Examples.Plugin.Client</RootNamespace>
77
<AssemblyName>Intersect.Examples.Plugin.Client</AssemblyName>
8-
<IntersectPluginType>Client</IntersectPluginType>
8+
<IntersectClientPlugin>true</IntersectClientPlugin>
99
</PropertyGroup>
1010

1111
<ItemGroup>
@@ -23,11 +23,10 @@
2323
</ItemGroup>
2424

2525
<ItemGroup>
26-
<ProjectReference Include="..\..\Intersect.Client.Framework\Intersect.Client.Framework.csproj"/>
2726
<ProjectReference Include="..\Intersect.Examples.Plugin\Intersect.Examples.Plugin.csproj"/>
2827
</ItemGroup>
2928

3029
<!-- This has to go here to pick up IntersectPluginType -->
31-
<Import Project="..\Plugin.build.props"/>
30+
<Import Project="..\IntersectPlugin.props"/>
3231

3332
</Project>

Examples/Intersect.Examples.Plugin.ClientVB/ExampleClientPluginEntry.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Public Class ExampleClientPluginEntry
6161
$"{NameOf(ExampleClientPluginEntry)}.{NameOf(OnStart)} writing to the plugin log!")
6262
_buttonTexture = context.ContentManager.LoadEmbedded (Of IGameTexture)(context, ContentType.[Interface],
6363
"join-our-discord.png")
64-
AddHandler context.Lifecycle.LifecycleChangeState, AddressOf HandleLifecycleChangeState
64+
AddHandler context.Lifecycle.LifecycleChangingState, AddressOf HandleLifecycleChangingState
6565
End Sub
6666

6767
''' <inheritdoc />
@@ -74,7 +74,7 @@ Public Class ExampleClientPluginEntry
7474
)
7575
End Sub
7676

77-
Private Sub HandleLifecycleChangeState(
77+
Private Sub HandleLifecycleChangingState(
7878
context As IClientPluginContext,
7979
lifecycleChangeStateArgs As LifecycleChangeStateArgs
8080
)

Examples/Intersect.Examples.Plugin.ClientVB/Intersect.Examples.Plugin.ClientVB.vbproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
66
<RootNamespace>Intersect.Examples.Plugin.Client</RootNamespace>
77
<AssemblyName>Intersect.Examples.Plugin.ClientVB</AssemblyName>
8-
<IntersectPluginType>Client</IntersectPluginType>
8+
<IntersectClientPlugin>true</IntersectClientPlugin>
99
</PropertyGroup>
1010

1111
<ItemGroup>
@@ -23,7 +23,6 @@
2323
</ItemGroup>
2424

2525
<ItemGroup>
26-
<ProjectReference Include="..\..\Intersect.Client.Framework\Intersect.Client.Framework.csproj"/>
2726
<ProjectReference Include="..\Intersect.Examples.Plugin\Intersect.Examples.Plugin.csproj"/>
2827
</ItemGroup>
2928

@@ -43,6 +42,6 @@
4342
</ItemGroup>
4443

4544
<!-- This has to go here to pick up IntersectPluginType -->
46-
<Import Project="..\Plugin.build.props"/>
45+
<Import Project="..\IntersectPlugin.props"/>
4746

4847
</Project>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using Intersect.Client.Plugins;
2+
using Intersect.Framework.Multitarget;
3+
using Intersect.Framework.Reflection;
4+
using Intersect.Plugins;
5+
using Intersect.Server.Plugins;
6+
using Microsoft.Extensions.Logging;
7+
8+
namespace Intersect.Examples.Plugin.Multitarget;
9+
10+
public class ExampleMultitargetPluginEntry : MultitargetPluginEntry
11+
{
12+
public override void OnBootstrap(IPluginBootstrapContext context)
13+
{
14+
context.Logging.Plugin.LogInformation(
15+
"Starting multi-target plugin {PluginName} v{PluginVersion} for a {PluginHostContext}...",
16+
context.Manifest.Name,
17+
context.Manifest.Version,
18+
context.HostPluginContextType.GetName(qualified: true)
19+
);
20+
}
21+
22+
public override void OnStart(IClientPluginContext context)
23+
{
24+
context.Logging.Plugin.LogInformation(
25+
"Starting multi-target plugin {PluginName} v{PluginVersion} in client mode...",
26+
context.Manifest.Name,
27+
context.Manifest.Version
28+
);
29+
}
30+
31+
public override void OnStop(IClientPluginContext context)
32+
{
33+
context.Logging.Plugin.LogInformation(
34+
"Stopping multi-target plugin {PluginName} v{PluginVersion} in client mode...",
35+
context.Manifest.Name,
36+
context.Manifest.Version
37+
);
38+
}
39+
40+
public override void OnStart(IServerPluginContext context)
41+
{
42+
context.Logging.Plugin.LogInformation(
43+
"Starting multi-target plugin {PluginName} v{PluginVersion} in server mode...",
44+
context.Manifest.Name,
45+
context.Manifest.Version
46+
);
47+
}
48+
49+
public override void OnStop(IServerPluginContext context)
50+
{
51+
context.Logging.Plugin.LogInformation(
52+
"Stopping multi-target plugin {PluginName} v{PluginVersion} in server mode...",
53+
context.Manifest.Name,
54+
context.Manifest.Version
55+
);
56+
}
57+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Description>Example Multitarget Plugin - Part of the Intersect 2D Game Creation Suite</Description>
5+
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
6+
<IntersectClientPlugin>true</IntersectClientPlugin>
7+
<IntersectServerPlugin>true</IntersectServerPlugin>
8+
</PropertyGroup>
9+
10+
<!-- This has to go here to pick up IntersectPluginType -->
11+
<Import Project="..\IntersectPlugin.props"/>
12+
13+
</Project>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
using Intersect.Plugins.Interfaces;
2+
using Intersect.Plugins.Manifests.Types;
3+
using Semver;
4+
5+
namespace Intersect.Examples.Plugin.Multitarget;
6+
7+
/// <summary>
8+
/// Defines a plugin manifest in code rather than an embedded manifest.json file.
9+
/// </summary>
10+
public struct Manifest : IManifestHelper, IEquatable<IManifestHelper>, IEquatable<Manifest>
11+
{
12+
// ReSharper disable once AssignNullToNotNullAttribute This will not be null.
13+
/// <inheritdoc />
14+
public string Name => typeof(Manifest).Namespace ?? throw new InvalidOperationException();
15+
16+
// ReSharper disable once AssignNullToNotNullAttribute This will not be null.
17+
/// <inheritdoc />
18+
public string Key => typeof(Manifest).Namespace ?? throw new InvalidOperationException();
19+
20+
/// <inheritdoc />
21+
public SemVersion Version => new(1);
22+
23+
/// <inheritdoc />
24+
public Authors Authors =>
25+
"Ascension Game Dev <[email protected]> (https://github.com/AscensionGameDev/Intersect-Engine)";
26+
27+
/// <inheritdoc />
28+
public string Homepage => "https://github.com/AscensionGameDev/Intersect-Engine";
29+
30+
public override bool Equals(object? obj)
31+
{
32+
return (obj is Manifest other && Equals(other)) ||
33+
(obj is IManifestHelper otherManifestHelper &&
34+
Equals(otherManifestHelper));
35+
}
36+
37+
public override int GetHashCode()
38+
{
39+
return HashCode.Combine(Name, Key, Version, Authors, Homepage);
40+
}
41+
42+
public static bool operator ==(Manifest left, Manifest right)
43+
{
44+
return left.Equals(right);
45+
}
46+
47+
public static bool operator !=(Manifest left, Manifest right)
48+
{
49+
return !(left == right);
50+
}
51+
52+
public bool Equals(Manifest other)
53+
{
54+
return Equals(other as IManifestHelper);
55+
}
56+
57+
public bool Equals(IManifestHelper? other)
58+
{
59+
return other != null &&
60+
string.Equals(Name, other.Name, StringComparison.Ordinal) &&
61+
string.Equals(Key, other.Key, StringComparison.Ordinal) &&
62+
Version.Equals(other.Version) &&
63+
Authors.Equals(other.Authors as IEnumerable<Author>) &&
64+
string.Equals(
65+
Homepage,
66+
other.Homepage,
67+
StringComparison.OrdinalIgnoreCase
68+
);
69+
}
70+
}

0 commit comments

Comments
 (0)