Skip to content

Instantly share code, notes, and snippets.

@guerro323
Last active August 9, 2021 13:44
Show Gist options
  • Select an option

  • Save guerro323/4bf9cacb85a99c15f72547e554e237e4 to your computer and use it in GitHub Desktop.

Select an option

Save guerro323/4bf9cacb85a99c15f72547e554e237e4 to your computer and use it in GitHub Desktop.
Example 1 Gist
using System;
using Collections.Pooled;
using GameHost.Core.Ecs;
using GameHost.Simulation.TabEcs;
using GameHost.Simulation.TabEcs.Interfaces;
using PataNext.Module.Simulation.BaseSystems;
using PataNext.Simulation.Mixed.Components.GamePlay.RhythmEngine.DefaultCommands;
public struct MoveNdJumpAbility : IComponentData
{
public float Speed;
public float JumpPower;
public struct State : IComponentData
{
public uint PreviousActivation;
}
}
public class MoveNdJumpAbilityProvider : BaseRuntimeRhythmAbilityProvider<MoveNdJumpAbility>
{
public MoveNdJumpAbilityProvider(WorldCollection collection) : base(collection)
{
DefaultConfiguration = new MoveNdJumpAbility()
{
Speed = 1,
JumpPower = 8
};
}
public override string MasterServerId => "MoveNdJump";
public override ComponentType GetChainingCommand()
{
return AsComponentType<MarchCommand>();
}
public override void GetComponents(PooledList<ComponentType> entityComponents)
{
base.GetComponents(entityComponents);
entityComponents.Add(AsComponentType<MoveNdJumpAbility.State>());
}
}
using System;
using GameHost.Core.Ecs;
using GameHost.Simulation.TabEcs;
using PataNext.Module.Simulation.BaseSystems;
using PataNext.Module.Simulation.Components.GamePlay.Abilities;
using PataNext.Module.Simulation.Components.GamePlay.Units;
using PataNext.Simulation.Mixed.Components.GamePlay.RhythmEngine.DefaultCommands;
using StormiumTeam.GameBase.Physics.Components;
public class MoveNdJumpScript : AbilityScriptModule<MoveNdJumpAbilityProvider>
{
public MoveNdJumpScript(WorldCollection collection) : base(collection)
{
}
protected override void OnExecute(GameEntity owner, GameEntity self, ref AbilityState state)
{
ref var abilityState = ref GetComponentData<MoveNdJumpAbility.State>(self);
var settings = GetComponentData<MoveNdJumpAbility>(self);
if (state.IsActive)
{
var previousCommand = GetComponentData<AbilityEngineSet>(self).PreviousCommand;
if (HasComponent<ChargeCommand>(previousCommand.Entity))
{
if (abilityState.PreviousActivation != state.ActivationVersion)
GetComponentData<Velocity>(owner).Value.Y = settings.JumpPower;
}
else
{
GetComponentData<Velocity>(owner).Value.X = settings.Speed;
GetComponentData<UnitControllerState>(owner).ControlOverVelocityX = true;
}
}
abilityState.PreviousActivation = state.ActivationVersion;
}
protected override void OnSetup(Span<GameEntityHandle> abilities)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment