harbor run -t openthoughts/tasktrove-exp-rpt-crosscodeeval-csharp-v4-crosscodeeval-csharp-0061harbor download openthoughts/tasktrove-exp-rpt-crosscodeeval-csharp-v4-crosscodeeval-csharp-0061solution file
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using static Ultrapain.ConfigManager;
namespace Ultrapain.Patches
{
// EID
class EnemyIdentifier_UpdateModifiers
{
static void Postfix(EnemyIdentifier __instance)
{
EidStatContainer container = ConfigManager.enemyStats[__instance.enemyType];
if(__instance.enemyType == EnemyType.V2)
{
V2 comp = __instance.GetComponent<V2>();
if(comp != null && comp.secondEncounter)
{
container = ConfigManager.enemyStats[EnemyType.V2Second];
}
}
__instance.totalHealthModifier *= container.health.value;
__instance.totalDamageModifier *= container.damage.value;
__instance.totalSpeedModifier *= container.speed.value;
List<string> weakness = new List<string>();
List<float> weaknessMulti = new List<float>();
foreach(KeyValuePair<string, float> weaknessPair in container.resistanceDict)
{
weakness.Add(weaknessPair.Key);
int index = Array.IndexOf(__instance.weaknesses, weaknessPair.Key);
if(index >= 0)
{
float defaultResistance = 1f / __instance.weaknessMultipliers[index];
if (defaultResistance > weaknessPair.Value)
weaknessMulti.Add(1f / defaultResistance);
else
weaknessMulti.Add(1f / weaknessPair.Value);
}
else
weaknessMulti.Add(1f / weaknessPair.Value);
}
for(int i = 0; i < __instance.weaknessMultipliers.Length; i++)
{
if (container.resistanceDict.ContainsKey(__instance.weaknesses[i]))
continue;
weakness.Add(__instance.weaknesses[i]);
weaknessMulti.Add(__instance.weaknessMultipliers[i]);
}
__instance.weaknesses = weakness.ToArray();
__instance.weaknessMultipliers = weaknessMulti.ToArray();
}
}
// DETECT DAMAGE TYPE
class Explosion_Collide_FF
{
static bool Prefix(Explosion __instance)
{
EnemyIdentifier_DeliverDamage_FF.currentCause = EnemyIdentifier_DeliverDamage_FF.DamageCause.Explosion;
if ((__instance.enemy || __instance.friendlyFire) && __instance.canHit != AffectedSubjects.PlayerOnly)
EnemyIdentifier_DeliverDamage_FF.friendlyBurn = true;
return true;
}
static void Postfix()
{
EnemyIdentifier_DeliverDamage_FF.currentCause = EnemyIdentifier_DeliverDamage_FF.DamageCause.Unknown;
EnemyIdentifier_DeliverDamage_FF.friendlyBurn = false;
}
}
class PhysicalShockwave_CheckCollision_FF
{
static bool Prefix()
{
EnemyIdentifier_DeliverDamage_FF.currentCause = EnemyIdentifier_DeliverDamage_FF.DamageCause.Explosion;
return true;
}
static void Postfix()
{
EnemyIdentifier_DeliverDamage_FF.currentCause = EnemyIdentifier_DeliverDamage_FF.DamageCause.Unknown;
}
}
class VirtueInsignia_OnTriggerEnter_FF
{
static bool Prefix(VirtueInsignia __instance)
{
if (__instance.gameObject.name == "PlayerSpawned")
return true;
EnemyIdentifier_DeliverDamage_FF.currentCause = EnemyIdentifier_DeliverDamage_FF.DamageCause.Fire;
EnemyIdentifier_DeliverDamage_FF.friendlyBurn = true;
return true;
}
static void Postfix()
{
EnemyIdentifier_DeliverDamage_FF.currentCause = EnemyIdentifier_DeliverDamage_FF.DamageCause.Unknown;
EnemyIdentifier_DeliverDamage_FF.friendlyBurn = false;
}
}
class SwingCheck2_CheckCollision_FF
{
static bool Prefix()
{
EnemyIdentifier_DeliverDamage_FF.currentCause = EnemyIdentifier_DeliverDamage_FF.DamageCause.Melee;
return true;
}
static void Postfix()
{
EnemyIdentifier_DeliverDamage_FF.currentCause = EnemyIdentifier_DeliverDamage_FF.DamageCause.Unknown;
}
}
class Projectile_Collided_FF
{
static bool Prefix()
{
EnemyIdentifier_DeliverDamage_FF.currentCause = EnemyIdentifier_DeliverDamage_FF.DamageCause.Projectile;
return true;
}
static void Postfix()
{
EnemyIdentifier_DeliverDamage_FF.currentCause = EnemyIdentifier_DeliverDamage_FF.DamageCause.Unknown;
}
}
class EnemyIdentifier_DeliverDamage_FF
{
public enum DamageCause
{
Explosion,
Projectile,
Fire,
Melee,
Unknown
}
public static DamageCause currentCause = DamageCause.Unknown;
public static bool friendlyBurn = false;
[HarmonyBefore]
static bool Prefix(
This is a line completion task in the CrossCodeEval style. The C# snippet
above ends mid-declaration on purpose -- on something like public List<,
private unsafe , or [JsonProperty("...")]\n public bool? X {. Your
job is to output the short continuation that completes that cut-off code
fragment. The continuation is typically 1-3 lines and 20-200 characters; it
is appended to the snippet conceptually, NOT a standalone file.
You must write your line-completion fragment to /app/solution.txt. The
verifier reads ONLY that file. The most common mistake is to type the C#
fragment straight into bash -- bash treats (, <, >, ,, {, etc.
as shell metacharacters and dies with syntax error near unexpected token,
and /app/solution.txt never gets created.
To avoid all bash-quoting traps, use the pre-installed helper:
write_solution 'YOUR FRAGMENT GOES HERE'
write_solution is on your PATH. It takes its single argument verbatim,
writes it to /app/solution.txt followed by a newline, and is safe with
any C# content because the argument is single-quoted. You must single-quote
your fragment so bash does not try to interpret the inner punctuation. If
your fragment itself contains a single quote, escape it as '\''.
Equivalent without the helper (slightly more error-prone):
printf '%s\n' 'YOUR FRAGMENT GOES HERE' > /app/solution.txt
WRONG -- typed into bash, gets syntax error, never creates solution.txt:
Module> Modules => GetModules();
WRONG -- unquoted < > ( ) blow up at bash parse-time:
echo -n string QueryServiceFilePath(SafeServiceHandle service) > /app/solution.txt
WRONG -- nested bash -lc '...' without escaping inner punctuation:
bash -lc 'echo -n string QueryServiceFilePath(SafeServiceHandle service) > /app/solution.txt'
WRONG -- literal \n (backslash-n) instead of a real newline; printf is
never told to terminate:
printf '...content with literal \\n in it...' >> /app/solution.txt
RIGHT -- single-quoted, written through the helper:
write_solution 'Module> Modules => GetModules();'
RIGHT -- single-quoted, written through printf:
printf '%s\n' 'Module> Modules => GetModules();' > /app/solution.txt
using directives or namespace blocks. Do NOT
wrap the fragment in Markdown code fences. Do NOT prepend solution: or
any other label.If the snippet above ended with:
public Kernel Kernel { get; private set; }
public List<
then a reasonable /app/solution.txt would be:
Module> Modules => GetModules();
(NOT a full class declaration, NOT a using ...; block.) To write that,
run exactly:
write_solution 'Module> Modules => GetModules();'