RandomTransition
I made a Random timed transition. When I spawn the enemy, it picks the same number every time like it was already picked when it was spawned and it would never re pick the number. How would I make it pick a different number every time? Btw the states are strings with an integer within the quotes.
RandomTimedTransistion.cs
Code:
#region
using wServer.realm;
using System;
#endregion
namespace wServer.logic.transitions
{
public class RandomTimedTransition : Transition
{
//State storage: cooldown timer
private readonly bool randomized;
private readonly int time;
public RandomTimedTransition(int time, int min, int max, bool randomized = false)
: base(new Random().Next(min, max).ToString())
{
this.time = time;
this.randomized = randomized;
}
protected override bool TickCore(Entity host, RealmTime time, ref object state)
{
int cool;
if (state == null) cool = randomized ? Random.Next(this.time) : this.time;
else cool = (int) state;
bool ret = false;
if (cool <= 0)
{
ret = true;
cool = this.time;
}
else
cool -= time.thisTickTimes;
state = cool;
return ret;
}
}
}
