暂存2
This commit is contained in:
@@ -17,8 +17,9 @@ namespace WulaFallenEmpire
|
||||
// --- Our custom state ---
|
||||
private int ticksLeft;
|
||||
private int ticksToNextDamage;
|
||||
private int explosionTicks;
|
||||
private Vector3 beamEnd;
|
||||
|
||||
|
||||
private VerbProperties_Wula_IonicBeam BeamProps => (VerbProperties_Wula_IonicBeam)verbProps;
|
||||
|
||||
public override float? AimAngleOverride => (state == VerbState.Bursting) ? (beamEnd - caster.DrawPos).AngleFlat() : (float?)null;
|
||||
@@ -27,11 +28,9 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
base.WarmupComplete();
|
||||
|
||||
// For sustained beam, it always reaches its max range
|
||||
var shotAngle = (currentTarget.Cell - caster.Position).AngleFlat;
|
||||
beamEnd = GetMapEdgePoint(caster.Position, shotAngle);
|
||||
|
||||
// --- Copied Effect Logic ---
|
||||
if (verbProps.beamMoteDef != null)
|
||||
{
|
||||
mote = MoteMaker.MakeInteractionOverlay(verbProps.beamMoteDef, caster, new TargetInfo(beamEnd.ToIntVec3(), caster.Map));
|
||||
@@ -44,10 +43,9 @@ namespace WulaFallenEmpire
|
||||
|
||||
public override void BurstingTick()
|
||||
{
|
||||
// This verb is not a standard "burst", but we use the state to manage the effect
|
||||
if (ticksLeft > 0)
|
||||
{
|
||||
// --- Copied Effect Logic ---
|
||||
// --- Maintain Visual Effects ---
|
||||
if (mote != null)
|
||||
{
|
||||
mote.UpdateTargets(new TargetInfo(caster.Position, caster.Map), new TargetInfo(beamEnd.ToIntVec3(), caster.Map), Vector3.zero, Vector3.zero);
|
||||
@@ -63,15 +61,26 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
sustainer?.Maintain();
|
||||
|
||||
// --- Custom Damage Logic ---
|
||||
ticksLeft--;
|
||||
// --- Beam Damage Logic ---
|
||||
ticksToNextDamage--;
|
||||
if (ticksToNextDamage <= 0)
|
||||
{
|
||||
ApplyDamage();
|
||||
ApplyBeamDamage();
|
||||
ticksToNextDamage = BeamProps.tickInterval;
|
||||
}
|
||||
|
||||
// --- Path Explosion Logic ---
|
||||
if (BeamProps.explosionEnabled)
|
||||
{
|
||||
explosionTicks--;
|
||||
if (explosionTicks <= 0)
|
||||
{
|
||||
ApplyPathExplosionDamage();
|
||||
explosionTicks = BeamProps.explosionTickInterval;
|
||||
}
|
||||
}
|
||||
|
||||
ticksLeft--;
|
||||
if (ticksLeft <= 0)
|
||||
{
|
||||
StopBeam();
|
||||
@@ -83,16 +92,25 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
this.state = VerbState.Bursting;
|
||||
this.ticksLeft = BeamProps.duration;
|
||||
this.ticksToNextDamage = 0; // First damage tick happens immediately
|
||||
this.ticksToNextDamage = 0;
|
||||
this.explosionTicks = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ApplyDamage()
|
||||
private void StopBeam()
|
||||
{
|
||||
this.state = VerbState.Idle;
|
||||
mote?.Destroy();
|
||||
endEffecter?.Cleanup();
|
||||
sustainer?.End();
|
||||
}
|
||||
|
||||
private void ApplyBeamDamage()
|
||||
{
|
||||
var shotAngle = (beamEnd - caster.DrawPos).AngleFlat();
|
||||
var dinfo = new DamageInfo(verbProps.beamDamageDef ?? DamageDefOf.Burn, BeamProps.sustainedDamagePerTick, BeamProps.armorPenetration, shotAngle, caster, EquipmentSource);
|
||||
var cellsInBeam = WulaBeamUtility.GetCellsInBeamArea(caster.Position, beamEnd.ToIntVec3(), verbProps.beamWidth);
|
||||
var dinfo = new DamageInfo(verbProps.beamDamageDef ?? DamageDefOf.Burn, BeamProps.sustainedDamagePerTick, BeamProps.armorPenetration, shotAngle, caster, null, EquipmentSource?.def);
|
||||
var cellsInBeam = WulaBeamUtility.GetCellsInBeamArea(caster.Position, beamEnd.ToIntVec3(), (int)verbProps.beamWidth);
|
||||
|
||||
foreach (var cell in cellsInBeam)
|
||||
{
|
||||
@@ -105,13 +123,38 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void StopBeam()
|
||||
|
||||
private void ApplyPathExplosionDamage()
|
||||
{
|
||||
this.state = VerbState.Idle;
|
||||
mote?.Destroy();
|
||||
endEffecter?.Cleanup();
|
||||
sustainer?.End();
|
||||
if (BeamProps.explosionDamageDef == null) return;
|
||||
|
||||
var pathCells = WulaBeamUtility.GetCellsInBeamArea(caster.Position, beamEnd.ToIntVec3(), (int)verbProps.beamWidth);
|
||||
var shotAngle = (beamEnd - caster.DrawPos).AngleFlat();
|
||||
var explosionDamageDef = BeamProps.explosionDamageDef;
|
||||
|
||||
foreach (var cell in pathCells)
|
||||
{
|
||||
if (!cell.InBounds(caster.Map)) continue;
|
||||
|
||||
if (cell.GetHashCode() % 3 != 0) continue;
|
||||
|
||||
var thingsToHit = cell.GetThingList(caster.Map).Where(t => CanHit(t)).ToList();
|
||||
foreach (var thing in thingsToHit)
|
||||
{
|
||||
var dinfo = new DamageInfo(explosionDamageDef, explosionDamageDef.defaultDamage, explosionDamageDef.defaultArmorPenetration, shotAngle, caster, null, EquipmentSource?.def);
|
||||
thing.TakeDamage(dinfo);
|
||||
}
|
||||
|
||||
if(BeamProps.explosionCellFleck != null)
|
||||
{
|
||||
FleckMaker.Static(cell, caster.Map, BeamProps.explosionCellFleck);
|
||||
}
|
||||
if (BeamProps.soundExplosion != null)
|
||||
{
|
||||
BeamProps.soundExplosion.PlayOneShot(new TargetInfo(cell, caster.Map));
|
||||
}
|
||||
GenTemperature.PushHeat(cell, caster.Map, BeamProps.explosionHeatEnergyPerCell);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExposeData()
|
||||
@@ -119,6 +162,7 @@ namespace WulaFallenEmpire
|
||||
base.ExposeData();
|
||||
Scribe_Values.Look(ref ticksLeft, "ticksLeft", 0);
|
||||
Scribe_Values.Look(ref ticksToNextDamage, "ticksToNextDamage", 0);
|
||||
Scribe_Values.Look(ref explosionTicks, "explosionTicks");
|
||||
Scribe_Values.Look(ref beamEnd, "beamEnd");
|
||||
}
|
||||
|
||||
@@ -131,7 +175,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
float mapSize = Mathf.Max(caster.Map.Size.x, caster.Map.Size.z) * 1.5f;
|
||||
Vector3 direction = Quaternion.AngleAxis(angle, Vector3.up) * Vector3.forward;
|
||||
return start.toVector3() + direction * mapSize;
|
||||
return start.ToVector3() + direction * mapSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user