Skip to content

Commit 95dfa00

Browse files
feature: run parallel events (AscensionGameDev#2269)
1 parent 460aed1 commit 95dfa00

File tree

8 files changed

+1797
-19
lines changed

8 files changed

+1797
-19
lines changed

Intersect (Core)/GameObjects/Events/EventBase.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel.DataAnnotations.Schema;
44
using System.Linq;
@@ -70,6 +70,11 @@ public EventBase(Guid id, string json, bool isCommon = false) : base(id)
7070

7171
public bool CommonEvent { get; set; }
7272

73+
/// <summary>
74+
/// Option used to run events even when another is already running
75+
/// </summary>
76+
public bool CanRunInParallel { get; set; }
77+
7378
public bool Global { get; set; }
7479

7580
[JsonIgnore]

Intersect.Editor/Forms/Editors/Events/frmEvent.Designer.cs

Lines changed: 27 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Intersect.Editor/Forms/Editors/Events/frmEvent.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ private void InitLocalization()
954954
chkInteractionFreeze.Text = Strings.EventEditor.interactionfreeze;
955955
chkIgnoreNpcAvoids.Text = Strings.EventEditor.ignorenpcavoids;
956956
grpTriggers.Text = Strings.EventEditor.trigger;
957+
chkParallelRun.Text = Strings.EventEditor.ParallelRun;
957958
grpNewCommands.Text = Strings.EventEditor.addcommand;
958959
grpEventCommands.Text = Strings.EventEditor.commandlist;
959960
btnInsert.Text = Strings.EventEditor.insertcommand;
@@ -1008,6 +1009,7 @@ public void InitEditor(bool disableNaming, bool disableTriggers, bool questEvent
10081009
cmbAnimation.Items.Clear();
10091010
cmbAnimation.Items.Add(Strings.General.None);
10101011
cmbAnimation.Items.AddRange(AnimationBase.Names);
1012+
chkParallelRun.Checked = MyEvent.CanRunInParallel;
10111013
if (MyEvent.CommonEvent || questEvent)
10121014
{
10131015
grpEntityOptions.Hide();
@@ -1824,6 +1826,11 @@ private void cmbLayering_SelectedIndexChanged(object sender, EventArgs e)
18241826
CurrentPage.Layer = (EventRenderLayer)cmbLayering.SelectedIndex;
18251827
}
18261828

1829+
private void chkParallelRun_CheckedChanged(object sender, EventArgs e)
1830+
{
1831+
MyEvent.CanRunInParallel = chkParallelRun.Checked;
1832+
}
1833+
18271834
private void cmbTrigger_SelectedIndexChanged(object sender, EventArgs e)
18281835
{
18291836
if (MyEvent.CommonEvent)

Intersect.Editor/Localization/Strings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2876,6 +2876,8 @@ public partial struct EventEditor
28762876

28772877
public static LocalizedString pageoptions = @"Page Options";
28782878

2879+
public static LocalizedString ParallelRun = @"Can run in Parallel?";
2880+
28792881
public static LocalizedString passable = @"Passable";
28802882

28812883
public static LocalizedString pastecommand = @"Paste";

Intersect.Server.Core/Entities/Player.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -696,11 +696,17 @@ public override void Update(long timeMs)
696696
var evt = obj.Value as EventBase;
697697
if (evt != null && evt.CommonEvent)
698698
{
699-
if (Options.Instance.Metrics.Enable)
699+
foreach (var page in evt.Pages)
700700
{
701-
autorunEvents += evt.Pages.Count(p => p.CommonTrigger == CommonEventTrigger.Autorun);
701+
if (page.CommonTrigger == CommonEventTrigger.Autorun)
702+
{
703+
if (Options.Instance.Metrics.Enable)
704+
{
705+
autorunEvents += evt.Pages.Count(p => p.CommonTrigger == CommonEventTrigger.Autorun);
706+
}
707+
EnqueueStartCommonEvent(evt, CommonEventTrigger.Autorun);
708+
}
702709
}
703-
EnqueueStartCommonEvent(evt, CommonEventTrigger.Autorun);
704710
}
705711
}
706712

@@ -6901,7 +6907,7 @@ public bool UnsafeStartCommonEvent(
69016907
return false;
69026908
}
69036909

6904-
if (EventBaseIdLookup.ContainsKey(baseEvent.Id))
6910+
if (EventBaseIdLookup.ContainsKey(baseEvent.Id) && !baseEvent.CanRunInParallel)
69056911
{
69066912
return false;
69076913
}

0 commit comments

Comments
 (0)