protected override void OnCreate() { base.OnCreate(); m_EntityCommandBufferSystem = World.GetOrCreateSystem <BeginSimulationEntityCommandBufferSystem>(); // Collect list of all types that implement IAbility and store reference to methods var abilityTypes = World.Active.EntityManager.GetAssignableComponentTypes(typeof(IAbilityBehaviour)).ToArray(); // Iterate over all objects that implement the IAbility interface for (var i = 0; i < abilityTypes.Length; i++) { IAbilityBehaviour ability = (IAbilityBehaviour)Activator.CreateInstance(abilityTypes[i]); abilities.Add(ability); // Create the FunctionPointer hashmaps var cooldownEffects = ability.CooldownEffects; var nativeArray = new NativeArray <EGameplayEffect>(cooldownEffects, Allocator.Persistent); var entityQueryDescContainer = ability.EntityQueries; m_AbilityBeginCastQuery.Add(GetEntityQuery(entityQueryDescContainer.BeginAbilityCastJobQueryDesc)); m_UpdateCooldownsJobQuery.Add(GetEntityQuery(entityQueryDescContainer.UpdateCooldownsJobQueryDesc)); m_UpdateAbilityAvailableQuery.Add(GetEntityQuery(entityQueryDescContainer.CheckAbilityAvailableJobQueryDesc_UpdateAvailability)); m_GenericCheckResourceForAbilityJobQuery.Add(GetEntityQuery(entityQueryDescContainer.CheckAbilityAvailableJobQueryDesc_CheckResources)); m_GenericCheckAbilityGrantedJobQuery.Add(GetEntityQuery(entityQueryDescContainer.CheckAbilityGrantedJobQueryDesc)); abilityCooldownEffects.Add(nativeArray); } // Create EntityQueries for jobs m_CooldownEffects = GetEntityQuery(new EntityQueryDesc { All = new[] { ComponentType.ReadOnly <CooldownEffectComponent>(), ComponentType.ReadOnly <GameplayEffectDurationComponent>(), ComponentType.ReadOnly <AttributeModificationComponent>() }, }); m_ActiveAbilities = GetEntityQuery(new EntityQueryDesc { All = new[] { ComponentType.ReadOnly <AbilityComponent>(), ComponentType.ReadOnly <AbilityStateComponent>(), ComponentType.ReadOnly <AbilitySourceTargetComponent>() }, }); }
public abstract void ActivateAbility(AbilitySystemComponent Source, AbilitySystemComponent Target, IAbilityBehaviour Ability);
public Ability CreateAbility(IAbilityBehaviour abilityBehaviour) { return(new Ability(abilityBehaviour)); }
public override async void ActivateAbility(AbilitySystemComponent Source, AbilitySystemComponent Target, IAbilityBehaviour Ability) { var abilitySystemActor = Source.GetActor(); var animationEventSystemComponent = abilitySystemActor.GetComponent <AnimationEventSystem>(); var animatorComponent = abilitySystemActor.GetComponent <Animator>(); // Ability.State = AbilityState.Activated; // Make sure we have enough resources. End ability if we don't animatorComponent.SetTrigger(AnimationTriggerName); //(_, var gameplayEventData) = await AbilitySystem.OnGameplayEvent.WaitForEvent((gameplayTag, eventData) => gameplayTag == WaitForEventTag); var gameplayEventData = new GameplayEventData() { Instigator = Source, Target = Target }; List <GameObject> objectsSpawned = new List <GameObject>(); GameObject instantiatedProjectile = null; await animationEventSystemComponent.CustomAnimationEvent.WaitForEvent((x) => x == CastingInitiated); if (Projectile != null) { instantiatedProjectile = Instantiate(Projectile); instantiatedProjectile.transform.position = abilitySystemActor.transform.position + this.ProjectilePositionOffset + abilitySystemActor.transform.forward * 1.2f; } animatorComponent.SetTrigger(ProjectileFireTriggerName); await animationEventSystemComponent.CustomAnimationEvent.WaitForEvent((x) => x == FireProjectile); // Animation complete. Spawn and send projectile at target if (instantiatedProjectile != null) { SeekTargetAndDestroy(Source, gameplayEventData, instantiatedProjectile); } var beh = animatorComponent.GetBehaviour <AnimationBehaviourEventSystem>(); await beh.StateEnter.WaitForEvent((animator, stateInfo, layerIndex) => stateInfo.fullPathHash == Animator.StringToHash(CompletionAnimatorStateFullHash)); }
public override void ActivateAbility(AbilitySystemComponent Source, AbilitySystemComponent Target, IAbilityBehaviour Ability) { throw new NotImplementedException(); }
public Ability(IAbilityBehaviour abilityBehaviour) { _ability = abilityBehaviour; }
public void AddNewBehaviour(IAbilityBehaviour behaviour) { _behaviours.Add(behaviour); }