ace/Source/ACE.Server/Entity/RecordCast.cs
gmriggs 6e0e691f2a
continued porting of 1991 to master branch (#2545)
* continuing to pull functions out of 1991 while retaining existing functionality

* adding command descriptions

* moving /debugcast and /recordcast to Developer commands
2019-12-17 09:21:07 -05:00

85 lines
2.1 KiB
C#

using System;
using System.IO;
using System.Text;
using ACE.Entity.Enum;
using ACE.Server.Network.Structure;
using ACE.Server.WorldObjects;
namespace ACE.Server.Entity
{
public class RecordCast
{
public Player Player;
public bool Enabled;
public string Filename => $"{Player.Name}Cast.log";
public StringBuilder Buffer = new StringBuilder();
public RecordCast(Player player)
{
Player = player;
}
public void OnMoveToState(MoveToState moveToState)
{
var rawState = moveToState.RawMotionState;
var line = rawState.ToString(false).Replace(Environment.NewLine, " | ");
line = line.Length >= 8 ? line.Substring(0, line.Length - 8) : "";
Output(line);
}
public void OnCastTargetedSpell(Spell spell, WorldObject target)
{
var line = $"HandleActionCastTargetedSpell({spell.Id} - {spell.Name}, {target.Name} ({target.Guid}))";
Output(line);
}
public void OnCastUntargetedSpell(Spell spell)
{
var line = $"HandleActionCastUntargetedSpell({spell.Id} - {spell.Name})";
Output(line);
}
public void OnJump(JumpPack jump)
{
var line = $"HandleActionJump: Velocity={jump.Velocity}, Extent={jump.Extent}";
Output(line);
}
public void OnSetCombatMode(CombatMode combatMode)
{
var line = $"HandleActionChangeCombatMode({combatMode})";
Output(line);
}
public void Log(string line)
{
Output(line);
}
public void Output(string line)
{
var timestamp = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss,fff");
var timestamp_line = $"[{timestamp}] {line}";
Buffer.AppendLine(timestamp_line);
Console.WriteLine(timestamp_line);
}
public void Flush()
{
File.AppendAllText(Filename, Buffer.ToString());
Buffer.Clear();
}
}
}