static void Init() { // Get existing open window or if none, make a new one: FxHelper window = (FxHelper)EditorWindow.GetWindow(typeof(FxHelper)); window.Show(); }
static void DestroyFx(GameObject FxObject) { if (FxObject) { FxHelper.Destroy(FxObject); FxObject = null; } }
static GameObject RespawnFx(GameObject prefab, ItemEntity item) { WeaponSlot weaponSlot = item.HoldingSlot as WeaponSlot; var weaponSnap = weaponSlot?.FxSnapMap; var unit = item.Wielder.Unit?.View; return(FxHelper.SpawnFxOnWeapon(prefab, unit, weaponSnap)); }
//Refer FxHelper.SpawnFxOnGameObject static void ShowFxInfo(UnitEntityData unitEntityData) { //Choose FX GUILayout.Label($"Choose FX {FXIds.Length} available", GUILayout.Width(200f)); if (FXIds.Length == 0) { LoadFxLookup(); } GUILayout.BeginHorizontal(); fxIndex = (int)GUILayout.HorizontalSlider(fxIndex, 0, FXIds.Length - 1, GUILayout.Width(300)); if (GUILayout.Button("Prev", GUILayout.Width(45))) { fxIndex = fxIndex == 0 ? 0 : fxIndex - 1; } if (GUILayout.Button("Next", GUILayout.Width(45))) { fxIndex = fxIndex >= FXIds.Length - 1 ? FXIds.Length - 1 : fxIndex + 1; } var fxId = FXIds[fxIndex]; GUILayout.Label($"{LibraryThing.GetResourceGuidMap()[fxId]} {FXIds[fxIndex]}"); if (GUILayout.Button("Apply", GUILayout.Width(200))) { var prefab = ResourcesLibrary.TryGetResource <GameObject>(fxId); FxHelper.SpawnFxOnUnit(prefab, unitEntityData.View); } if (GUILayout.Button("Clear FX Cache", GUILayout.Width(200))) { LoadFxLookup(forceReload: true); } GUILayout.EndHorizontal(); //List of SpawnFxOnStart var spawnOnStart = unitEntityData.View.GetComponent <SpawnFxOnStart>(); if (spawnOnStart) { GUILayout.Label("Spawn on Start", GUILayout.Width(200f)); GUILayout.Label("FxOnStart " + spawnOnStart.FxOnStart?.Load()?.name, GUILayout.Width(400)); GUILayout.Label("FXFxOnDeath " + spawnOnStart.FxOnStart?.Load()?.name, GUILayout.Width(400)); } GUILayout.Label("Decals"); var decals = Traverse.Create(unitEntityData.View).Field("m_Decals").GetValue <List <FxDecal> >(); for (int i = decals.Count - 1; i >= 0; i--) { var decal = decals[i]; GUILayout.Label("Decal: " + decal.name, GUILayout.Width(400)); if (GUILayout.Button("Destroy", GUILayout.Width(200f))) { GameObject.Destroy(decal.gameObject); decals.RemoveAt(i); } } GUILayout.Label("CustomWeaponEffects", GUILayout.Width(200f)); var dollroom = Game.Instance.UI.Common.DollRoom; foreach (var kv in EffectsManager.WeaponEnchantments) { GUILayout.Label($"{kv.Key.Name} - {kv.Value.Count}"); foreach (var go in kv.Value) { GUILayout.BeginHorizontal(); GUILayout.Label($" {go?.name ?? "NULL"}"); if (dollroom != null && GUILayout.Button("UnscaleFXTimes", GUILayout.ExpandWidth(false))) { Traverse.Create(dollroom).Method("UnscaleFxTimes", new object[] { go }).GetValue(); } GUILayout.EndHorizontal(); } } GUILayout.Label("FXRoot", GUILayout.Width(200f)); foreach (Transform t in FxHelper.FxRoot.transform) { var pooledFX = t.gameObject.GetComponent <PooledFx>(); var snapToLocaters = (List <SnapToLocator>)AccessTools.Field(typeof(PooledFx), "m_SnapToLocators").GetValue(pooledFX); var fxBone = snapToLocaters.Select(s => s.Locator).FirstOrDefault(); UnitEntityView unit = null; if (fxBone != null) { var viewTransform = fxBone.Transform; while (viewTransform != null && unit == null) { unit = viewTransform.GetComponent <UnitEntityView>(); if (unit == null) { viewTransform = viewTransform.parent; } } } GUILayout.BeginHorizontal(); if (unit != null) { GUILayout.Label($"{pooledFX.name} - {unit.EntityData.CharacterName} - {unit.name}", GUILayout.Width(200f)); } else { GUILayout.Label($"{pooledFX.name}", GUILayout.Width(200f)); } if (GUILayout.Button("DestroyFX", GUILayout.Width(200))) { FxHelper.Destroy(t.gameObject); } GUILayout.EndHorizontal(); } }
// setiap awake void Awake() { // instance dirinya sendiri instanceFX = this; }
public static void Functions(int index) { switch (index) { case 0: break; case 1: GameInfo(); break; case 2: KillFunctions(); break; case 3: Common.ResurrectAndFullRestore(Common.GetUnitUnderMouse()); break; case 4: Common.Buff(Common.GetUnitUnderMouse(), Storage.buffFavouritesGuids[Main.Settings.actionKeyBuffIndex]); break; case 5: editUnit = Common.GetUnitUnderMouse(); break; case 6: teleportUnit = Common.GetUnitUnderMouse(); if (teleportUnit != null && Strings.ToBool(Main.Settings.toggleAddToLog)) { Common.AddLogEntry(Strings.GetText("label_TeleportUnit") + $": {teleportUnit.CharacterName}", Color.black); } break; case 7: if (settings.actionKeySpawnRandomEnemy && Strings.ToBool(settings.toggleActionKeyExperimental)) { try { Common.SpawnHostileUnit(Common.MousePositionLocalMap(), ResourcesLibrary.GetBlueprints <BlueprintUnit>().RandomElement()); } catch (Exception e) { modLogger.Log(e.ToString()); } } else { Common.SpawnHostileUnit(Common.MousePositionLocalMap(), banditsGuids[banidtCrIndex]); } break; case 8: rotateUnit = Common.GetUnitUnderMouse(); if (rotateUnit != null && Strings.ToBool(Main.Settings.toggleAddToLog)) { Common.AddLogEntry( Strings.GetText("arrayItem_ActionKeyMain_RotateUnit") + $": {rotateUnit.CharacterName}", Color.black); } break; case 9: Common.GetUnitUnderMouse().View.AnimationManager.Execute(animationTypes[animationTypesIndex]); break; case 10: FxHelper.SpawnFxOnPoint(BlueprintRoot.Instance.Cheats.SillyCheatBlood, Common.MousePositionLocalMap()); break; case 11: Common.Charm(Common.GetUnitUnderMouse()); break; case 12: Common.AddToParty(Common.GetUnitUnderMouse()); break; case 13: Common.GetUnitUnderMouse().Descriptor.Recreate = true; break; } }
internal static void HealMagic() { // code copied from RestController.UseSpells() foreach (UnitEntityData unitEntityData in Game.Instance.Player.PartyCharacters) { if (unitEntityData.Descriptor.State.IsFinallyDead) { if (unitEntityData.Descriptor.State.ResurrectOnRest) { unitEntityData.Descriptor.Resurrect(0f, true); unitEntityData.Descriptor.State.LifeState = UnitLifeState.Conscious; unitEntityData.Damage = unitEntityData.Stats.HitPoints - Math.Min(1, unitEntityData.Descriptor.Progression.CharacterLevel); if (unitEntityData.Descriptor.IsPet) { Vector3 vector = unitEntityData.Descriptor.Master.Value.Position; if (AstarPath.active) { FreePlaceSelector.PlaceSpawnPlaces(2, unitEntityData.View.Corpulence, vector); vector = FreePlaceSelector.GetRelaxedPosition(1, true); } unitEntityData.Position = vector; } } } } if (RestController.Instance.m_ScriptedRest || Game.Instance.Player.Camping.UseSpells) { var fx = Resources.FindObjectsOfTypeAll <GameObject>().First(x => x.name == "SpellHeal00"); RestController.Instance.UpdateCharactersToBeHealedOnRest(); var partyHP = new Dictionary <string, int>(); foreach (var u in Game.Instance.Player.ControllableCharacters) { partyHP.Add(u.UniqueId, u.HPLeft); } // specific healers if (SelectionManager.Instance.SelectedUnits.Count > 0) { foreach (var unit in SelectionManager.Instance.SelectedUnits) { unit.UseSpellsOnRest(); } } // nobody is selected else { foreach (UnitEntityData unit in RestController.Instance.CharactersToBeHealedOnRest) { try { if (unit.UseSpellsOnRest()) { FxHelper.SpawnFxOnUnit(fx, unit.View); } } catch (Exception ex) { Log(ex); } } } foreach (var u in Game.Instance.Player.ControllableCharacters) { if (u.HPLeft > partyHP[u.UniqueId]) { FxHelper.SpawnFxOnUnit(fx, u.View); } } } }
public override IEnumerator <AbilityDeliveryTarget> Deliver(AbilityExecutionContext context, TargetWrapper target) { UnitEntityData caster = context.Caster; List <UnitEntityData> targets = this.GetTargets(caster); Vector3 tp = target.Point; Vector3[] points = new Vector3[targets.Count]; float[] radiuses = new float[targets.Count]; for (int i = 0; i < targets.Count; i++) { points[i] = tp; radiuses[i] = targets[i].View.Corpulence; } FreePlaceSelector.RelaxPoints(points, radiuses, targets.Count, null); Vector3 targetPoint = points[0]; GameObject portalFrom = FxHelper.SpawnFxOnUnit(this.PortalFromPrefab, caster.View, null, default(Vector3)); GameObject portalTo = FxHelper.SpawnFxOnUnit(this.PortalToPrefab, caster.View, null, default(Vector3)); if (portalTo != null) { portalTo.transform.position = targetPoint; } Transform portalFromBone = (!(portalFrom != null)) ? null : portalFrom.transform.FindChildRecursive(this.PortalBone); Vector3 portalFromPoint = (!(portalFromBone != null)) ? caster.Position : portalFromBone.transform.position; Transform portalToBone = (!(portalTo != null)) ? null : portalTo.transform.FindChildRecursive(this.PortalBone); Vector3 portalToPoint = (!(portalToBone != null)) ? targetPoint : portalToBone.transform.position; TimeSpan startTime = Game.Instance.TimeController.GameTime; bool casterTeleported = false; for (int j = 0; j < targets.Count; j++) { UnitEntityData t = targets[j]; t.Wake(10f); Vector3 teleportPosition = points[j]; GameObject prefab = (j != 0) ? this.SideDisappearFx : this.CasterDisappearFx; GameObject appearFx = (j != 0) ? this.SideAppearFx : this.CasterAppearFx; BlueprintProjectile blueprint = (j != 0) ? this.SideDisappearProjectile : this.CasterDisappearProjectile; BlueprintProjectile appearProjectile = (j != 0) ? this.SideAppearProjectile : this.CasterAppearProjectile; FxHelper.SpawnFxOnUnit(prefab, t.View, null, default(Vector3)); GameHelper.LaunchProjectile(t, portalFromPoint, blueprint, delegate(Projectile dp) { t.CombatState.PreventAttacksOfOpporunityNextFrame = true; t.Position = teleportPosition; t.View.StopMoving(); Game.Instance.ProjectileController.Launch(t, t, appearProjectile, portalToPoint, delegate(Projectile ap) { if (this.LookAtTarget) { t.ForceLookAt(target.Point); } FxHelper.SpawnFxOnUnit(appearFx, t.View, null, default(Vector3)); casterTeleported |= (caster == t); }); }); } while (!casterTeleported && Game.Instance.TimeController.GameTime - startTime < 2.Seconds()) { yield return(null); } if (casterTeleported) { yield return(new AbilityDeliveryTarget(target)); } yield break; }
public static void Functions(int index) { switch (index) { case 0: break; case 1: GameInfo(); break; case 2: KillFunctions(); break; case 3: UnitEntityDataUtils.ResurrectAndFullRestore(Common.GetUnitUnderMouse()); break; case 4: UnitEntityDataUtils.Buff(Common.GetUnitUnderMouse(), FavouritesFactory.GetFavouriteBuffs.FavouritesList[Main.settings.actionKeyBuffIndex]); break; case 5: editUnit = Common.GetUnitUnderMouse(); break; case 6: teleportUnit = Common.GetUnitUnderMouse(); if (teleportUnit != null && StringUtils.ToToggleBool(Main.settings.toggleAddToLog)) { Common.AddLogEntry(Strings.GetText("label_TeleportUnit") + $": {teleportUnit.CharacterName}", Color.black); } break; case 7: if (StringUtils.ToToggleBool(settings.toggleSpawnEnemiesFromUnitFavourites)) { try { Vector3 pos = Common.MousePositionLocalMap(); float x = 0.0f; float z = 0.0f; foreach (string guid in SpawnUnits.GetStoredGUIDs) { Vector3 finalPos = new Vector3(pos.x + 1.5f * x, pos.y, pos.z + 1.5f * z); SpawnUnits.UnitSpawner(finalPos, guid); x++; if (x > 10f) { x = 0.0f; z++; } } } catch (Exception e) { modLogger.Log(e.ToString()); } } else if (settings.actionKeySpawnRandomEnemy && StringUtils.ToToggleBool(settings.toggleActionKeyExperimental)) { try { Common.SpawnHostileUnit(Common.MousePositionLocalMap(), ResourcesLibrary.GetBlueprints <BlueprintUnit>().RandomElement()); } catch (Exception e) { modLogger.Log(e.ToString()); } } else { Common.SpawnHostileUnit(Common.MousePositionLocalMap(), banditsGuids[banidtCrIndex]); } break; case 8: rotateUnit = Common.GetUnitUnderMouse(); if (rotateUnit != null && StringUtils.ToToggleBool(Main.settings.toggleAddToLog)) { Common.AddLogEntry(Strings.GetText("arrayItem_ActionKeyMain_RotateUnit") + $": {rotateUnit.CharacterName}", Color.black); } break; case 9: Common.GetUnitUnderMouse().View.AnimationManager.Execute(animationTypes[animationTypesIndex]); break; case 10: FxHelper.SpawnFxOnPoint(BlueprintRoot.Instance.Cheats.SillyCheatBlood, Common.MousePositionLocalMap()); break; case 11: UnitEntityDataUtils.Charm(Common.GetUnitUnderMouse()); break; case 12: UnitEntityDataUtils.AddToParty(Common.GetUnitUnderMouse()); break; case 13: Common.GetUnitUnderMouse().Descriptor.Recreate = true; break; } }