Skip to content

Commit

Permalink
Last update for this version
Browse files Browse the repository at this point in the history
  • Loading branch information
guerro323 committed Aug 14, 2020
1 parent b1bda18 commit 9d4403e
Show file tree
Hide file tree
Showing 31 changed files with 594 additions and 54 deletions.
1 change: 1 addition & 0 deletions PataNext.Export.Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ static async Task Main(string[] args)
gameBootstrap.GameEntity.Set(typeof(PataNext.Module.Simulation.CustomModule));
gameBootstrap.GameEntity.Set(typeof(PataNext.Simulation.Client.Module));
gameBootstrap.GameEntity.Set(typeof(PataNext.Simulation.Mixed.Abilities.Module));
gameBootstrap.GameEntity.Set(typeof(PataNext.Simulation.Client.Abilities.Module));
gameBootstrap.GameEntity.Set(typeof(Feature.RhythmEngineAudio.CustomModule));
gameBootstrap.GameEntity.Set(typeof(PataNext.Game.Module));
gameBootstrap.GameEntity.Set(typeof(PataNext.Game.Client.Resources.Module));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class BgmDefaultDirector : BgmDirectorBase
{
public readonly Bindable<IncomingCommandData> IncomingCommand;
public readonly Bindable<bool> IsFever;
public readonly Bindable<int> HeroModeCombo;

private readonly Dictionary<int, int> commandCycle;

Expand All @@ -20,8 +21,9 @@ public BgmDefaultDirector(JsonElement elem, BgmStore store, BgmDirectorBase pare
Loader = new BgmDefaultSamplesLoader(store);
IncomingCommand = new Bindable<IncomingCommandData>();
IsFever = new Bindable<bool>();
HeroModeCombo = new Bindable<int>();

commandCycle = new Dictionary<int, int>();
commandCycle = new Dictionary<int, int>();
}

public int GetNextCycle(CharBuffer64 commandId, string state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@
using GameHost.Simulation.Utility.EntityQuery;
using GameHost.Simulation.Utility.Resource.Components;
using Microsoft.Extensions.Logging;
using PataNext.Module.Simulation.Components.GamePlay.Abilities;
using PataNext.Module.Simulation.Components.GamePlay.RhythmEngine;
using PataNext.Module.Simulation.Passes;
using PataNext.Module.Simulation.Resources;
using PataNext.Module.Simulation.Resources.Keys;
using PataNext.Simulation.Client.Systems;
using PataNext.Simulation.mixed.Components.GamePlay.Abilities;
using StormiumTeam.GameBase.Camera.Components;
using StormiumTeam.GameBase.Roles.Components;
using StormiumTeam.GameBase.Roles.Descriptions;
using ZLogger;


Expand All @@ -24,11 +30,13 @@ namespace PataNext.Feature.RhythmEngineAudio.BGM.Directors
public class BgmDefaultDirectorCommandSystem : BgmDirectorySystemBase<BgmDefaultDirector, BgmDefaultSamplesLoader>
{
private readonly Dictionary<CharBuffer64, ComboBasedOutput> commandComboBasedOutputs;
private readonly Bindable<List<ResourceHandle<AudioResource>>> onHeroModeCombo;
private readonly Bindable<ResourceHandle<AudioResource>> onEnterFever;
private readonly Bindable<ResourceHandle<AudioResource>> onFeverLost;

private EntitySet commandSet;
private LoadAudioResourceSystem loadAudio;
private AbilityHeroVoiceManager heroVoiceManager;

private CustomModule module;

Expand All @@ -39,11 +47,13 @@ public class BgmDefaultDirectorCommandSystem : BgmDirectorySystemBase<BgmDefault
public BgmDefaultDirectorCommandSystem(WorldCollection collection) : base(collection)
{
commandComboBasedOutputs = new Dictionary<CharBuffer64, ComboBasedOutput>();
onHeroModeCombo = new Bindable<List<ResourceHandle<AudioResource>>>();

onEnterFever = new Bindable<ResourceHandle<AudioResource>>();
onFeverLost = new Bindable<ResourceHandle<AudioResource>>();

DependencyResolver.Add(() => ref loadAudio);
DependencyResolver.Add(() => ref heroVoiceManager);
DependencyResolver.Add(() => ref module);
DependencyResolver.Add(() => ref logger);
}
Expand All @@ -57,6 +67,20 @@ protected override async void OnDependenciesResolved(IEnumerable<object> depende

onEnterFever.Default = loadAudio.Load("voice_fever.wav", storage);
onFeverLost.Default = loadAudio.Load("fever_lost.wav", storage);

onHeroModeCombo.Default = new List<ResourceHandle<AudioResource>>();

var heroModeComboStorage = await storage.GetOrCreateDirectoryAsync("HeroMode/Combo/");
foreach (var file in heroModeComboStorage.GetFilesAsync("return*.wav").Result)
{
var resource = loadAudio.Load(file);

var index = file.Name[6];
if (index < onHeroModeCombo.Default.Count)
onHeroModeCombo.Default.Insert(index, resource);
else
onHeroModeCombo.Default.Add(resource);
}

audioPlayer = World.Mgr.CreateEntity();
AudioPlayerUtility.Initialize(audioPlayer, new StandardAudioPlayerComponent());
Expand Down Expand Up @@ -84,6 +108,35 @@ protected override void OnUpdatePass()

loadFiles();

var isHeroMode = false;
var heroModeCommandResource = default(ResourceHandle<AudioResource>);
if (TryGetComponentData(LocalEngine, out Relative<PlayerDescription> relativePlayer))
{
CameraState cameraState = default, localCamState = default;
if (TryGetComponentData(relativePlayer.Target, out ServerCameraState serverCameraState))
{
cameraState = serverCameraState.Data;
}
else if (TryGetComponentData(relativePlayer.Target, out LocalCameraState localCameraState))
{
cameraState = localCameraState.Data;
}

if ((int) localCamState.Mode > (int) cameraState.Mode)
cameraState = localCamState;

if (GameWorld.Contains(cameraState.Target) && TryGetComponentData(cameraState.Target, out OwnerActiveAbility activeAbility)
&& activeAbility.Incoming != default
&& TryGetComponentData(activeAbility.Incoming, out AbilityActivation abilityActivation)
&& TryGetComponentData(activeAbility.Incoming, out AbilityState abilityState)
&& abilityActivation.Type == EAbilityActivationType.HeroMode)
{
isHeroMode = true;
if (TryGetComponentData(activeAbility.Incoming, out NamedAbilityId namedAbilityId))
heroModeCommandResource = heroVoiceManager.GetResource(namedAbilityId.Value.ToString());
}
}

var comboSettings = GameWorld.GetComponentData<GameCombo.Settings>(LocalEngine);
var comboState = GameWorld.GetComponentData<GameCombo.State>(LocalEngine);

Expand Down Expand Up @@ -124,11 +177,29 @@ protected override void OnUpdatePass()
if (doFeverShout)
{
resourceHandle = onEnterFever.Value.IsLoaded ? onEnterFever.Value : onEnterFever.Default;

Director.HeroModeCombo.Value = 0;
}
else if (isHeroMode)
{
if (heroModeCommandResource.IsLoaded)
resourceHandle = heroModeCommandResource;
else Director.HeroModeCombo.Value++;

if (Director.HeroModeCombo.Value > 0)
{
var comboList = onHeroModeCombo.Value ?? onHeroModeCombo.Default;
resourceHandle = comboList[Director.HeroModeCombo.Value % comboList.Count];
}

Director.HeroModeCombo.Value++;
}
else if (output.Map.TryGetValue(key, out var resourceMap)
&& resourceMap.TryGetValue(Director.GetNextCycle(LocalInformation.NextCommandStr, key), out var resource))
{
resourceHandle = resource;

Director.HeroModeCombo.Value = 0;
}

if (resourceHandle.Entity != default && resourceHandle.IsLoaded)
Expand Down
6 changes: 5 additions & 1 deletion PataNext.Feature.RhythmEngineAudio/CustomModule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DefaultEcs;
using System;
using DefaultEcs;
using GameHost.Core.Modules;
using GameHost.Injection;
using GameHost.Simulation.Application;
Expand Down Expand Up @@ -27,6 +28,9 @@ public CustomModule(Entity source, Context ctxParent, GameHostModuleDescription
simulationApplication.Data.Collection.GetOrCreate(typeof(LoadActiveBgmSystem));
}
}

foreach (var file in DllStorage.GetFilesAsync("*.*").Result)
Console.WriteLine("---------- " + file.Name + " , " + file.FullName);

global.Collection.GetOrCreate(typeof(BgmManager));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ protected override void OnUpdatePass()
{
if (currentLoadedBgm.Span.SequenceEqual(LocalInformation.ActiveBgmId.Span) && isBgmLoaded)
return;

Console.WriteLine(">>>> 0");

currentLoadedBgm = LocalInformation.ActiveBgmId;
if (currentLoadedBgm.GetLength() == 0)
return;

isBgmLoaded = true;
Console.WriteLine(">>>> 1");

// We use a double scheduler strategy.
// - First schedule from the client app (main thread) to get the requested BGM file.
Expand Down
Binary file not shown.
Binary file not shown.
13 changes: 10 additions & 3 deletions PataNext.Game.Client.Resources/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,33 @@
using GameHost.Simulation.Application;
using GameHost.Threading;
using GameHost.Worlds;
using PataNext.Game.Abilities;
using PataNext.Game.BGM;
using PataNext.Game.Client.Resources;

[assembly: RegisterAvailableModule("PataNext.Game.Client.Resources", "guerro", typeof(Module))]

namespace PataNext.Game.Client.Resources
{
public class Module : GameHostModule
public class Module : GameHostModule, IModuleHasAbilityDescStorage
{
private AbilityDescStorage abilityDescStorage;

public Module(Entity source, Context ctxParent, GameHostModuleDescription description) : base(source, ctxParent, description)
{
Console.WriteLine("Resources module loaded");

var global = new ContextBindingStrategy(ctxParent, true).Resolve<GlobalWorld>();
Storage.Subscribe((_,exteriorStorage) =>
Storage.Subscribe((_, exteriorStorage) =>
{
var storage = exteriorStorage switch
{
{} => new StorageCollection{exteriorStorage, DllStorage},
{} => new StorageCollection {exteriorStorage, DllStorage},
null => new StorageCollection {DllStorage}
};
abilityDescStorage = new AbilityDescStorage(storage.GetOrCreateDirectoryAsync("Abilities").Result);
global.Context.BindExisting(new BgmContainerStorage(storage.GetOrCreateDirectoryAsync("Bgm").Result));
foreach (ref readonly var listener in global.World.Get<IListener>())
{
Expand All @@ -36,5 +41,7 @@ public Module(Entity source, Context ctxParent, GameHostModuleDescription descri
}
}, true);
}

AbilityDescStorage IModuleHasAbilityDescStorage.Value => abilityDescStorage;
}
}
3 changes: 2 additions & 1 deletion PataNext.Game/Abilities/StatisticModifierJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public static unsafe void FromMap(ref Dictionary<string, StatisticModifier> hash
if (json == null)
return;

using (var reader = JsonDocument.Parse(json.ToLower()))
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(json.ToLower()));
using var reader = JsonDocument.Parse(stream);
{
var root = reader.RootElement;
if (!root.TryGetProperty("modifiers", out var modifierProp))
Expand Down
1 change: 0 additions & 1 deletion PataNext.Game/Inputs/Actions/RhythmInputAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public Layout(string id, params CInput[] inputs) : base(id, inputs)
public TimeSpan ActiveTime;

public bool HasBeenPressed => DownCount > 0;
public bool IsSliding => ActiveTime.TotalSeconds >= 0.42;

public class System : InputActionSystemBase<RhythmInputAction, Layout>
{
Expand Down
28 changes: 28 additions & 0 deletions PataNext.Simulation.Client.Abilities/Module.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using DefaultEcs;
using GameHost.Core.Ecs;
using GameHost.Core.Modules;
using GameHost.Injection;
using GameHost.Simulation.Application;
using GameHost.Threading;
using GameHost.Worlds;

[assembly: RegisterAvailableModule("Client Abilities", "guerro", typeof(PataNext.Simulation.Client.Abilities.Module))]

namespace PataNext.Simulation.Client.Abilities
{
public class Module : GameHostModule
{
public Module(Entity source, Context ctxParent, GameHostModuleDescription description) : base(source, ctxParent, description)
{
var global = new ContextBindingStrategy(ctxParent, true).Resolve<GlobalWorld>();
foreach (ref readonly var listener in global.World.Get<IListener>())
{
if (listener is SimulationApplication simulationApplication)
{
simulationApplication.Data.Collection.GetOrCreate(typeof(TaterazayEnergyFieldClientProvider));
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using GameHost.Core.Ecs;
using PataNext.Game.Abilities;
using PataNext.Simulation.Mixed.Abilities.CTate;

namespace PataNext.Simulation.Client.Abilities
{
public class TaterazayEnergyFieldClientProvider : BaseClientAbilityProvider<TaterazayEnergyFieldAbilityProvider>
{
public TaterazayEnergyFieldClientProvider(WorldCollection collection) : base(collection)
{
}
}
}
31 changes: 31 additions & 0 deletions PataNext.Simulation.Client/Inputs/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"SliderSensibility": 0.43,
"PataKeys": [
"keyboard/numpad4"
],
"PonKeys": [
"keyboard/numpad6"
],
"DonKeys": [
"keyboard/numpad2"
],
"ChakaKeys": [
"keyboard/numpad8"
],
"Ability0Keys": [
"keyboard/a",
"keyboard/d"
],
"Ability1Keys": [
"keyboard/w"
],
"Ability2Keys": [
"keyboard/s"
],
"PanningNegativeKeys": [
"keyboard/q"
],
"PanningPositiveKeys": [
"keyboard/e"
]
}
3 changes: 3 additions & 0 deletions PataNext.Simulation.Client/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using GameHost.Simulation.Application;
using GameHost.Threading;
using GameHost.Worlds;
using PataNext.Game.Abilities;
using PataNext.Simulation.Client.Systems;
using PataNext.Simulation.Client.Systems.Inputs;

namespace PataNext.Simulation.Client
Expand All @@ -18,6 +20,7 @@ public Module(Entity source, Context ctxParent, GameHostModuleDescription descri
if (listener is SimulationApplication simulationApplication)
{
simulationApplication.Data.Collection.GetOrCreate(typeof(RegisterRhythmEngineInputSystem));
simulationApplication.Data.Collection.GetOrCreate(typeof(AbilityHeroVoiceManager));
}
}
}
Expand Down
Loading

0 comments on commit 9d4403e

Please sign in to comment.