/// <summary> /// Returns a list of MemberLocations, sorted by distance to the specified leader. /// </summary> private List <MemberLocation> GetMemberLocations(CreatureBoardAsset leaderAsset) { if (lastMemberLocations != null) { return(lastMemberLocations); } List <MemberLocation> memberLocations = new List <MemberLocation>(); foreach (string memberId in Data.Members) { MemberLocation memberLocation = new MemberLocation(); CreatureBoardAsset creatureBoardAsset = Talespire.Minis.GetCreatureBoardAsset(memberId); if (creatureBoardAsset == null) { continue; } memberLocation.Asset = creatureBoardAsset; memberLocation.Name = creatureBoardAsset.GetOnlyCreatureName(); memberLocation.Position = creatureBoardAsset.PlacedPosition; memberLocation.DistanceToLeader = (leaderAsset.PlacedPosition - creatureBoardAsset.PlacedPosition).magnitude; memberLocations.Add(memberLocation); } memberLocations = memberLocations.OrderBy(x => x.DistanceToLeader).ToList(); return(memberLocations); }
public string GetGroupName() { CreatureBoardAsset asset = OwnerCreature; if (asset != null) { return(asset.GetOnlyCreatureName()); } Talespire.Log.Error($"GetGroupName - Asset with OwnerID {OwnerID} not found!"); return(string.Empty); }
private static void AttachEffects(CreatureBoardAsset creatureAsset, IOldPersistentEffect persistentEffect) { Log.Indent(); if (persistentEffect != null) { if (persistentEffect is SuperPersistentEffect superPersistentEffect) { for (int i = 0; i < superPersistentEffect.EffectProperties.Count; i++) { string prefix = i.ToString().PadLeft(2, '0'); EffectProperties effectProperties = superPersistentEffect.EffectProperties[i]; Log.Warning($"Adding effect {prefix} - \"{effectProperties.EffectName}\""); GameObject spell = Spells.AttachEffect(creatureAsset, effectProperties.EffectName, creatureAsset.CreatureId.ToString(), 0, 0, 0, STR_AttachedNode, prefix); TransferPropertiesToPersistentEffect(CompositeEffect.GetFromGameObject(spell), superPersistentEffect); if (superPersistentEffect.ScriptData != null && superPersistentEffect.ScriptData.Count > 0) { Log.Debug($""); foreach (string scriptName in superPersistentEffect.ScriptData.Keys) { Log.Warning($"Adding Script: {scriptName} to \"{creatureAsset.GetOnlyCreatureName()}\" with data: \"{superPersistentEffect.ScriptData[scriptName]}\""); TaleSpireBehavior script = spell.AddComponent(KnownScripts.GetType(scriptName)) as TaleSpireBehavior; if (script != null) { script.OwnerCreated(creatureAsset.CreatureId.ToString()); script.Initialize(superPersistentEffect.ScriptData[scriptName]); } } } } } else { Spells.AttachEffect(creatureAsset, persistentEffect.EffectName, creatureAsset.CreatureId.ToString(), 0, 0, 0, STR_AttachedNode); } } else { Log.Error($"Unable to attach any effects. {nameof(persistentEffect)} is null!"); //Log.Warning($"Adding \"{defaultNewEffect}\"..."); //Spells.AttachEffect(creatureAsset, defaultNewEffect, creatureAsset.CreatureId.ToString(), 0, 0, 0, STR_AttachedNode); } Log.Unindent(); }
static void DuplicateEffectAtMenu(MapMenuItem menuItem, object arg2) { //if (menuItem != null) // Talespire.Log.Warning($"menuItem.gameObject.name = {menuItem.gameObject.name}"); CreatureBoardAsset creatureAtMenu = RadialUI.RadialUIPlugin.CreatureAtMenu; //Talespire.Log.Warning($"DuplicateEffectAtMenu: \"{menuItem}\", \"{arg2}\""); //Talespire.Log.Warning($"CreatureAtMenu: {creatureAtMenu.Creature.Name}"); if (creatureAtMenu != null) { IOldPersistentEffect persistentEffect = creatureAtMenu.GetPersistentEffect(); //string persistentEffectData = creatureAtMenu.GetPersistentEffectData(); Talespire.PersistentEffects.Duplicate(persistentEffect, creatureAtMenu.GetOnlyCreatureName()); } }
public static void SetFlying(string id, bool isFlying) { Log.Indent(); try { CreatureBoardAsset creatureBoardAsset = GetCreatureBoardAsset(id); if (Guard.IsNull(creatureBoardAsset, "creatureBoardAsset")) { return; } string creatureName = creatureBoardAsset.GetOnlyCreatureName(); if (creatureBoardAsset.IsFlying != isFlying) { Log.Warning($"Setting {creatureName}'s flying state to {isFlying}"); CreatureManager.SetCreatureFlyingState(creatureBoardAsset.CreatureId, isFlying); creatureBoardAsset.EnableFlying(isFlying); if (creatureBoardAsset.IsFlying != isFlying) { Log.Error($"Error: {creatureName} is flying state is still {creatureBoardAsset.IsFlying}."); } if (!isFlying) { Log.Debug($"creatureBoardAsset.DropAtCurrentLocation();"); creatureBoardAsset.DropAtCurrentLocation(); } } else { if (isFlying) { Log.Warning($"{creatureName} is already flying!"); } else { Log.Warning($"{creatureName} is already grounded!"); } } } finally { Log.Unindent(); } }
/// <summary> /// Removes the Knockdown status emote for creatures that are knocked down (and stands the mini upright). /// </summary> public static void StandUp(this CreatureBoardAsset asset) { ActionTimeline knockdownStatusEmote = Menus.GetKnockdownStatusEmote(); if (knockdownStatusEmote == null) { Log.Error($"knockdownStatusEmote not found."); return; } bool isStanding = !asset.HasActiveEmote(knockdownStatusEmote); if (isStanding) { Log.Debug($"Asset {asset.GetOnlyCreatureName()} is already knocked up!"); return; } asset.Creature.ToggleStatusEmote(knockdownStatusEmote); }
internal static bool InitializeMiniAsEffect(CreatureBoardAsset creatureAsset, string effectName = null, string newCreatureName = null) { //Log.Indent($"InitializeMiniAsEffect({creatureAsset.CreatureId}, \"{effectName}\", \"{newCreatureName}\")"); try { if (effectName == null) { effectName = "R1.WaterWallSegment1"; } IOldPersistentEffect persistentEffect = creatureAsset.GetPersistentEffect(); if (persistentEffect == null) { Log.Error($"Error - persistentEffect == null (not found by call to GetPersistentEffect() on \"{creatureAsset.GetOnlyCreatureName()}\")."); persistentEffect = new SuperPersistentEffect(); if (persistentEffect is SuperPersistentEffect superPersistentEffect) { superPersistentEffect.EffectProperties.Add(new EffectProperties() { EffectName = effectName }); } } return(InitializeMiniFromPersistentEffect(creatureAsset, persistentEffect, newCreatureName)); } finally { //Log.Unindent(); } }
private void BoardToolManager_OnSwitchTool(BoardTool obj) { Talespire.Log.Indent(); try { if (obj is CreatureMoveBoardTool || obj is CreatureKeyMoveBoardTool) { if (Data.Movement == GroupMovementMode.FollowTheLeader) { CreatureBoardAsset selectedMini = Talespire.Minis.GetSelected(); if (selectedMini == OwnerCreature) { Talespire.Log.Debug($"Owner selected and moving!"); } else { Talespire.Log.Debug($"Owner NOT selected!"); } } moveToolActive = true; // Something is moving! Talespire.Log.Debug($"// Something is moving!"); return; } if (!(obj is DefaultBoardTool)) { return; } if (OwnerCreature != null) { Talespire.Log.Debug($"OwnerCreature != null"); float newAltitude = OwnerCreature.GetFlyingAltitude(); if (newAltitude != lastAltitude) { Talespire.Log.Warning($"Altitude changed from {lastAltitude} to {newAltitude}!"); } lastAltitude = newAltitude; CheckAltitudeAgainSoon(); if (moveToolActive) { RefreshIndicators(); Vector3 newPosition = OwnerCreature.PlacedPosition; Vector3 deltaMove = newPosition - lastGroupPosition; MoveGroup(deltaMove); lastGroupPosition = newPosition; } else { Talespire.Log.Debug($"moveTool is not Active"); } } CreatureBoardAsset selected = Talespire.Minis.GetSelected(); if (selectingLookTarget && selected != null) { selectingLookTarget = false; if (OwnerCreature != null) { OwnerCreature.Creature.Speak($"Now looking at {selected.GetOnlyCreatureName()}."); } Data.Target = selected.CreatureId.ToString(); DataChanged(); } if (selected?.Creature.CreatureId.ToString() != OwnerID) { if (selected == null) { lastCreatureSelected = null; } else { lastCreatureSelected = selected.CreatureId.ToString(); if (Data.Look == LookTowardMode.NearestOutsider) { LookToNearestOutsiders(GetMemberAssets()); } else if (Data.Look == LookTowardMode.NearestMember) { List <CreatureBoardAsset> assets = GetMemberAssets(); if (assets.Contains(selected)) // We just moved a member... { FaceClosest(assets, assets); } } else if (Data.Look == LookTowardMode.Creature && lastCreatureSelected == Data.Target) { List <CreatureBoardAsset> assets = GetMemberAssets(); foreach (CreatureBoardAsset asset in assets) { asset.RotateToFacePosition(selected.PlacedPosition); } } } if (needToClearGroupIndicators) { ClearGroupIndicators(); } } moveToolActive = false; } finally { Talespire.Log.Unindent(); } }
public GroupMember(CreatureBoardAsset creatureBoardAsset) { CreatureBoardAsset = creatureBoardAsset; Name = creatureBoardAsset.GetOnlyCreatureName().Trim(); }