HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: Clear all collection elements  (Read 800 times)

cloudnine

  • General Accounts
  • *
  • Posts: 80
    • View Profile
    • Youtube
Clear all collection elements
« on: Jan 09, 13, 01:44:24 PM »

I have a GUI window button that calls the server and should clear all abilities from the character.
Code: [Select]
untrusted function RequestRemoveAll()
  account as NodeRef = SYSTEM.REMOTE.CLIENT
  var char = account.GetMyChar()
  var charAbilities = char.GetMyAbilities()
  println("PreQuickLookupLength (" +charabilities.AbilitiesQuicklookup.length +")")
  println("PreAbilityListLength (" +charabilities.AbilityList.length +")")
  // Clear Ability List
  clear charAbilities.AbilityList //destroy
  // Clear Quicklookup
  foreach key in charAbilities.AbilitiesQuicklookup
  //if (someCondition == true)
    remove key from charAbilities.AbilitiesQuicklookup destroy
  .
  // Reset the Skill and Ability Points
  mychar as NodeRef of Class E_playerCharacter = char
  mychar.AbilityPoints = mychar.E_level - 1
  if mychar.AbilityPoints <0
    mychar.AbilityPoints = 0
  .
  mychar.SkillPoints = 0
  mychar.Strength = (mychar.E_level * 1)
  mychar.Dexterity = (mychar.E_level * 1)
  mychar.Vitality = (mychar.E_level * 1)
  mychar.Agility = (mychar.E_level * 1)
  mychar.Intelligence = (mychar.E_level * 1)
  //Clear the skill history
  clear mychar.TrainedJobSkills
  println("PostQuickLookupLength (" +charabilities.AbilitiesQuicklookup.length +")")
  println("PostAbilityListLength (" +charabilities.AbilityList.length +")")
.
When I was removing a single ability i used
  me.RemoveCollectionElement( rability, destroy )       
   me.TransmitRemoveCollectionElementToClient( account, rability, destroy )
Is there a way to remove all elements from a collection
Or do I have to Iterate through a collection?

Also on the client AbilityListWindow it checks the AbilityOracle which is anchored to
System.Info.WorldAnchor
Should This Be System.Node.Prototypename?
Theres a 3 second screen freeze when opening the window.
Code: [Select]
method SoloCharacterAbilityListWindow_Populate()
  var clientarea = me.SoloCharacterAbilityListWindow_GetFlowContainer()
  clear clientarea.children destroy
  println("Populate the abilitylistwindow")
  var oracle = SYSTEM.INFO.WORLDANCHOR.GetAbilityOracle()
  var abilitiesNode = oracle.GetAbilitiesNode()
  oracle.addListener(me)
  println("Oracle node is (" +oracle+ ")" )
  println("Abilities node is (" +abilitiesnode+ ")" )
  abilities as List of NodeRef
  abilitiesNode.listCollectionElements(abilities)
 
  c as NodeRef of Class ExpandedInfoAbilityContainer
  foreach a in abilities
    where a is kindof PlayerAbility
      c = me.SoloCharacterAbilityListWindow_CreateControlForAbility(a, a.AbilitySource)
      add back c to clientarea.children
    .
  .
.
Because right now the problem is If I log off/log on
The ability list window is empty.
If I train One ability the AbilityListWindow has 10+ of the same ability.
Log off / on and its blank until I train an ability.

I don't have abilities that will have levels, instead the character stats affect the abilities damage.
Would It be better to use abilitylist(which is a list of id) to populate the window.
Logged

cloudnine

  • General Accounts
  • *
  • Posts: 80
    • View Profile
    • Youtube
Re: Clear all collection elements
« Reply #1 on: Jan 09, 13, 05:48:32 PM »

I believe I cleared the collection out
 by opening the window with the two commented lines
uncommented.
Code: [Select]
method SoloCharacterAbilityListWindow_Populate()
  var clientarea = me.SoloCharacterAbilityListWindow_GetFlowContainer()
  clear clientarea.children destroy
  println("Populate the abilitylistwindow")
  var oracle = SYSTEM.INFO.WORLDANCHOR.GetAbilityOracle()
  var abilitiesNode = oracle.GetAbilitiesNode()
  oracle.addListener(me)
  println("Oracle node is (" +oracle+ ")" )
  println("Abilities node is (" +abilitiesnode+ ")" )
  abilities as List of NodeRef
 
  abilitiesNode.listCollectionElements(abilities)
  //SYSTEM.EXEC.CPULIMIT = 00:00:30
  c as NodeRef of Class ExpandedInfoAbilityContainer
  foreach a in abilities
    //abilitiesNode.RemoveCollectionElement( a,destroy )
    where a is kindof PlayerAbility
      c = me.SoloCharacterAbilityListWindow_CreateControlForAbility(a,a.AbilitySource)//(a)// a.AbilitySource)
      add back c to clientarea.children
    .
  .
.
Still not sure why the ability oracle is anchored to SYSTEM.INFO.WORLDANCHOR though.
Logged