Added IsActive field to scripted events (allows disabling event-specific music when needed)
This commit is contained in:
@@ -25,6 +25,15 @@ namespace Barotrauma
|
|||||||
return "ScriptedEvent (" + characterFile + ")";
|
return "ScriptedEvent (" + characterFile + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool isActive;
|
||||||
|
public override bool IsActive
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public MonsterEvent(XElement element)
|
public MonsterEvent(XElement element)
|
||||||
: base (element)
|
: base (element)
|
||||||
{
|
{
|
||||||
@@ -92,13 +101,31 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (isFinished) return;
|
if (isFinished) return;
|
||||||
|
|
||||||
|
isActive = false;
|
||||||
|
|
||||||
|
Entity targetEntity = null;
|
||||||
|
if (Character.Controlled != null)
|
||||||
|
{
|
||||||
|
targetEntity = Character.Controlled;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
targetEntity = Submarine.FindClosest(GameMain.GameScreen.Cam.WorldViewCenter);
|
||||||
|
}
|
||||||
|
|
||||||
bool monstersDead = true;
|
bool monstersDead = true;
|
||||||
foreach (Character monster in monsters)
|
foreach (Character monster in monsters)
|
||||||
{
|
{
|
||||||
if (monster.IsDead) continue;
|
if (!monster.IsDead)
|
||||||
|
{
|
||||||
|
monstersDead = false;
|
||||||
|
|
||||||
monstersDead = false;
|
if (targetEntity != null && Vector2.DistanceSquared(monster.WorldPosition, targetEntity.WorldPosition) < 5000.0f * 5000.0f)
|
||||||
break;
|
{
|
||||||
|
isActive = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monstersDead) Finished();
|
if (monstersDead) Finished();
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ namespace Barotrauma
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool IsActive
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsFinished
|
public bool IsFinished
|
||||||
{
|
{
|
||||||
get { return isFinished; }
|
get { return isFinished; }
|
||||||
|
|||||||
@@ -4,6 +4,14 @@
|
|||||||
{
|
{
|
||||||
private ScriptedEvent scriptedEvent;
|
private ScriptedEvent scriptedEvent;
|
||||||
|
|
||||||
|
public override bool IsStarted
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return scriptedEvent.IsActive;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ScriptedTask(ScriptedEvent scriptedEvent)
|
public ScriptedTask(ScriptedEvent scriptedEvent)
|
||||||
: base(scriptedEvent.Difficulty, scriptedEvent.Name)
|
: base(scriptedEvent.Difficulty, scriptedEvent.Name)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user