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
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
using System.Linq;
using OpenRpg.AdviceEngine.Advisors;
using OpenRpg.AdviceEngine.Extensions;
using OpenRpg.AdviceEngine.Handlers;
using OpenRpg.AdviceEngine.Handlers.Advisors;
using OpenRpg.AdviceEngine.Variables;
using OpenRpg.Core.Common;

namespace OpenRpg.AdviceEngine.Handlers.Advisors
namespace OpenRpg.AdviceEngine.Rx.Advisors
{
public class AdviceHandler : IAdviceHandler
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using OpenRpg.AdviceEngine.Handlers;
using OpenRpg.AdviceEngine.Handlers.Advisors;
using OpenRpg.AdviceEngine.Handlers.Advisors.Factories;
using OpenRpg.AdviceEngine.Variables;
using OpenRpg.Core.Common;

namespace OpenRpg.AdviceEngine.Handlers.Advisors.Factories
namespace OpenRpg.AdviceEngine.Rx.Advisors.Factories
{
public class DefaultAdviceHandlerFactory : IAdviceHandlerFactory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using OpenRpg.AdviceEngine.Considerations;
using OpenRpg.AdviceEngine.Extensions;
using OpenRpg.AdviceEngine.Handlers;
using OpenRpg.AdviceEngine.Handlers.Considerations;
using OpenRpg.AdviceEngine.Keys;
using OpenRpg.AdviceEngine.Variables;
using OpenRpg.Core.Variables;

namespace OpenRpg.AdviceEngine.Handlers.Considerations
namespace OpenRpg.AdviceEngine.Rx.Considerations
{
public class ConsiderationHandler : IConsiderationHandler
{
Expand All @@ -34,7 +35,7 @@ public ConsiderationHandler(IRefreshScheduler scheduler, IUtilityVariables utili
public void StartHandler() => _isRunning = true;
public void StopHandler() => _isRunning = false;

public void AddConsideration(IConsideration consideration, IObservable<Unit> explicitUpdateTrigger = null)
public void AddConsideration(IConsideration consideration, IObservable<bool> explicitUpdateTrigger = null)
{
_considerations.Add(consideration.UtilityId, consideration);
UtilityVariables[consideration.UtilityId] = 0;
Expand Down Expand Up @@ -66,7 +67,7 @@ public void ClearConsiderations()
{ RemoveConsideration(key); }
}

private void HandleSchedulingForConsideration(IConsideration consideration, IObservable<Unit> explicitUpdateTrigger = null)
private void HandleSchedulingForConsideration(IConsideration consideration, IObservable<bool> explicitUpdateTrigger = null)
{
if (explicitUpdateTrigger != null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using OpenRpg.AdviceEngine.Handlers;
using OpenRpg.AdviceEngine.Handlers.Considerations;
using OpenRpg.AdviceEngine.Handlers.Considerations.Factories;
using OpenRpg.AdviceEngine.Variables;
using OpenRpg.Core.Common;

namespace OpenRpg.AdviceEngine.Handlers.Considerations.Factories
namespace OpenRpg.AdviceEngine.Rx.Considerations.Factories
{
public class DefaultConsiderationHandlerFactory : IConsiderationHandlerFactory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using System;
using System.Reactive;
using System.Reactive.Linq;
using OpenRpg.AdviceEngine.Handlers;

namespace OpenRpg.AdviceEngine.Handlers
namespace OpenRpg.AdviceEngine.Rx.Handlers
{
public class DefaultRefreshScheduler : IRefreshScheduler
{
public IObservable<Unit> PreBuiltScheduler;
public IObservable<bool> PreBuiltScheduler;

public DefaultRefreshScheduler(float defaultFrequency = 0.5f)
{
PreBuiltScheduler = Observable
.Timer(TimeSpan.FromSeconds(defaultFrequency), TimeSpan.FromSeconds(defaultFrequency))
.Select(x => Unit.Default);
.Select(x => true);
}

public IObservable<Unit> DefaultRefreshPeriod => PreBuiltScheduler;
public IObservable<bool> DefaultRefreshPeriod => PreBuiltScheduler;
}
}
23 changes: 23 additions & 0 deletions src/OpenRpg.AdviceEngine.Rx/OpenRpg.AdviceEngine.Rx.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>0.0.0</Version>
<Title>OpenRpg.AdviceEngine.Rx</Title>
<Authors>Grofit (LP)</Authors>
<PackageLicenseUrl>https://github.com/openrpg/OpenRpg/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/openrpg/OpenRpg</PackageProjectUrl>
<Description>A Utility AI flavoured framework to provide advice about what entities should do</Description>
<PackageTags>rpg game-development xna monogame unity godot rx</PackageTags>
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>8</LangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\OpenRpg.AdviceEngine\OpenRpg.AdviceEngine.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Reactive" Version="6.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using OpenRpg.AdviceEngine.Applicators;
using OpenRpg.Core.Requirements;
using OpenRpg.Entities.Requirements;

namespace OpenRpg.AdviceEngine.Advisors.Applicators
{
Expand Down
3 changes: 1 addition & 2 deletions src/OpenRpg.AdviceEngine/Extensions/IAgentExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using OpenRpg.AdviceEngine.Advisors;
using OpenRpg.AdviceEngine.Considerations;
using OpenRpg.AdviceEngine.Keys;
Expand All @@ -10,7 +9,7 @@ namespace OpenRpg.AdviceEngine.Extensions
{
public static class IAgentExtensions
{
public static void AddConsideration(this IAgent agent, IConsideration consideration, IObservable<Unit> explicitUpdateTrigger = null)
public static void AddConsideration(this IAgent agent, IConsideration consideration, IObservable<bool> explicitUpdateTrigger = null)
{ agent.ConsiderationHandler.AddConsideration(consideration, explicitUpdateTrigger); }

public static void RemoveConsideration(this IAgent agent, int utilityId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Reactive;
using OpenRpg.AdviceEngine.Considerations;
using OpenRpg.AdviceEngine.Keys;
using OpenRpg.AdviceEngine.Variables;
Expand All @@ -14,7 +13,7 @@ public interface IConsiderationHandler : IDisposable
void StartHandler();
void StopHandler();

void AddConsideration(IConsideration consideration, IObservable<Unit> explicitUpdateTrigger = null);
void AddConsideration(IConsideration consideration, IObservable<bool> explicitUpdateTrigger = null);
void RemoveConsideration(UtilityKey utilityKey);
void ClearConsiderations();
}
Expand Down
3 changes: 1 addition & 2 deletions src/OpenRpg.AdviceEngine/Handlers/IRefreshScheduler.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using System.Reactive;

namespace OpenRpg.AdviceEngine.Handlers
{
public interface IRefreshScheduler
{
IObservable<Unit> DefaultRefreshPeriod { get; }
IObservable<bool> DefaultRefreshPeriod { get; }
}
}
1 change: 0 additions & 1 deletion src/OpenRpg.AdviceEngine/OpenRpg.AdviceEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<ItemGroup>
<ProjectReference Include="..\OpenRpg.Core\OpenRpg.Core.csproj" />
<ProjectReference Include="..\OpenRpg.CurveFunctions\OpenRpg.CurveFunctions.csproj" />
<PackageReference Include="System.Reactive" Version="6.0.1" />
<ProjectReference Include="..\OpenRpg.Entities\OpenRpg.Entities.csproj" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions src/OpenRpg.Demos.Web/OpenRpg.Demos.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<ProjectReference Include="..\OpenRpg.AdviceEngine.Rx\OpenRpg.AdviceEngine.Rx.csproj" />
<ProjectReference Include="..\OpenRpg.AdviceEngine\OpenRpg.AdviceEngine.csproj" />
<ProjectReference Include="..\OpenRpg.Cards\OpenRpg.Cards.csproj" />
<ProjectReference Include="..\OpenRpg.Combat\OpenRpg.Combat.csproj" />
Expand Down
3 changes: 3 additions & 0 deletions src/OpenRpg.Demos.Web/Pages/AdviceEngine/ExampleSetup.razor
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
@using OpenRpg.AdviceEngine.Extensions
@using OpenRpg.AdviceEngine.Handlers.Advisors.Factories
@using OpenRpg.AdviceEngine.Handlers.Considerations.Factories
@using OpenRpg.AdviceEngine.Rx.Advisors.Factories
@using OpenRpg.AdviceEngine.Rx.Considerations.Factories
@using OpenRpg.AdviceEngine.Rx.Handlers
@using OpenRpg.AdviceEngine.Variables
@using OpenRpg.Core.Requirements
@using OpenRpg.Entities.Requirements
Expand Down
7 changes: 7 additions & 0 deletions src/OpenRpg.sln
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRpg.Editor", "OpenRpg.E
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRpg.Entities", "OpenRpg.Entities\OpenRpg.Entities.csproj", "{776F3D4B-B89F-4407-BAA7-5E367F643B69}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRpg.AdviceEngine.Rx", "OpenRpg.AdviceEngine.Rx\OpenRpg.AdviceEngine.Rx.csproj", "{EBA05F43-4988-4B73-9E11-23360C1BF9A1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -182,6 +184,10 @@ Global
{776F3D4B-B89F-4407-BAA7-5E367F643B69}.Debug|Any CPU.Build.0 = Debug|Any CPU
{776F3D4B-B89F-4407-BAA7-5E367F643B69}.Release|Any CPU.ActiveCfg = Release|Any CPU
{776F3D4B-B89F-4407-BAA7-5E367F643B69}.Release|Any CPU.Build.0 = Release|Any CPU
{EBA05F43-4988-4B73-9E11-23360C1BF9A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EBA05F43-4988-4B73-9E11-23360C1BF9A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBA05F43-4988-4B73-9E11-23360C1BF9A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EBA05F43-4988-4B73-9E11-23360C1BF9A1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{86FD715B-0B33-40EB-B8AC-25EE62398A66} = {6BE3D2A4-F53A-4879-868E-A7522A445FE9}
Expand Down Expand Up @@ -209,5 +215,6 @@ Global
{4BF19FBA-6C19-486B-A87D-D588581DC40E} = {8BEAB2AD-426F-41A7-8378-8D29B8C07D26}
{A71DC9D4-43E8-4E3C-B294-29B0C2E87C39} = {8BEAB2AD-426F-41A7-8378-8D29B8C07D26}
{776F3D4B-B89F-4407-BAA7-5E367F643B69} = {6BE3D2A4-F53A-4879-868E-A7522A445FE9}
{EBA05F43-4988-4B73-9E11-23360C1BF9A1} = {9ABACD9E-828C-48B7-985D-CFC03A05DF8D}
EndGlobalSection
EndGlobal
Loading