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 + ")";
|
||||
}
|
||||
|
||||
private bool isActive;
|
||||
public override bool IsActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
}
|
||||
|
||||
public MonsterEvent(XElement element)
|
||||
: base (element)
|
||||
{
|
||||
@@ -92,13 +101,31 @@ namespace Barotrauma
|
||||
|
||||
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;
|
||||
foreach (Character monster in monsters)
|
||||
{
|
||||
if (monster.IsDead) continue;
|
||||
if (!monster.IsDead)
|
||||
{
|
||||
monstersDead = false;
|
||||
|
||||
monstersDead = false;
|
||||
break;
|
||||
if (targetEntity != null && Vector2.DistanceSquared(monster.WorldPosition, targetEntity.WorldPosition) < 5000.0f * 5000.0f)
|
||||
{
|
||||
isActive = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (monstersDead) Finished();
|
||||
|
||||
@@ -35,6 +35,11 @@ namespace Barotrauma
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public virtual bool IsActive
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public bool IsFinished
|
||||
{
|
||||
|
||||
@@ -3,7 +3,15 @@
|
||||
class ScriptedTask : Task
|
||||
{
|
||||
private ScriptedEvent scriptedEvent;
|
||||
|
||||
|
||||
public override bool IsStarted
|
||||
{
|
||||
get
|
||||
{
|
||||
return scriptedEvent.IsActive;
|
||||
}
|
||||
}
|
||||
|
||||
public ScriptedTask(ScriptedEvent scriptedEvent)
|
||||
: base(scriptedEvent.Difficulty, scriptedEvent.Name)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user