playMaker

Author Topic: FSM Set?  (Read 4007 times)

turkeypotpie

  • Playmaker Newbie
  • *
  • Posts: 22
FSM Set?
« on: January 08, 2013, 12:55:03 PM »
I noticed there is an extension that adds a list and hash data structure.  But there is no set structure.  You could use the list but it would be slow.  You could use the hash but it requires to make all your members to have unique keys, which isn't always so easy.

I'm going to just put the set in a monobehavior, but this is sorta inconsistent with the way the other structures are used ...

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: FSM Set?
« Reply #1 on: January 08, 2013, 01:53:48 PM »
wait, so what is your question?  ???
Remember, you don't fail unless you give up trying to succeed!

turkeypotpie

  • Playmaker Newbie
  • *
  • Posts: 22
Re: FSM Set?
« Reply #2 on: January 08, 2013, 02:25:56 PM »
Well, I guess my questions would be:

1.  Why is there no set structure?  This seems like something that would be commonly used.  For instance, in my case, I have an enemy that sits around and shoots stuff.  When targets come in and out of range, I store them in a set so it can later decide who to shoot.

2.  If there is no set structure, is there a workaround with the hashtables that I am missing?


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: FSM Set?
« Reply #3 on: January 08, 2013, 03:14:05 PM »
Hi,

 Could you give me a script example of what you mean by "structure" set? do you refer here for c# "struct" ?

bye,

 Jean

turkeypotpie

  • Playmaker Newbie
  • *
  • Posts: 22
Re: FSM Set?
« Reply #4 on: January 08, 2013, 03:46:18 PM »
Here is an example.  I'm calling AddInRangeRabbit and RemoveInRangeRabbit from my FSM.

Code: [Select]
public class Hunter : BaseMonoBehaviour {

    ...

    private HashSet<GameObject> _rabbitsInRange = new HashSet<GameObject>();

    void AddInRangeRabbit(GameObject rabbit) {
        _rabbitsInRange.Add(rabbit);
    }

    void RemoveInRangeRabbit(GameObject rabbit) {
        _rabbitsInRange.Remove(rabbit);
    }

    ...
}

Not a huge deal really.  But it might be nice to be able to do this within PlayMaker.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: FSM Set?
« Reply #5 on: January 09, 2013, 03:27:46 AM »
hi,

 ok, could you explain why you want to use HashSet and not an simple ArrayList? Also, why are you using "BaseMonoBehaviour"? Interested to know, I might miss something very cool here.

 I created ArrayMaker, which is totally for this kind of needs, you can store fsm variables ( or values during editing) inside arrayLit or Hashtable.

https://hutonggames.fogbugz.com/default.asp?W715

Have you tried this? It's full of examples to show you how it can be used, and in your case, it would work perfectly.

bye,

 Jean

turkeypotpie

  • Playmaker Newbie
  • *
  • Posts: 22
Re: FSM Set?
« Reply #6 on: January 09, 2013, 03:02:25 PM »
BaseMonoBehaviour is just a convenience class I made.  It doesn't do much, except make some commonly used function calls simpler.

The "extension" I was talking about in the beginning of my post was ArrayMaker itself, so my question was why ArrayMaker has a list and a map, but not a set.

Lists work functionally, but they're slow when set functionality is needed, which is the main reason I made this post ...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: FSM Set?
« Reply #7 on: January 09, 2013, 03:25:44 PM »
Hi,

 ok, I see. You're fine with ArrayList really..  I made an sample using 58113 string entries parsed from a text file list of words, and it's instant access, query, and general handling of array methods.

http://hutonggames.com/playmakerforum/index.php?topic=891.msg3666#msg3666


the thing is, yes, you can find more optimal way to write c#, but in the context of developing for a real time rendering engine, you will find that your performances are way more dependent on the content, textures, meshes, animation, sound, camera effects, etc etc and the script optimizations such as switchin from arrayList to HashSet comes last ( read almost never) in the equation. On Mobile, you have to be careful of course, but I use arrayMaker even on first generation ipads without any real issues.

bye,

 Jean






Bye,

 Jean