PDA

View Full Version : ActorName - For Reference



ATAG_Bliss
Dec-24-2011, 20:15
namespace maddox.game
{
using System;
using System.Runtime.InteropServices;

public static class ActorName
{
public static string Full(int missionNumber, string shortActorName)
{
return (missionNumber + ":" + shortActorName);
}

public static bool IsShort(string actorName)
{
return (actorName.IndexOf(':') < 0);
}

public static int MissionNumber(string fullActorName)
{
int num2;
int index = fullActorName.IndexOf(':');
if ((index > 0) && int.TryParse(fullActorName.Substring(0, index), out num2))
{
return num2;
}
return 0;
}

public static void Parce(string fullActorName, out int missionNumber, out string shortName)
{
int index = fullActorName.IndexOf(':');
if (index < 0)
{
missionNumber = 0;
shortName = fullActorName;
}
else
{
int num2;
if (int.TryParse(fullActorName.Substring(0, index), out num2))
{
missionNumber = num2;
}
else
{
missionNumber = 0;
}
shortName = fullActorName.Substring(index + 1);
}
}

public static string Short(string fullActorName)
{
int index = fullActorName.IndexOf(':');
if (index < 0)
{
return fullActorName;
}
return fullActorName.Substring(index + 1);
}
}
}