-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access to local targets from sensors #36
Comments
Hey @simeonradivoev, thanks for checking out this package! I don't think it's possible to access other targets. That would probably require sensors to have an order/dependancy on each other, which they don't have right now. Perhaps you can abstract the gathering of targets to a class which overlaps multiple sensors? |
Can you show the code for the reload action? |
public class ReloadAction : ActionBase<ReloadAction.Data>
{
#region Overrides of ActionBase
public override void Created()
{
}
#endregion
#region Overrides of ActionBase<Data>
public override void Start(IMonoAgent agent, Data data)
{
data.Timer = 2;
}
public override ActionRunState Perform(IMonoAgent agent, Data data, CrashKonijn.Goap.Classes.ActionContext context)
{
data.Timer -= context.DeltaTime;
if (data.Timer > 0)
{
return ActionRunState.Continue;
}
data.Stats.Ammo = data.Stats.MaxAmmo;
return ActionRunState.Stop;
}
public override void End(IMonoAgent agent, Data data)
{
}
#endregion
public class Data : IActionData
{
public float Timer { get; set; }
[GetComponent]
public StatsComponent Stats { get; set; }
#region Implementation of IActionData
public ITarget Target { get; set; }
#endregion
}
} If I explicitly add the condition that ammo needs to be lower or equal to 0, Then it skips it. But shouldn't it do that without specifying it? |
It should, yes. I think this might be a bug. I don't have my laptop with me today, I'll look into it tomorrow! Thanks for the report! |
Update; I have created a unit test that fails. I'm working on the fix as we speak! |
Hello @simeonradivoev, Could you confirm my PR fixes your issues? If you change the git url to this you can directly reference the branch:
|
Yea, it works now. Thx. |
Is there a way to access other targets from a target sensor?
Let's say you need to choose a target based on another target.
The text was updated successfully, but these errors were encountered: