public override bool ApplyInternal(IEntity sender, ActionEventData eventData) { if (!sender.Has <FollowPathBehaviour>()) { var coordinates = eventData.Parameters.Split(';').Select(e => { var mapCoordinate = new MapCoordinate(); mapCoordinate.Deserialize(e); return(mapCoordinate); }).ToList(); var behaviour = new FollowPathBehaviour(_systemContainer) { Path = coordinates, Priority = 999 }; _systemContainer.EntityEngine.AddComponent(sender, behaviour); var firstStep = behaviour.ChooseAction(sender); if (firstStep != null) { _systemContainer.EventSystem.Try(EventType.Action, sender, firstStep); } } return(true); }
public void Deserialize(string value) { var match = Regex.Match(value, "^BranchLinkEnd: (.*) ([0-9]*)-([0-9]*) @ (.*)$"); if (match.Success) { Location = new MapCoordinate(); Location.Deserialize(match.Groups[4].Value); } else { match = Regex.Match(value, "^BranchLinkEnd: (.*) ([0-9]*)-([0-9]*)$"); } Branch = match.Groups[1].Value; LevelFrom = int.Parse(match.Groups[2].Value); LevelTo = int.Parse(match.Groups[3].Value); }