76 lines
2.5 KiB
C#
76 lines
2.5 KiB
C#
using System.Xml.Linq;
|
|
|
|
public class MinEventActionSendNPCForRebirth : MinEventActionTargetedBase
|
|
{
|
|
private bool hide;
|
|
private string task = "";
|
|
private float duration = 600;
|
|
|
|
public override void Execute(MinEventParams _params)
|
|
{
|
|
//Log.Out("MinEventActionSendNPCForRebirth-Execute START");
|
|
|
|
var entity = _params.Self as EntityNPCRebirth;
|
|
if (entity == null)
|
|
{
|
|
//Log.Out("MinEventActionSendNPCForRebirth-Execute 1");
|
|
return;
|
|
}
|
|
|
|
switch (task)
|
|
{
|
|
case null:
|
|
//Log.Out("MinEventActionSendNPCForRebirth-Execute 2");
|
|
return;
|
|
case "mine":
|
|
{
|
|
//Log.Out("MinEventActionSendNPCForRebirth-Execute 3");
|
|
entity.GameTimerTicks = GameTimer.Instance.ticks;
|
|
entity.HideDuration = ((int)GameManager.Instance.World.worldTime / GameStats.GetInt(EnumGameStats.TimeOfDayIncPerSec)) + duration;
|
|
//Log.Out("MinEventActionSendNPCForRebirth-Execute entity.HideDuration: " + entity.HideDuration);
|
|
entity.bMine = true;
|
|
entity.HideNPC(true);
|
|
return;
|
|
}
|
|
case "repair":
|
|
{
|
|
//Log.Out("MinEventActionSendNPCForRebirth-Execute 4");
|
|
entity.GameTimerTicks = GameTimer.Instance.ticks;
|
|
entity.HideDuration = ((int)GameManager.Instance.World.worldTime / GameStats.GetInt(EnumGameStats.TimeOfDayIncPerSec)) + duration;
|
|
entity.bRepair = true;
|
|
entity.HideNPC(true);
|
|
return;
|
|
}
|
|
default:
|
|
//Log.Out("MinEventActionSendNPCForRebirth-Execute 5");
|
|
return;
|
|
}
|
|
}
|
|
|
|
public override bool ParseXmlAttribute(XAttribute _attribute)
|
|
{
|
|
var flag = base.ParseXmlAttribute(_attribute);
|
|
if (flag) return true;
|
|
var name = _attribute.Name;
|
|
|
|
if (name == null)
|
|
{
|
|
return flag;
|
|
}
|
|
else if (name == "task")
|
|
{
|
|
task = _attribute.Value;
|
|
return true;
|
|
}
|
|
else if (name == "duration")
|
|
{
|
|
duration = float.Parse(_attribute.Value); //Convert.ToUInt64(_attribute.Value) * 20UL;
|
|
//Log.Out("MinEventActionSendNPCForRebirth-ParseXmlAttribute duration: " + duration);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
} |