Skip to content

Commit

Permalink
Added backward, party ability, and modified perfect score threshold a…
Browse files Browse the repository at this point in the history
…nd error threshold for commands
  • Loading branch information
guerro323 committed Aug 14, 2020
1 parent 9d4403e commit cbd369c
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,10 @@ protected override void OnUpdate()
});

abilityCollectionSystem.SpawnFor("march", unit);
abilityCollectionSystem.SpawnFor("backward", unit);
abilityCollectionSystem.SpawnFor("retreat", unit);
abilityCollectionSystem.SpawnFor("jump", unit);
abilityCollectionSystem.SpawnFor("party", unit);
abilityCollectionSystem.SpawnFor("charge", unit);
abilityCollectionSystem.SpawnFor("CTate.BasicDefendFrontal", unit);
abilityCollectionSystem.SpawnFor("CTate.BasicDefendStay", unit, AbilitySelection.Top);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"modifiers":
{
"active": {
"movement_speed": 0.5,
"defense": 1.1
},
"perfect": {
"movement_speed": 1.2,
"defense": 1.1
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using Collections.Pooled;
using GameHost.Core.Ecs;
using GameHost.Simulation.Features.ShareWorldState.BaseSystems;
using GameHost.Simulation.TabEcs;
using GameHost.Simulation.TabEcs.HLAPI;
using GameHost.Simulation.TabEcs.Interfaces;
using GameHost.Simulation.Utility.EntityQuery;
using PataNext.Module.Simulation.BaseSystems;
using PataNext.Module.Simulation.Components.GamePlay.Abilities;
using PataNext.Simulation.Mixed.Abilities.Subset;
using PataNext.Simulation.mixed.Components.GamePlay.RhythmEngine.DefaultCommands;

namespace PataNext.Simulation.Mixed.Abilities.Defaults
{
/// <summary>
/// The default backward ability
/// </summary>
/// <remarks>
/// If you wish to modify the AccelerationFactor, do it so in the attached <see cref="DefaultBackwardAbility"/> component
/// </remarks>
public struct DefaultBackwardAbility : IComponentData
{
public class Register : RegisterGameHostComponentData<DefaultBackwardAbility>
{}
}

public class DefaultBackwardAbilityProvider : BaseRhythmAbilityProvider<DefaultBackwardAbility>
{
public override string MasterServerId => "backward";

public DefaultBackwardAbilityProvider(WorldCollection collection) : base(collection)
{
}

public override void GetComponents(PooledList<ComponentType> entityComponents)
{
base.GetComponents(entityComponents);
entityComponents.Add(GameWorld.AsComponentType<DefaultSubsetMarch>());
}

public override void SetEntityData(GameEntity entity, CreateAbility data)
{
base.SetEntityData(entity, data);

GameWorld.GetComponentData<DefaultSubsetMarch>(entity) = new DefaultSubsetMarch
{
AccelerationFactor = -1,
Target = DefaultSubsetMarch.ETarget.All
};
}

public override ComponentType GetChainingCommand()
{
return GameWorld.AsComponentType<BackwardCommand>();
}
}

public class DefaultBackwardAbilitySystem : BaseAbilitySystem
{
public DefaultBackwardAbilitySystem(WorldCollection collection) : base(collection)
{
}

private EntityQuery abilityQuery;

public override void OnAbilityUpdate()
{
var abilityAccessor = new ComponentDataAccessor<AbilityState>(GameWorld);
var subsetAccessor = new ComponentDataAccessor<DefaultSubsetMarch>(GameWorld);
foreach (var entity in (abilityQuery ??= CreateEntityQuery(new[]
{
typeof(DefaultBackwardAbility),
typeof(DefaultSubsetMarch),
typeof(AbilityState)
})).GetEntities())
{
subsetAccessor[entity].IsActive = abilityAccessor[entity].IsActive;
}
}
}
}
113 changes: 113 additions & 0 deletions PataNext.Simulation.Mixed.Abilities/Defaults/DefaultPartyAbility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using System;
using GameHost.Core.Ecs;
using GameHost.Simulation.TabEcs;
using GameHost.Simulation.TabEcs.Interfaces;
using GameHost.Simulation.Utility.EntityQuery;
using GameHost.Worlds.Components;
using PataNext.Module.Simulation.BaseSystems;
using PataNext.Module.Simulation.Components.GamePlay.Abilities;
using PataNext.Simulation.mixed.Components.GamePlay.RhythmEngine;
using PataNext.Simulation.mixed.Components.GamePlay.RhythmEngine.DefaultCommands;
using StormiumTeam.GameBase.Roles.Components;

namespace PataNext.Simulation.Mixed.Abilities.Defaults
{
public struct DefaultPartyAbility : IComponentData
{
public TimeSpan TickProgression;
public TimeSpan TickPerSecond;
public bool WasActive;

public int EnergyPerTick;
public int EnergyOnActivation;
}

public class DefaultPartyAbilityProvider : BaseRhythmAbilityProvider<DefaultPartyAbility>
{
public DefaultPartyAbilityProvider(WorldCollection collection) : base(collection)
{
}

public override string MasterServerId => "party";
public override ComponentType GetChainingCommand()
{
return GameWorld.AsComponentType<PartyCommand>();
}

public override void SetEntityData(GameEntity entity, CreateAbility data)
{
base.SetEntityData(entity, data);

GameWorld.GetComponentData<DefaultPartyAbility>(entity) = new DefaultPartyAbility
{
TickPerSecond = TimeSpan.FromSeconds(0.1),
EnergyPerTick = 1,
EnergyOnActivation = 30
};
}
}

public class DefaultPartyAbilitySystem : BaseAbilitySystem
{
private IManagedWorldTime worldTime;

public DefaultPartyAbilitySystem(WorldCollection collection) : base(collection)
{
DependencyResolver.Add(() => ref worldTime);
}

private EntityQuery abilityQuery;
public override void OnAbilityUpdate()
{
var dt = worldTime.Delta;

var abilityAccessor = GetAccessor<DefaultPartyAbility>();
var stateAccessor = GetAccessor<AbilityState>();
var engineSetAccessor = GetAccessor<AbilityEngineSet>();
var ownerAccessor = GetAccessor<Owner>();
foreach (var entity in (abilityQuery ??= CreateEntityQuery(new[]
{
AsComponentType<DefaultPartyAbility>(),
AsComponentType<AbilityState>(),
AsComponentType<AbilityEngineSet>(),
AsComponentType<Owner>()
})).GetEntities())
{
ref var ability = ref abilityAccessor[entity];

ref readonly var state = ref stateAccessor[entity];
if (!state.IsActive)
{
ability.TickProgression = default;
ability.WasActive = false;
return;
}

var isActivationFrame = false;
if (!ability.WasActive)
isActivationFrame = ability.WasActive = true;

ref readonly var engineSet = ref engineSetAccessor[entity];
if (engineSet.ComboSettings.CanEnterFever(engineSet.ComboState))
{
ability.TickProgression += dt;
if (ability.TickProgression > TimeSpan.Zero)
{
var energy = (int) (ability.TickProgression / ability.TickPerSecond);
if (energy > 0)
{
ability.TickProgression = default;

GetComponentData<RhythmSummonEnergy>(engineSet.Engine).Value += energy * ability.EnergyPerTick;
}
}

if (isActivationFrame)
GetComponentData<RhythmSummonEnergy>(engineSet.Engine).Value += ability.EnergyOnActivation;
}
else
ability.TickProgression = default;
}
}
}
}
6 changes: 6 additions & 0 deletions PataNext.Simulation.Mixed.Abilities/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@ public Module(Entity source, Context ctxParent, GameHostModuleDescription descri
{
simulationApplication.Data.Collection.GetOrCreate(typeof(Defaults.DefaultMarchAbilityProvider));
simulationApplication.Data.Collection.GetOrCreate(typeof(Defaults.DefaultMarchAbilitySystem));

simulationApplication.Data.Collection.GetOrCreate(typeof(Defaults.DefaultBackwardAbilityProvider));
simulationApplication.Data.Collection.GetOrCreate(typeof(Defaults.DefaultBackwardAbilitySystem));

simulationApplication.Data.Collection.GetOrCreate(typeof(Defaults.DefaultRetreatAbilityProvider));
simulationApplication.Data.Collection.GetOrCreate(typeof(Defaults.DefaultRetreatAbilitySystem));

simulationApplication.Data.Collection.GetOrCreate(typeof(Defaults.DefaultJumpAbilityProvider));
simulationApplication.Data.Collection.GetOrCreate(typeof(Defaults.DefaultJumpAbilitySystem));

simulationApplication.Data.Collection.GetOrCreate(typeof(Defaults.DefaultPartyAbilityProvider));
simulationApplication.Data.Collection.GetOrCreate(typeof(Defaults.DefaultPartyAbilitySystem));

simulationApplication.Data.Collection.GetOrCreate(typeof(Defaults.DefaultChargeAbilityProvider));

simulationApplication.Data.Collection.GetOrCreate(typeof(CTate.TaterazayBasicDefendFrontalAbilityProvider));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public override void OnAbilityUpdate()
ref var velocity = ref GetComponentData<Velocity>(owner).Value;

// to not make tanks op, we need to get the weight from entity and use it as an acceleration factor
acceleration = Math.Clamp(RcpSafe(unitPlayState.Weight), 0, 1) * subSet.AccelerationFactor * 50;
// We need to get the abs of the AccelerationFactor since the backward ability use -1
acceleration = Math.Clamp(RcpSafe(unitPlayState.Weight), 0, 1) * Math.Abs(subSet.AccelerationFactor) * 50;
acceleration = Math.Min(acceleration * timeDelta, 1);

walkSpeed = unitPlayState.MovementSpeed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct ComputedSliderFlowPressure
public struct FlowPressure
{
public const float Error = 0.99f;
public const double Perfect = 0.18f;
public const double Perfect = 0.16f;

/// <summary>
/// Is this the end of a slider?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private static float unlerp(TimeSpan a, TimeSpan b, TimeSpan x)
return 0.0f;
}

private static bool isValid(int beat, double offset, TimeSpan commandStart, TimeSpan elapsed, TimeSpan beatInterval, float scoreLimit = 0.6f)
private static bool isValid(int beat, double offset, TimeSpan commandStart, TimeSpan elapsed, TimeSpan beatInterval, float scoreLimit = 0.4f)
{
elapsed -= commandStart;

Expand Down

0 comments on commit cbd369c

Please sign in to comment.