MonsterEvents and ArtifactEvents spawn the monsters/items during initialization instead of waiting for the round to start (prevents entity ID mismatches if a client starts the event before receiving a message about something the server has spawned)
This commit is contained in:
@@ -30,8 +30,10 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Start()
|
public override void Init()
|
||||||
{
|
{
|
||||||
|
base.Init();
|
||||||
|
|
||||||
Vector2 position = Level.Loaded.GetRandomItemPos(
|
Vector2 position = Level.Loaded.GetRandomItemPos(
|
||||||
Level.PositionType.Cave | Level.PositionType.MainPath | Level.PositionType.Ruin, 500.0f, 30.0f);
|
Level.PositionType.Cave | Level.PositionType.MainPath | Level.PositionType.Ruin, 500.0f, 30.0f);
|
||||||
|
|
||||||
@@ -60,7 +62,6 @@ namespace Barotrauma
|
|||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
Start();
|
|
||||||
state = 1;
|
state = 1;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
@@ -54,8 +54,10 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Start()
|
public override void Init()
|
||||||
{
|
{
|
||||||
|
base.Init();
|
||||||
|
|
||||||
SpawnMonsters();
|
SpawnMonsters();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,10 +90,6 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
if (monsters == null) SpawnMonsters();
|
if (monsters == null) SpawnMonsters();
|
||||||
|
|
||||||
//base.Update(deltaTime);
|
|
||||||
|
|
||||||
//if (!isStarted) return;
|
|
||||||
|
|
||||||
if (isFinished) return;
|
if (isFinished) return;
|
||||||
|
|
||||||
bool monstersDead = true;
|
bool monstersDead = true;
|
||||||
@@ -99,8 +97,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (monster.IsDead) continue;
|
if (monster.IsDead) continue;
|
||||||
|
|
||||||
if (!isStarted && Vector2.Distance(monster.WorldPosition, Submarine.MainSub.WorldPosition) < 5000.0f) isStarted = true;
|
|
||||||
|
|
||||||
monstersDead = false;
|
monstersDead = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
this.item = item;
|
this.item = item;
|
||||||
IsFinishedChecker = isFinished;
|
IsFinishedChecker = isFinished;
|
||||||
|
|
||||||
taskManager.TaskStarted(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float deltaTime)
|
public override void Update(float deltaTime)
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
if (taskManager == null) return;
|
if (taskManager == null) return;
|
||||||
|
|
||||||
this.item = item;
|
this.item = item;
|
||||||
|
|
||||||
taskManager.TaskStarted(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float deltaTime)
|
public override void Update(float deltaTime)
|
||||||
|
|||||||
@@ -7,25 +7,12 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
class ScriptedEvent
|
class ScriptedEvent
|
||||||
{
|
{
|
||||||
//const int MaxPreviousEvents = 6;
|
|
||||||
//const float PreviouslyUsedWeight = 10.0f;
|
|
||||||
|
|
||||||
//static List<int> previousEvents = new List<int>();
|
|
||||||
|
|
||||||
protected string name;
|
protected string name;
|
||||||
protected string description;
|
protected string description;
|
||||||
|
|
||||||
protected int commonness;
|
protected int commonness;
|
||||||
protected int difficulty;
|
protected int difficulty;
|
||||||
|
|
||||||
//the time after starting a shift after which the event is started
|
|
||||||
//the time is set to a random value between startTimeMin and startTimeMax at the start of the shift
|
|
||||||
private int startTimeMin;
|
|
||||||
private int startTimeMax;
|
|
||||||
|
|
||||||
private double startTimer;
|
|
||||||
|
|
||||||
protected bool isStarted;
|
|
||||||
protected bool isFinished;
|
protected bool isFinished;
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
@@ -49,11 +36,6 @@ namespace Barotrauma
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsStarted
|
|
||||||
{
|
|
||||||
get { return isStarted; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsFinished
|
public bool IsFinished
|
||||||
{
|
{
|
||||||
get { return isFinished; }
|
get { return isFinished; }
|
||||||
@@ -77,20 +59,7 @@ namespace Barotrauma
|
|||||||
difficulty = ToolBox.GetAttributeInt(element, "difficulty", 1);
|
difficulty = ToolBox.GetAttributeInt(element, "difficulty", 1);
|
||||||
commonness = ToolBox.GetAttributeInt(element, "commonness", 1);
|
commonness = ToolBox.GetAttributeInt(element, "commonness", 1);
|
||||||
|
|
||||||
|
|
||||||
MusicType = ToolBox.GetAttributeString(element, "musictype", "default");
|
MusicType = ToolBox.GetAttributeString(element, "musictype", "default");
|
||||||
|
|
||||||
|
|
||||||
if (element.Attribute("starttime") != null)
|
|
||||||
{
|
|
||||||
startTimeMax = ToolBox.GetAttributeInt(element, "starttime", 1);
|
|
||||||
startTimeMin = startTimeMax;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
startTimeMax = ToolBox.GetAttributeInt(element, "starttimemax", 1);
|
|
||||||
startTimeMin = ToolBox.GetAttributeInt(element, "starttimemin", 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -179,28 +148,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public virtual void Init()
|
public virtual void Init()
|
||||||
{
|
{
|
||||||
isStarted = false;
|
|
||||||
isFinished = false;
|
isFinished = false;
|
||||||
startTimer = Rand.Range(startTimeMin, startTimeMax, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Start()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void Update(float deltaTime)
|
public virtual void Update(float deltaTime)
|
||||||
{
|
{
|
||||||
if (isStarted) return;
|
|
||||||
|
|
||||||
if (startTimer>0)
|
|
||||||
{
|
|
||||||
startTimer -= deltaTime;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Start();
|
|
||||||
isStarted = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Finished()
|
public virtual void Finished()
|
||||||
|
|||||||
@@ -4,13 +4,6 @@
|
|||||||
{
|
{
|
||||||
private ScriptedEvent scriptedEvent;
|
private ScriptedEvent scriptedEvent;
|
||||||
|
|
||||||
private bool prevStarted;
|
|
||||||
|
|
||||||
public override bool IsStarted
|
|
||||||
{
|
|
||||||
get { return scriptedEvent.IsStarted; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScriptedTask(ScriptedEvent scriptedEvent)
|
public ScriptedTask(ScriptedEvent scriptedEvent)
|
||||||
: base(scriptedEvent.Difficulty, scriptedEvent.Name)
|
: base(scriptedEvent.Difficulty, scriptedEvent.Name)
|
||||||
{
|
{
|
||||||
@@ -24,12 +17,6 @@
|
|||||||
|
|
||||||
public override void Update(float deltaTime)
|
public override void Update(float deltaTime)
|
||||||
{
|
{
|
||||||
if (prevStarted == false && scriptedEvent.IsStarted)
|
|
||||||
{
|
|
||||||
taskManager.TaskStarted(this);
|
|
||||||
prevStarted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
scriptedEvent.Update(deltaTime);
|
scriptedEvent.Update(deltaTime);
|
||||||
if (scriptedEvent.IsFinished) Finished();
|
if (scriptedEvent.IsFinished) Finished();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,34 +79,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TaskStarted(Task task)
|
|
||||||
{
|
|
||||||
//Color color = Color.Red;
|
|
||||||
//int width = 250;
|
|
||||||
//if (task.Priority < 30.0f)
|
|
||||||
//{
|
|
||||||
// width = 200;
|
|
||||||
// color = Color.Yellow;
|
|
||||||
//}
|
|
||||||
//else if (task.Priority < 60)
|
|
||||||
//{
|
|
||||||
// width = 220;
|
|
||||||
// color = Color.Orange;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//GUIFrame frame = new GUIFrame(new Rectangle(0,0,width,40), Color.Transparent, Alignment.Right, null, taskListBox);
|
|
||||||
//frame.UserData = task;
|
|
||||||
//frame.Padding = new Vector4(0.0f, 5.0f, 5.0f, 5.0f);
|
|
||||||
|
|
||||||
//GUIFrame colorFrame = new GUIFrame(new Rectangle(0, 0, 0, 0), color * 0.5f, Alignment.Right, null, frame);
|
|
||||||
//GUITextBlock textBlock = new GUITextBlock(new Rectangle(5, 5, 0, 20), task.Name, Color.Transparent, Color.Black, Alignment.Right, null, colorFrame);
|
|
||||||
//textBlock.Padding = new Vector4(10.0f, 10.0f, 0.0f, 0.0f);
|
|
||||||
|
|
||||||
//colorFrame.AddChild(textBlock);
|
|
||||||
|
|
||||||
//taskListBox.children.Sort((x, y) => ((Task)y.UserData).Priority.CompareTo(((Task)x.UserData).Priority));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void TaskFinished(Task task)
|
public void TaskFinished(Task task)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user