private static void BoardToolManager_OnSwitchTool(BoardTool obj) { if (obj is CreatureMoveBoardTool) { CreatureBoardAsset selectedCreature = Minis.GetSelected(); draggingPersistentEffect = selectedCreature.GetPersistentEffect(); if (draggingPersistentEffect != null && draggingPersistentEffect.RotationIsLocked) { trackingDraggedMiniForRotationLock = true; } } else { if (draggingPersistentEffect != null && trackingDraggedMiniForRotationLock) { CreatureBoardAsset selectedCreature = Minis.GetSelected(); if (selectedCreature != null) { selectedCreature.SetRotationDegrees(draggingPersistentEffect.LockedRotation); } } draggingPersistentEffect = null; trackingDraggedMiniForRotationLock = false; } }
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(); } }
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 bool IsHidden(string creatureId) { CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(creatureId); if (creatureBoardAsset == null) { Log.Error($"IsHidden -- creatureBoardAsset == null"); return(false); } IOldPersistentEffect persistentEffect = creatureBoardAsset.GetPersistentEffect(); if (persistentEffect == null) { Log.Error($"IsHidden -- persistentEffect == null"); return(false); } return(persistentEffect.Hidden); }
public static void SetHidden(CreatureBoardAsset creatureBoardAsset, bool hidden) { //Log.Debug($"SetHidden - hidden: {hidden}"); IOldPersistentEffect persistentEffect = creatureBoardAsset.GetPersistentEffect(); if (persistentEffect == null) { Log.Error($"persistentEffect == null"); return; } persistentEffect.Hidden = hidden; CreatureManager.SetCreatureExplicitHideState(creatureBoardAsset.Creature.CreatureId, hidden); // Hide or show adornments: GameObject effectOrb = GetEffectOrb(creatureBoardAsset); foreach (string key in persistentEffect.Indicators.Keys) { bool indicatorVisible = persistentEffect.Indicators[key]; bool shouldBeVisible = !hidden && indicatorVisible; SetOrbIndicatorVisible(effectOrb, shouldBeVisible, key); } if (persistentEffect is SuperPersistentEffect superPersistentEffect && superPersistentEffect.VisibilityMatchesBase) { GameObject attachedParentGameObject = creatureBoardAsset.GetAttachedParentGameObject(); if (attachedParentGameObject != null) { attachedParentGameObject.SetActive(!hidden); } else { Log.Error($"Unable to find attached parent game object! Cannot hide this control!"); } } creatureBoardAsset.SavePersistentEffect(persistentEffect); }
public static void SetRotationLocked(CreatureBoardAsset creatureBoardAsset, bool locked) { //Log.Debug($"SetRotationLocked - locked: {locked}"); IOldPersistentEffect persistentEffect = creatureBoardAsset.GetPersistentEffect(); if (persistentEffect == null) { Log.Error($"persistentEffect == null"); return; } //Log.Debug($"SetRotationLocked - IsVisible: {creatureBoardAsset.IsVisible}"); SetSpinLockVisible(creatureBoardAsset, locked && creatureBoardAsset.IsVisible); persistentEffect.RotationIsLocked = locked; if (locked) { persistentEffect.LockedRotation = creatureBoardAsset.GetRotationDegrees(); } creatureBoardAsset.SavePersistentEffect(persistentEffect); }
public static bool IsRotationLocked(string creatureId) { CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(creatureId); if (creatureBoardAsset == null) { Log.Error($"IsRotationLocked -- creatureBoardAsset == null"); return(false); } IOldPersistentEffect persistentEffect = creatureBoardAsset.GetPersistentEffect(); if (persistentEffect == null) { Log.Error($"IsRotationLocked -- persistentEffect == null"); return(false); } //Log.Debug($"persistentEffect.RotationLocked = {persistentEffect.RotationIsLocked}"); return(persistentEffect.RotationIsLocked); }
// TODO: Refactor this. Hard to read. internal static bool InitializeMiniFromPersistentEffect(CreatureBoardAsset creatureAsset, IOldPersistentEffect persistentEffect, string newCreatureName) { //Log.Indent(); try { GameObject assetLoader = creatureAsset.GetAssetLoader(); //Log.Warning($"creatureAsset.Creature.Name = \"{creatureAsset.Creature.Name}\""); if (assetLoader != null) { GameObject goatClone = assetLoader.FindChild(STR_UninitializedMiniMeshName); if (goatClone != null) { MeshFilter meshFilter = goatClone.GetComponent <MeshFilter>(); MeshRenderer meshRenderer = goatClone.GetComponent <MeshRenderer>(); if (meshFilter != null && meshRenderer != null) { PositionOrb(goatClone); ReplaceMaterial(meshFilter, meshRenderer); if (persistentEffect == null) { persistentEffect = creatureAsset.GetPersistentEffect(); if (persistentEffect == null) { Log.Error($"persistentEffect is null! Creating Waterfall!"); persistentEffect = new OldPersistentEffect() { EffectName = "R1.WaterWallSegment1" }; } } InitializeNewlyCreatedPersistentEffect(creatureAsset, persistentEffect, newCreatureName); updatedCreatures.Add(creatureAsset.CreatureId.ToString()); Log.Debug($"returning true"); return(true); } else { Log.Debug($"Mesh Filter or Mesh Renderer not found in this update cycle..."); } } else { if (assetLoader.FindChild(STR_EffectOrb) != null) { //if (effectsToInitialize.Count > 0) // Log.Warning($"effectsToInitialize.Count = {effectsToInitialize.Count}"); //if (updatedCreatures.Count > 0) // Log.Warning($"updatedCreatures.Count = {updatedCreatures.Count}"); //Log.Warning($"Already initialized. Adding {creatureAsset.CreatureId.ToString()} to updatedCreatures"); persistentEffect = creatureAsset.GetPersistentEffect(); GameObject effectOrb = GetEffectOrb(creatureAsset); GameObject attachedNode = creatureAsset.GetAttachedParentGameObject(); if (attachedNode != null) { persistentEffectEventArgs.Set(creatureAsset, assetLoader, effectOrb, attachedNode, persistentEffect); OnPersistentEffectInitialized(creatureAsset, persistentEffectEventArgs); } else { Log.Error($"attachedNode is null!!!"); } updatedCreatures.Add(creatureAsset.CreatureId.ToString()); } else { Log.Debug($"goatClone not found in this update cycle..."); } } } else { Log.Debug($"Asset Loader not found in this update cycle..."); } //Log.Debug($"returning false"); return(false); } finally { //Log.Unindent(); } }