Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

Commit

Permalink
#28 Added blue orb attack during mortar attack
Browse files Browse the repository at this point in the history
Default values need to be tested before release
  • Loading branch information
eternalUnion committed Jun 2, 2023
1 parent 5f05d5c commit 9ac315b
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
20 changes: 20 additions & 0 deletions Ultrapain/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,12 @@ public enum SwordsMachineSecondPhase
public static IntField panopticonSpinAttackDamage;
public static FloatField panopticonSpinAttackDistance;

public static BoolField panopticonBlueProjToggle;
public static IntField panopticonBlueProjCount;
public static FloatField panopticonBlueProjDamage;
public static FloatField panopticonBlueProjTurnSpeed;
public static FloatField panopticonBlueProjInitialSpeed;

/////////// ADD MEEEE
// GABRIEL SECOND
public static BoolField gabriSecondP1Chaos;
Expand Down Expand Up @@ -1578,6 +1584,20 @@ public static void Initialize()
panopticonSpinAttackTurnSpeed = new FloatField(panopticonSpinInsigniaDiv, "Turn speed", "panopticonSpinAttackTurnSpeed", 60f, 0f, float.MaxValue);
panopticonSpinAttackActivateSpeed = new FloatField(panopticonSpinInsigniaDiv, "Activasion speed", "panopticonSpinAttackActivateSpeed", 0.5f, 0f, float.MaxValue);

new ConfigHeader(panopticonPanel, "Blue Orb Attack");
ConfigDivision panopticonBlueProjDiv = new ConfigDivision(panopticonPanel, "panopticonBlueProjDiv");
panopticonBlueProjToggle = new BoolField(panopticonPanel, "Enabled", "panopticonBlueProjToggle", true);
panopticonBlueProjToggle.onValueChange += (BoolField.BoolValueChangeEvent e) =>
{
panopticonBlueProjDiv.interactable = e.value;
dirtyField = true;
};
panopticonBlueProjToggle.TriggerValueChangeEvent();
panopticonBlueProjCount = new IntField(panopticonBlueProjDiv, "Projectile count", "panopticonBlueProjCount", 3, 1, int.MaxValue);
panopticonBlueProjDamage = new FloatField(panopticonBlueProjDiv, "Projectile damage", "panopticonBlueProjDiv", 5, 0, float.MaxValue);
panopticonBlueProjTurnSpeed = new FloatField(panopticonBlueProjDiv, "Projectile turn speed multiplier", "panopticonBlueProjTurnSpeed", 1f, 0f, float.MaxValue);
panopticonBlueProjInitialSpeed = new FloatField(panopticonBlueProjDiv, "Projectile initial speed", "panopticonBlueProjInitialSpeed", 0f, 0f, float.MaxValue);

config.Flush();
//config.LogDuplicateGUID();
Plugin.PatchAll();
Expand Down
60 changes: 59 additions & 1 deletion Ultrapain/Patches/Panopticon.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System;
using HarmonyLib;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using UnityEngine;
using UnityEngine.UIElements;
Expand Down Expand Up @@ -199,4 +204,57 @@ static void Postfix(FleshPrison __instance, StateInfo __state)
__instance.fleshDrone = __state.template;
}
}

class Panopticon_BlueProjectile
{
public static void BlueProjectileSpawn(FleshPrison instance)
{
if (!instance.altVersion || !ConfigManager.panopticonBlueProjToggle.value)
return;

int count = ConfigManager.panopticonBlueProjCount.value;
float deltaAngle = 360f / (count + 1);
float currentAngle = deltaAngle;

for (int i = 0; i < count; i++)
{
GameObject proj = GameObject.Instantiate(Plugin.homingProjectile, instance.rotationBone.position + instance.rotationBone.up * 16f, instance.rotationBone.rotation);
proj.transform.position += proj.transform.forward * 5f;
proj.transform.RotateAround(instance.transform.position, Vector3.up, currentAngle);
currentAngle += deltaAngle;
Projectile comp = proj.GetComponent<Projectile>();
comp.safeEnemyType = EnemyType.FleshPanopticon;
comp.target = instance.target;
comp.damage = ConfigManager.panopticonBlueProjDamage.value * instance.eid.totalDamageModifier;
comp.turningSpeedMultiplier *= ConfigManager.panopticonBlueProjTurnSpeed.value;
comp.speed = ConfigManager.panopticonBlueProjInitialSpeed.value;
}
}

static MethodInfo m_Panopticon_BlueProjectile_BlueProjectileSpawn = typeof(Panopticon_BlueProjectile).GetMethod("BlueProjectileSpawn", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
static MethodInfo m_GameObject_GetComponent_Projectile = typeof(GameObject).GetMethod("GetComponent", new Type[0]).MakeGenericMethod(new Type[1] { typeof(Projectile) });

static IEnumerable Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> code = new List<CodeInstruction>(instructions);

for (int i = 0; i < code.Count; i++)
{
if (code[i].opcode == OpCodes.Callvirt && code[i].OperandIs(m_GameObject_GetComponent_Projectile))
{
i += 2;

// Push instance reference
code.Insert(i, new CodeInstruction(OpCodes.Ldarg_0));
i += 1;
// Call the method
code.Insert(i, new CodeInstruction(OpCodes.Call, m_Panopticon_BlueProjectile_BlueProjectileSpawn));

break;
}
}

return code.AsEnumerable();
}
}
}
2 changes: 2 additions & 0 deletions Ultrapain/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ private static void PatchAllEnemies()
harmonyTweaks.Patch(GetMethod<FleshPrison>("SpawnBlackHole"), postfix: GetHarmonyMethod(GetMethod<Panopticon_SpawnBlackHole>("Postfix")));
if (ConfigManager.panopticonBalanceEyes.value)
harmonyTweaks.Patch(GetMethod<FleshPrison>("SpawnFleshDrones"), prefix: GetHarmonyMethod(GetMethod<Panopticon_SpawnFleshDrones>("Prefix")), postfix: GetHarmonyMethod(GetMethod<Panopticon_SpawnFleshDrones>("Postfix")));
if (ConfigManager.panopticonBlueProjToggle.value)
harmonyTweaks.Patch(GetMethod<FleshPrison>("Update"), transpiler: GetHarmonyMethod(GetMethod<Panopticon_BlueProjectile>("Transpiler")));

// ADDME
/*
Expand Down

0 comments on commit 9ac315b

Please sign in to comment.