public IEnumerator DelayedActionManagerInvokeWithParameters() { var testObj = new DamTest(); DelayedActionManager.AddAction((Action <int, string, bool, float>)testObj.MethodWithParams, 0, 5, "testValue", true, 3.14f); yield return(null); }
public IEnumerator StressInstantiation() { for (int i = 0; i < 100; i++) { var loc = m_Locations[Random.Range(0, m_Locations.Count)]; ResourceManager.ProvideInstance <GameObject>(loc, new InstantiationParameters(null, true)).Completed += op => { Assert.IsNotNull(op.Result); DelayedActionManager.AddAction((Action <Object, IResourceLocation>)ResourceManager.ReleaseInstance, Random.Range(.25f, .5f), op.Result, loc); }; if (Random.Range(0, 100) > 20) { yield return(null); } } while (DelayedActionManager.IsActive) { yield return(null); } var objs = SceneManager.GetActiveScene().GetRootGameObjects(); foreach (var r in objs) { Assert.False(r.name.EndsWith("(Clone)"), "All instances were not cleaned up"); } }
public void CleanupDelayedActionManager() { EditorApplication.isPlaying = true; DelayedActionManager.AddAction(new Action(() => {})); EditorApplication.isPlaying = false; Assert.AreEqual(0, CountResourcesByName("DelayedActionManager")); }
public void Start(ProvideHandle provideHandle, float loadDelay) { m_ProvideHandle = provideHandle; if (loadDelay < 0) { LoadImmediate(); } DelayedActionManager.AddAction((Action)LoadImmediate, loadDelay); }
public IEnumerator DelayedActionManagerInvokeSameFrame() { var testObj = new DamTest(); int frameCalled = Time.frameCount; DelayedActionManager.AddAction((Action)testObj.Method); yield return(null); Assert.AreEqual(frameCalled, testObj.frameInvoked); }
public void OneTimeSetup() { ResourceManager.ResourceProviders.Clear(); ResourceManager.InstanceProvider = null; ResourceManager.SceneProvider = null; AsyncOperationCache.Instance.Clear(); DelayedActionManager.Clear(); CreateLocations(m_Locations); }
public IEnumerator DelayedActionManagerInvokeDelayed() { var testObj = new DamTest(); float timeCalled = Time.realtimeSinceStartup; DelayedActionManager.AddAction((Action)testObj.Method, .25f); yield return(new WaitForSeconds(.5f)); Assert.LessOrEqual(timeCalled + .2f, testObj.timeInvoked); }
public static void DJCommand(string value, WorldClient client) { int id = DelayedActionRecord.DelayedActions.DynamicPop(x => x.Id); DelayedActionRecord record = new DelayedActionRecord(id, "Monsters", 30, value, client.Character.Map.Id.ToString()); record.AddElement(); DelayedAction action = new DelayedAction(record); DelayedActionManager.AddAction(action); action.Execute(); }
public void CleanupDelayedActionManager() { EditorApplication.isPlaying = true; DelayedActionManager.AddAction(new Action(() => {})); Assert.True(DelayedActionManager.Exists); Assert.NotNull(DelayedActionManager.Instance); EditorApplication.isPlaying = false; Assert.False(DelayedActionManager.Exists); Assert.AreEqual(0, CountResourcesByName("DelayedActionManager")); }
public IEnumerator DelayedActionManagerInvokeDelayed() { var testObj = new DamTest(); float timeCalled = Time.unscaledTime; DelayedActionManager.AddAction((Action)testObj.Method, 2); while (!testObj.methodInvoked) { yield return(null); } //make sure delay was at least 1 second (to account for test slowness) Assert.Greater(testObj.timeInvoked, timeCalled + 1); }
public void Start(ProvideHandle provideHandle, float loadDelay) { m_Loaded = false; m_ProvideHandle = provideHandle; m_ProvideHandle.SetWaitForCompletionCallback(WaitForCompletionHandler); if (loadDelay < 0) { LoadImmediate(); } else { DelayedActionManager.AddAction((Action)LoadImmediate, loadDelay); } }
public string getPortalPositionString(string name) { var portal = PortalRecord.GetPortal(name); var action = DelayedActionManager.GetAction(DelayedActionEnum.Portal, portal.Id.ToString()); var nextPop = action.Timer.Interval.ConvertToMinutes(); if (action == null || action.Value == null) { return("?"); } var map = (MapRecord)action.Value; return(string.Format("<b>[{0},{1}]</b> ({2}) il y est encore pour " + Math.Ceiling(nextPop) + " minutes", map.Position.X, map.Position.Y, map.SubArea.Name)); }
public static void DjCommand(string value, WorldClient client) { if (value == null) { client.Character.ReplyError("You must provide a list of monsters to spawn. Example: 23,24,25,26."); return; } int id = DelayedActionRecord.DelayedActions.DynamicPop(x => x.Id); DelayedActionRecord record = new DelayedActionRecord(id, "Monsters", 30, value, client.Character.Map.Id.ToString()); record.AddElement(); DelayedAction action = new DelayedAction(record); DelayedActionManager.AddAction(action); action.Execute(); }
public static void CreateDelayedAction(string value, WorldClient client) { var split = value.Split(' '); string actionType = split[0]; // for dungeon: Monsters int interval = int.Parse(split[1]); // ex: 30 (in seconds) string value1 = split[2]; // For dungeons: list of monsters var value2 = client.Character.Map.Id.ToString(); DelayedActionRecord record = new DelayedActionRecord(actionType, interval, value1, value2); record.AddInstantElement(); DelayedAction action = new DelayedAction(record); DelayedActionManager.AddAction(action); action.Execute(); client.Character.Reply($"Successfully created DelayedAction record {record}."); }
public static void TestCommand(string value, WorldClient client) { client.SendRaw(RawDataManager.GetRawData("gvgpanel")); client.Character.Reply("Done"); // client.Character.SpellAnim(7356); return; client.Character.Record.Stats.LifePoints = 99999; client.Character.Record.Stats.ActionPoints.Base += 99; client.Character.Record.Stats.MaxLifePoints = 99999; client.Character.RefreshStats(); return; int id = DelayedActionRecord.DelayedActions.DynamicPop(x => x.Id); DelayedActionRecord record = new DelayedActionRecord(id, "CharacterMonster", 50, value, client.Character.Map.Id.ToString()); record.AddElement(); DelayedAction action = new DelayedAction(record); DelayedActionManager.AddAction(action); action.Execute(); }