![]() |
VOOZH | about |
dotnet add package Doprez.Stride.AI --version 0.1.1
NuGet\Install-Package Doprez.Stride.AI -Version 0.1.1
<PackageReference Include="Doprez.Stride.AI" Version="0.1.1" />
<PackageVersion Include="Doprez.Stride.AI" Version="0.1.1" />Directory.Packages.props
<PackageReference Include="Doprez.Stride.AI" />Project file
paket add Doprez.Stride.AI --version 0.1.1
#r "nuget: Doprez.Stride.AI, 0.1.1"
#:package Doprez.Stride.AI@0.1.1
#addin nuget:?package=Doprez.Stride.AI&version=0.1.1Install as a Cake Addin
#tool nuget:?package=Doprez.Stride.AI&version=0.1.1Install as a Cake Tool
AI libraries to be used within Stride3d games
using Doprez.Stride.AI.FSMs;
public class BasicEnemyFSM : FSM
{
public override void UpdateFSM()
{
//You can add triggers here to cancel/change the current running state
}
}
public class IdleState : FSMState
{
public IdleState(FSM fsm)
{
// set the FSM to access the methods within the running state
FiniteStateMachine = fsm;
// add this state to the FSM for other states to see this state
FiniteStateMachine.States.Add(0, this);
}
public override void EnterState()
{
// activate needed events or variables when this state is started
}
public override void ExitState()
{
// deactivate needed events or variables when this state is finished
}
public override void UpdateState()
{
// this runs in the Update method of Stride per frame
}
}
you can add the Doprez.Stride nuget package if some of the references are missing
using System;
using Doprez.Stride.AI.FSMs;
using Stride.Core;
using Stride.Engine;
using StridePlatformer.States;
using Navigation;
public class BasicEnemyFSM : FSM
{
[Display("Player Entity")]
[DataMember(0)]
public Entity Player{get;set;}
[Display("Player Seen Trigger")]
[DataMember(2)]
public PhysicsComponent PlayerSeenTrigger;
[Display("Animation Component")]
[DataMember(20)]
public AnimationComponent AnimationComponent { get; set; }
//States
//private MoveToState _moveTo;
private IdleState _idle;
public override void Start()
{
InitializeStates();
SetCurrentState(_idle);
}
private void InitializeStates()
{
_idle = new IdleState(this, AnimationComponent);// ", _moveTo" add this if you added a moveTo state
_idle.PlayerSeenTrigger = PlayerSeenTrigger;
}
public override void UpdateFSM()
{
// add some logic here if needed but it can just be blank
}
}
using System.Collections.Specialized;
using System.Threading.Tasks;
using Doprez.Stride.AI.FSMs;
using Stride.Core.Collections;
using Stride.Engine;
using Stride.Physics;
public class IdleState : FSMState
{
public PhysicsComponent PlayerSeenTrigger;
private readonly AnimationComponent _animationComponent;
//add a state for you to change to like the example below
//private readonly MoveToState _moveTo;
public IdleState(FSM fsm, AnimationComponent animationComponent)// , MoveToState moveTo
{
FiniteStateMachine = fsm;
_animationComponent = animationComponent;
//_moveTo = moveTo;
FiniteStateMachine.States.Add((int)EnemyStates.Idle, this);
}
public override void EnterState()
{
//Only activate this trigger while the state is running
PlayerSeenTrigger.Enabled = true;
PlayerSeenTrigger.Collisions.CollectionChanged += CollisionsChanged;
//run the idle anim if you have one
//_animationComponent.Play("Idle");
}
public override void ExitState()
{
// stop using the trigger when the state isnt running
PlayerSeenTrigger.Enabled = false;
PlayerSeenTrigger.Collisions.CollectionChanged -= CollisionsChanged;
}
public override void UpdateState()
{
}
private void CollisionsChanged(object sender, TrackingCollectionChangedEventArgs args)
{
// Cast the argument 'Item' to a collision object
var collision = (Collision)args.Item;
// We need to make sure which collision object is not the Trigger collider
// We perform a little check to find the ballCollider
var playerCollider = PlayerSeenTrigger == collision.ColliderA ? collision.ColliderB : collision.ColliderA;
if (args.Action == NotifyCollectionChangedAction.Add)
{
// When a collision has been added to the collision collection, we know an object has 'entered' our trigger
if (playerCollider.Entity.Name == "PlayerCharacter")
{
//get the entity that entered the trigger
var entitycollided = playerCollider.Entity;
//you can change the state by direct reference or the dictionary Id
//_moveTo.Target = entitycollided;
// change to a direct reference
//FiniteStateMachine.SetCurrentState(_moveTo);
// change based on a dictionary reference I would recommend setting up and Enum for readability
//FiniteStateMachine.SetCurrentState(1);
}
}
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.