public PlayerCommandingEventArgs(CommandTag command, int objectID, SubTag subTag) { Command = command; ObjectID = objectID; SubTag = subTag; }
private void PCMove_PlayerCommanding(object sender, PlayerCommandingEventArgs e) { if (!GetComponent <LocalManager>().MatchID(e.ObjectID)) { return; } if (!IsValidCommand(e.Command)) { return; } int[] source = GetComponent <MetaInfo>().Position; int[] target = GetNewPosition(source, e.Command); if (!GetComponent <LocalManager>().IsPassable(target)) { return; } ActionTag action = ActionTag.Move; MainTag mainTag = GetComponent <MetaInfo>().MainTag; SubTag subTag = GetComponent <MetaInfo>().SubTag; int id = GetComponent <MetaInfo>().ObjectID; GetComponent <LocalManager>().SetPosition(target); GetComponent <LocalManager>().TakenAction( new TakenActionEventArgs(action, mainTag, subTag, id)); GameCore.AxeManCore.GetComponent <TileOverlay>().TryHideTile(source); GameCore.AxeManCore.GetComponent <TileOverlay>().TryHideTile(target); }
private IPrototype GetLifeAltar(int[] position) { MainTag mt = MainTag.Altar; SubTag st = SubTag.LifeAltar; return(new ProtoObject(mt, st, position)); }
private void SubscribePathFinding_SearchingObstacle(object sender, SearchObstacleEventArgs e) { int[] position = GetComponent <MetaInfo>().Position; SubTag subTag = GetComponent <MetaInfo>().SubTag; switch (GetComponent <MetaInfo>().MainTag) { case MainTag.Altar: e.Impassable.Push(position); break; case MainTag.Trap: e.Trap.Push(position); break; case MainTag.Actor: if (subTag == SubTag.PC) { e.PC = position; } else if (subTag != SubTag.INVALID) { e.Impassable.Push(position); } break; default: break; } }
public ChangeHPEventArgs(SubTag subTag, int id, int hp, bool isAlive) { SubTag = subTag; ID = id; CurrentHP = hp; IsAlive = isAlive; }
private GameObject GetTargetUnderMarker(SubTag markerTag) { int x, y; switch (markerTag) { case SubTag.AimMarker: x = aimMetaInfo.Position[0]; y = aimMetaInfo.Position[1]; break; case SubTag.ExamineMarker: x = examineMetaInfo.Position[0]; y = examineMetaInfo.Position[1]; break; default: return(null); } GameObject[] sorted = GetComponent <TileOverlay>().GetSortedObjects(x, y); foreach (GameObject s in sorted) { if (s.GetComponent <MetaInfo>().MainTag != MainTag.Marker) { return(s); } } return(null); }
private void PrintExamineText(SubTag markerTag) { GameObject target = GetTargetUnderMarker(markerTag); if (target == null) { return; } PrintModeline(target); switch (target.GetComponent <MetaInfo>().MainTag) { case MainTag.Altar: PrintAltarData(target); break; case MainTag.Trap: PrintTrapData(target); break; case MainTag.Actor: PrintNPCData(target); break; default: break; } }
private void Awake() { defaultActor = SubTag.DEFAULT; defaultLanguage = LanguageTag.English; mainTagXElement = new Dictionary <MainTag, XElement>(); }
public void PublishCommand(CommandTag command, int id, SubTag tag) { if (command == CommandTag.INVALID) { return; } OnPlayerCommanding(new PlayerCommandingEventArgs(command, id, tag)); }
private void Update() { int id = GetComponent <MetaInfo>().ObjectID; SubTag tag = GetComponent <MetaInfo>().SubTag; GameCore.AxeManCore.GetComponent <InputManager>().PublishCommand( ConvertInput(), id, tag); }
public void SetValue(IPrototype proto) { if ((MainTag == MainTag.INVALID) && (SubTag == SubTag.INVALID)) { MainTag = proto.MainTag; SubTag = proto.SubTag; } }
public void TestRender() { PdfBuilder builder = new PdfBuilder(new Document(), PdfOptions.Default); ITag tag = new SubTag(); ITagRenderer renderer = new Renderer(); Assert.Throws <NotImplementedException>(() => renderer.Render(tag, builder)); }
public void KeepFirstAndMoveRemainderTo(SubTag tagToMoveTo) { for (int i = _subTagParts.Count - 1; i > 0; i--) { tagToMoveTo.AddToSubtag(_subTagParts[i]); _subTagParts.RemoveAt(i); } }
public PublishActionEventArgs(ActionTag action, MainTag mainTag, SubTag subTag, int objectID) { Action = action; MainTag = mainTag; SubTag = subTag; ObjectID = objectID; }
public GameObject[] Search(SubTag subTag) { Stack <GameObject> data = new Stack <GameObject>(); var ea = new SearchingSubTagEventArgs(subTag, data); OnSearchingSubTag(ea); return(ea.Data.ToArray()); }
private IPrototype GetLifeAltar() { MainTag mt = MainTag.Building; SubTag st = SubTag.LifeAltar; int[] position = new int[] { 4, 4 }; return(new ProtoObject(mt, st, position)); }
public SkillComponentTag GetEffect(MainTag mainTag, SubTag subTag) { string effect = (string)GetComponent <ActorData>().GetXElementData( mainTag, subTag, ActorDataTag.BuildingEffect); Enum.TryParse(effect, out SkillComponentTag skill); return(skill); }
public XElement GetXElementData(MainTag mainTag, SubTag subTag, ActorDataTag actorData) { if (!TryGetData(mainTag, subTag, actorData, out XElement data)) { TryGetData(mainTag, defaultActor, actorData, out data); } return(data); }
private PublishActionEventArgs GetEventArg(ActionTag actionTag) { MetaInfo metaInfo = GetComponent <MetaInfo>(); MainTag mainTag = metaInfo.MainTag; SubTag subTag = metaInfo.SubTag; int id = metaInfo.ObjectID; return(new PublishActionEventArgs(actionTag, mainTag, subTag, id)); }
private void PublishHP() { SubTag subTag = GetComponent <MetaInfo>().SubTag; int id = GetComponent <MetaInfo>().ObjectID; bool isAlive = Current > Min; GameCore.AxeManCore.GetComponent <PublishActorHP>().PublishHP( new ChangeHPEventArgs(subTag, id, Current, isAlive)); }
private StartOrEndTurnEventArgs GetEventArg() { SubTag subTag = GetComponent <Schedule>().Current .GetComponent <MetaInfo>().SubTag; int id = GetComponent <Schedule>().Current .GetComponent <MetaInfo>().ObjectID; return(new StartOrEndTurnEventArgs(subTag, id)); }
///<summary> /// Copy constructor ///</summary> ///<param name="rhs"></param> public RFC5646Tag(RFC5646Tag rhs) { _language = rhs._language; _script = rhs._script; _region = rhs._region; _variant = new SubTag(rhs._variant); _privateUse = new SubTag(rhs._privateUse); _requiresValidTag = rhs._requiresValidTag; }
public GameObject LoadFromPool(SubTag sTag) { if (pool.TryGetValue(sTag, out Stack <GameObject> goStack) && (goStack.Count > 0)) { return(pool[sTag].Pop()); } return(null); }
private static void MoveTagsMatching(SubTag from, SubTag to, Predicate <string> moveAllMatching) { var list = new List <string>(from.AllParts.Where(part => moveAllMatching(part))); foreach (var part in list) { to.AddToSubtag(part); from.RemoveParts(part); } }
private string GetTrapEffectName(SubTag subTag) { MainTag mainTag = MainTag.Trap; BuildingEffect building = GetComponent <BuildingEffect>(); SkillComponentTag skill = building.GetEffect(mainTag, subTag); int data = building.GetPowerDuration(mainTag, subTag); return(GetComponent <ConvertSkillMetaInfo>() .GetBuildingEffectName(skill, data)); }
private void Awake() { MainTag mainTag = GetComponent <MetaInfo>().MainTag; SubTag subTag = GetComponent <MetaInfo>().SubTag; ActorDataTag dataTag = ActorDataTag.MoveDistance; baseDistance = GameCore.AxeManCore.GetComponent <ActorData>() .GetIntData(mainTag, subTag, dataTag); minDistance = 1; }
public string GetStringData(MainTag mainTag, SubTag subTag, ActorDataTag actorData) { if (!TryGetData(mainTag, subTag, actorData, userLanguage, out XElement data)) { TryGetData(mainTag, subTag, actorData, defaultLanguage, out data); } return((string)data); }
private void Start() { MainTag mainTag = GetComponent <MetaInfo>().MainTag; SubTag subTag = GetComponent <MetaInfo>().SubTag; restoreHP = GameCore.AxeManCore.GetComponent <ActorData>() .GetIntData(mainTag, subTag, ActorDataTag.RestoreHP); GameCore.AxeManCore.GetComponent <TurnManager>().StartedTurn += NPCBonusAction_StartedTurn; }
/// <summary>Transfers a list of items into a tag as sub tag intems</summary> /// <typeparam name="T">The type of items to transfer</typeparam> /// <param name="List">The tag to receive the new sub tags</param> /// <param name="SubType">The sub tag type, must implement this <see cref="ITag"/></param> /// <param name="Source">The source of items to transfer</param> private static void Transfer <T>(ITag List, Type SubType, List <T> Source) { Int32 Count = Source.Count; ITag SubTag; for (Int32 I = 0; I < Count; I++) { SubTag = (ITag)Activator.CreateInstance(SubType); SubTag.SetValue(Source[I]); List.Add(SubTag); } }
private bool TryGetData(MainTag mainTag, SubTag subTag, ActorDataTag actorData, LanguageTag language, out XElement xElement) { if (TryGetData(mainTag, subTag, actorData, out xElement)) { xElement = xElement .Element(language.ToString()); return(xElement != null); } return(false); }
public SubTag(SubTag rhs) { _subTagParts = new List<string>(rhs._subTagParts); }
/// <summary> /// This method should move all subtag parts in the 'from' subtag which match the moveAllMatching predicate into the 'to' subtag. /// Because some parts of a subtag may match in more than one language tag area care must be taken to prevent emptying all parts of /// one subtag into another so the first part that matches the keepFirstMatching predicate will not be moved. /// i.e. if the languageTag is 'from' and the regionTag is 'to' and keepFirstMatching matches language codes and moveAllMatching /// matches region codes, all region looking parts would be placed in 'to' with the possible exception of the first language looking /// part. /// </summary> /// <param name="from">SubTag to move parts from</param> /// <param name="to">SubTag to move matching parts to</param> /// <param name="moveAllMatching">predicate matching parts to move</param> /// <param name="keepFirstMatching">predicate matching part to keep</param> private static void MoveTagsMatching(SubTag from, SubTag to, Predicate<string> moveAllMatching, Predicate<string> keepFirstMatching) { bool haveFirstMatching = false; var allParts = new List<string>(from.AllParts); foreach (var part in allParts) { if (!haveFirstMatching && keepFirstMatching(part)) { haveFirstMatching = true; continue; } if (!moveAllMatching(part)) continue; to.AddToSubtag(part); from.RemoveParts(part); } }
private static void MoveTagsMatching(SubTag from, SubTag to, Predicate<string> moveAllMatching) { var list = new List<string>(from.AllParts.Where(part => moveAllMatching(part))); foreach (var part in list) { to.AddToSubtag(part); from.RemoveParts(part); } }
/// <summary> /// If the given subtag has an "x" part move all subsequent parts into private use and remove the x /// and all subsequent parts from the from SubTag. /// </summary> /// <param name="from"></param> private void MovePartsToPrivateUseIfNecessary(SubTag from) { string movedParts = null; foreach (var part in from.AllParts) { if(movedParts == null && part.ToLowerInvariant().Equals("x")) { movedParts = "x"; } else if(movedParts != null) { movedParts += "-"; movedParts += part; _privateUseSubTag.AddToSubtag(part); } } if(movedParts != null) from.RemoveParts(movedParts); }
/// <summary> /// If there is a standard part (that passes test) in the parts of the subtag, move it to the start and return true. /// If keepStandardPartInPrivateUse is true, only a part before the first 'x' may be moved. /// Return true if an acceptable part was found. /// </summary> private bool MoveStandardPartToStart(SubTag from, Func<string, bool> test, bool keepStandardPartInPrivateUse) { foreach (var goodPart in from.AllParts) { if (keepStandardPartInPrivateUse && goodPart.Equals("x", StringComparison.OrdinalIgnoreCase)) return false; if (test(goodPart)) { from.RemoveParts(goodPart); from.InsertAtStartOfSubtag(goodPart); return true; } } return false; }
/// <summary> /// This is used to move one part if appropriate from the 'from' subtag to private use. /// Alternatively, if any part is appropriate for the tag according to the test predicate, /// it is moved to the first position (unless it follows an x- and keepStandardPartInPrivateUse is true). /// If we didn't find a valid part, but did move something, insert standardPrivateCode at the START of "from". /// As a side effect, this method may remove non-alphanumeric characters from the from tag. /// (I don't like having such a side effect, but it seems necessary to produce the desired behavior). /// </summary> private void MoveFirstPartToPrivateUseIfNecessary(SubTag from, Func<string, bool> test, string standardPrivatePart, bool keepStandardPartInPrivateUse) { var part = from.AllParts.FirstOrDefault(); if (part == null) return; // nothing to move. if (test(part)) return; // no need to move, it is a valid code for its slot. if (MoveStandardPartToStart(from, test, keepStandardPartInPrivateUse)) return; // If we exit this loop we need to move the first part to private use. // But first strip illegal characters since that may leave nothing to move, // or at least nothing of the first part we would otherwise move. // We do NOT want to do this BEFORE looking for good parts, because (for example) if we have a // region code like U!S-gb, we want to detect 'gb' as a good region code and keep that, // rather than fixing U!S to US and then choosing to keep that. from.RemoveNonAlphaNumericCharacters(); // But, now we should scan again. If cleaning out bad characters resulted in a good code, // let's put it in the main part of the tag rather than private-use. if (MoveStandardPartToStart(from, test, keepStandardPartInPrivateUse)) return; // OK, no good parts left. We will move the first part that is not an X. part = FirstNonXPart(from.AllParts); if (part == null) return; _privateUseSubTag.AddToSubtag(part); from.RemoveParts(part); from.InsertAtStartOfSubtag(standardPrivatePart); }
public void Clean() { // Migrate legacy ISO3 language codes to IANA 2 letter language codes, if there's a match. // Do this before we look for valid codes, otherwise the 3-letter ones come up as invalid and // get moved to private use. However, only do this to languages not identified as private-use. if (!Language.StartsWith("x-", StringComparison.OrdinalIgnoreCase)) { string migrateFrom = ""; string migrateTo = ""; foreach (string part in _languageSubTag.AllParts) { if (part.Equals("x", StringComparison.OrdinalIgnoreCase)) break; // don't migrate language code parts already explicitly marked private-use. if (String.IsNullOrEmpty(migrateFrom)) { foreach (var code in StandardTags.ValidIso639LanguageCodes) { if (code.ISO3Code.Equals(part)) { migrateFrom = part; migrateTo = code.Code; break; } } } } if (!String.IsNullOrEmpty(migrateFrom)) { _languageSubTag.RemoveParts(migrateFrom); _languageSubTag.AddToSubtag(migrateTo); } } // The very next thing, before anything else gets moved to private use, is to move the parts whose position we // care about to the appropriate position in the private use section. // In the process we may remove anything non-alphanumeric, since otherwise we may move a marker that later // disappears (pathologically). MoveFirstPartToPrivateUseIfNecessary(_languageSubTag, StandardTags.IsValidIso639LanguageCode, "qaa", true); MoveFirstPartToPrivateUseIfNecessary(_scriptSubTag, StandardTags.IsValidIso15924ScriptCode, "Qaaa", false); MoveFirstPartToPrivateUseIfNecessary(_regionSubTag, StandardTags.IsValidIso3166Region, "QM", false); //This fixes a bug where the LdmlAdaptorV1 was writing out Zxxx as part of the variant to mark an audio writing system if (_variantSubTag.Contains(WellKnownSubTags.Audio.Script)) { MoveTagsMatching(_variantSubTag, _scriptSubTag, tag => tag.Equals(WellKnownSubTags.Audio.Script)); _privateUseSubTag.AddToSubtag(WellKnownSubTags.Audio.PrivateUseSubtag); } // Fixes various legacy problems. if (Language.Equals("cmn", StringComparison.OrdinalIgnoreCase)) Language = "zh"; if (Language.Equals("pes", StringComparison.OrdinalIgnoreCase)) Language = "fa"; if (Language.Equals("arb", StringComparison.OrdinalIgnoreCase)) Language = "ar"; if (Language.Equals("zh", StringComparison.OrdinalIgnoreCase) && String.IsNullOrEmpty(Region)) Region = "CN"; // If the language tag contains an x- , then move the string behind the x- to private use MovePartsToPrivateUseIfNecessary(_languageSubTag); // Move script, region, and variant present in the langauge tag to their proper subtag. MoveTagsMatching(_languageSubTag, _scriptSubTag, StandardTags.IsValidIso15924ScriptCode, StandardTags.IsValidIso639LanguageCode); MoveTagsMatching(_languageSubTag, _regionSubTag, StandardTags.IsValidIso3166Region, StandardTags.IsValidIso639LanguageCode); MoveTagsMatching(_languageSubTag, _variantSubTag, StandardTags.IsValidRegisteredVariant, StandardTags.IsValidIso639LanguageCode); // Move all other tags that don't belong to the private use subtag. //keep track of everything that we moved var tempSubTag = new SubTag(); MoveTagsMatching( _languageSubTag, tempSubTag, tag => !StandardTags.IsValidIso639LanguageCode(tag) ); //place all the moved parts in private use. foreach (var part in tempSubTag.AllParts) { _privateUseSubTag.AddToSubtag(part); //if it looks like we moved a custom script set the subtag to mark that we've moved it if(_scriptSubTag.IsEmpty && part.Length == 4 //potential custom script tag && !WellKnownSubTags.Ipa.PhonemicPrivateUseSubtag.EndsWith(part) && !WellKnownSubTags.Ipa.PhoneticPrivateUseSubtag.EndsWith(part)) { _scriptSubTag = new SubTag("Qaaa"); } } MoveTagsMatching( _scriptSubTag, _privateUseSubTag, tag => !StandardTags.IsValidIso15924ScriptCode(tag) ); MoveTagsMatching( _regionSubTag, _privateUseSubTag, tag => !StandardTags.IsValidIso3166Region(tag) ); MoveTagsMatching( _variantSubTag, _privateUseSubTag, tag => !StandardTags.IsValidRegisteredVariant(tag) ); _languageSubTag.KeepFirstAndMoveRemainderTo(_privateUseSubTag); _scriptSubTag.KeepFirstAndMoveRemainderTo(_privateUseSubTag); _regionSubTag.KeepFirstAndMoveRemainderTo(_privateUseSubTag); if (_privateUseSubTag.Contains(WellKnownSubTags.Audio.PrivateUseSubtag)) { // Move every tag that's not a Zxxx to private use if (!_scriptSubTag.IsEmpty && !_scriptSubTag.Contains(WellKnownSubTags.Audio.Script)) { MoveTagsMatching(_scriptSubTag, _privateUseSubTag, tag => !_privateUseSubTag.Contains(tag)); } // If we don't have a Zxxx already, set it. This protects tags already present, but with unusual case if (!_scriptSubTag.Contains(WellKnownSubTags.Audio.Script)) { _scriptSubTag = new SubTag(WellKnownSubTags.Audio.Script); } } //These two methods may produce duplicates that will subsequently be removed. Do we care? - TA 29/3/2011 _privateUseSubTag.TruncatePartsToNumCharacters(8); _privateUseSubTag.RemoveNonAlphaNumericCharacters(); _variantSubTag.RemoveDuplicates(); _privateUseSubTag.RemoveDuplicates(); // Any 'x' in the other tags will have arrived in the privateUse tag, so remove them. _privateUseSubTag.RemoveParts("x"); // if language is empty, we need to add qaa, unless only a privateUse is present (e.g. x-blah is a valid rfc5646 tag) if ((_languageSubTag.IsEmpty && (!_scriptSubTag.IsEmpty || !_regionSubTag.IsEmpty || !_variantSubTag.IsEmpty)) || (_languageSubTag.IsEmpty && _scriptSubTag.IsEmpty && _regionSubTag.IsEmpty && _variantSubTag.IsEmpty && _privateUseSubTag.IsEmpty)) { _languageSubTag.AddToSubtag("qaa"); } // Two more legacy problems. We don't allow -etic or -emic without fonipa, so insert if needed. // If it has some other standard variant we won't be able to fix it...not sure what the right answer would be. // At least we catch the more common case. foreach (var part in _privateUseSubTag.AllParts) { if (string.IsNullOrEmpty(Variant) && (part.Equals("etic",StringComparison.OrdinalIgnoreCase) || part.Equals("emic", StringComparison.OrdinalIgnoreCase))) { Variant = "fonipa"; } } }
public void KeepFirstAndMoveRemainderTo(SubTag tagToMoveTo) { for (int i = _subTagParts.Count - 1; i > 0; i--) { tagToMoveTo.AddToSubtag(_subTagParts[i]); _subTagParts.RemoveAt(i); } }