spraycan: use permanent decals
instead of using auto decals, letting them time out and just Not replacing them when they're meant to be gone, this spawns a permanent decal (not affected by decal limit) and explicitly deletes it when necessary. as a consequence of this, spraying more than 11 decals Immediately removes the oldest spray. Addresses issue #1
This commit is contained in:
parent
f4bf7a793e
commit
56a46d0790
17
decaldef.txt
17
decaldef.txt
@ -1,20 +1,12 @@
|
||||
fader KiriInstantFade
|
||||
{
|
||||
DecayStart 60.0
|
||||
DecayTime 0.0
|
||||
}
|
||||
|
||||
decal KiriTestDecal
|
||||
{
|
||||
pic KSPYA0
|
||||
animator KiriInstantFade
|
||||
randomflipx
|
||||
}
|
||||
|
||||
decal SnekSpray_TransPride
|
||||
{
|
||||
pic KSPYA0
|
||||
animator KiriInstantFade
|
||||
randomflipx
|
||||
translucent 0.8
|
||||
}
|
||||
@ -22,7 +14,6 @@ decal SnekSpray_TransPride
|
||||
decal SnekSpray_LesbianPride
|
||||
{
|
||||
pic KSPYB0
|
||||
animator KiriInstantFade
|
||||
randomflipx
|
||||
translucent 0.8
|
||||
}
|
||||
@ -30,7 +21,6 @@ decal SnekSpray_LesbianPride
|
||||
decal SnekSpray_NBPride
|
||||
{
|
||||
pic KSPYC0
|
||||
animator KiriInstantFade
|
||||
randomflipx
|
||||
translucent 0.8
|
||||
}
|
||||
@ -38,7 +28,6 @@ decal SnekSpray_NBPride
|
||||
decal SnekSpray_AcePride
|
||||
{
|
||||
pic KSPYD0
|
||||
animator KiriInstantFade
|
||||
randomflipx
|
||||
translucent 0.8
|
||||
}
|
||||
@ -46,34 +35,29 @@ decal SnekSpray_AcePride
|
||||
decal SnekSpray_ProgressPride
|
||||
{
|
||||
pic KSPYE0
|
||||
animator KiriInstantFade
|
||||
translucent 0.8
|
||||
}
|
||||
|
||||
decal SnekSpray_DemiPride
|
||||
{
|
||||
pic KSPYF0
|
||||
animator KiriInstantFade
|
||||
translucent 0.8
|
||||
}
|
||||
|
||||
decal SnekSpray_PanPride
|
||||
{
|
||||
pic KSPYG0
|
||||
animator KiriInstantFade
|
||||
translucent 0.8
|
||||
}
|
||||
|
||||
decal SnekSpray_SwitchPride
|
||||
{
|
||||
pic KSPYH0
|
||||
animator KiriInstantFade
|
||||
}
|
||||
|
||||
decal SnekSpray_BiPride
|
||||
{
|
||||
pic KSPYI0
|
||||
animator KiriInstantFade
|
||||
translucent 0.8
|
||||
randomflipx
|
||||
}
|
||||
@ -81,7 +65,6 @@ decal SnekSpray_BiPride
|
||||
decal SnekSpray_GayPride
|
||||
{
|
||||
pic KSPYJ0
|
||||
animator KiriInstantFade
|
||||
translucent 0.8
|
||||
randomflipx
|
||||
}
|
||||
|
@ -113,8 +113,6 @@ class SnekTechSprayer : HDWeapon
|
||||
|
||||
} else {
|
||||
|
||||
Actor spawnedThing;
|
||||
bool success;
|
||||
float zOffset = GunHeight() * 0.8;
|
||||
FLineTraceData lineTraceData;
|
||||
|
||||
@ -154,15 +152,12 @@ class SnekTechSprayer : HDWeapon
|
||||
"kiri/spraycan_spray",
|
||||
CHAN_WEAPON);
|
||||
|
||||
[success, spawnedThing] = A_SpawnItemEx(
|
||||
"SnekTechSprayerDecalSpawner",
|
||||
xofs : 0, yofs : 0, zofs : zOffset);
|
||||
|
||||
let normal = lineTraceData.HitDir;
|
||||
let spawnedThing = Actor.Spawn("SnekTechSprayerDecalSpawner", lineTraceData.HitLocation - normal);
|
||||
SnekTechSprayerDecalSpawner spawner = SnekTechSprayerDecalSpawner(spawnedThing);
|
||||
|
||||
if(success && spawner) {
|
||||
spawner.A_SetPitch(pitch);
|
||||
spawner.A_SetAngle(angle);
|
||||
if(spawner) {
|
||||
spawner.angle = VectorAngle(-normal.x, -normal.y);
|
||||
spawner.actualDecalName = actualDecalName;
|
||||
spawner.master = invoker.owner;
|
||||
|
||||
@ -362,7 +357,7 @@ class SnekTechSprayer : HDWeapon
|
||||
}
|
||||
}
|
||||
|
||||
class SnekTechSprayerDecalSpawner : Actor
|
||||
class SnekTechSprayerDecalSpawner : Decal
|
||||
{
|
||||
default
|
||||
{
|
||||
@ -376,14 +371,65 @@ class SnekTechSprayerDecalSpawner : Actor
|
||||
stop;
|
||||
}
|
||||
|
||||
int timeSinceLastSpray;
|
||||
int thisSprayerId;
|
||||
String actualDecalName;
|
||||
|
||||
Array<Thinker> decals;
|
||||
|
||||
void SpawnDecal()
|
||||
{
|
||||
Thinker think;
|
||||
array<thinker> seen;
|
||||
|
||||
// find every decal that Isn't ours
|
||||
let iter = ThinkerIterator.Create('Thinker', STAT_DECAL);
|
||||
while (think = iter.Next()) {
|
||||
// BaseDecal isn't exported to zscript so we have to filter this manually
|
||||
if (think.GetClassName() == 'BaseDecal') {
|
||||
seen.Push(think);
|
||||
}
|
||||
}
|
||||
|
||||
// pass the decal name as a map editor type of argument
|
||||
args[0] = -int(name(actualDecalName));
|
||||
// spawn the decal
|
||||
Super.SpawnDecal();
|
||||
|
||||
// then find every decal that we spawned
|
||||
iter.Reinit();
|
||||
while (think = iter.Next()) {
|
||||
if (think.GetClassName() == 'BaseDecal' &&
|
||||
seen.Find(think) == seen.Size())
|
||||
{
|
||||
decals.Push(think);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override void OnDestroy()
|
||||
{
|
||||
for (let i = 0; i < decals.Size(); i++) {
|
||||
if (decals[i]) {
|
||||
decals[i].Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Decal::BeginPlay deletes the actor
|
||||
override void BeginPlay() {Actor.BeginPlay();}
|
||||
|
||||
override void PostBeginPlay()
|
||||
{
|
||||
Super.PostBeginPlay();
|
||||
A_SprayDecal(actualDecalName, KIRI_SPRAY_DISTANCE);
|
||||
|
||||
// copy A_SprayDecal z offset
|
||||
setz(pos.z + height / 2);
|
||||
|
||||
SpawnDecal();
|
||||
if (decals.Size() == 0) {
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
// Figure out a new ID number.
|
||||
ThinkerIterator iter = ThinkerIterator.Create("SnekTechSprayerDecalSpawner");
|
||||
@ -421,18 +467,6 @@ class SnekTechSprayerDecalSpawner : Actor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override void Tick()
|
||||
{
|
||||
super.Tick();
|
||||
|
||||
timeSinceLastSpray++;
|
||||
|
||||
if(timeSinceLastSpray >= 35 * 60) {
|
||||
A_SprayDecal(actualDecalName, KIRI_SPRAY_DISTANCE);
|
||||
timeSinceLastSpray = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SnekTechSprayerPattern : Actor
|
||||
|
Loading…
Reference in New Issue
Block a user