Remove redundant "clearscope" from utility functions.
This commit is contained in:
parent
b1683dae8e
commit
e5cb32bc02
8 changed files with 73 additions and 73 deletions
|
|
@ -3,7 +3,7 @@
|
|||
Class SWWMUtility
|
||||
{
|
||||
// gets the names of all mod cvars
|
||||
static clearscope void GetCVars( out Array<String> cvarlist )
|
||||
static void GetCVars( out Array<String> cvarlist )
|
||||
{
|
||||
cvarlist.Clear();
|
||||
let lmp = Wads.CheckNumForFullname("cvarinfo.base");
|
||||
|
|
@ -32,7 +32,7 @@ Class SWWMUtility
|
|||
}
|
||||
|
||||
// sends
|
||||
static clearscope void SendTooltip( Class<SWWMWeapon> which )
|
||||
static void SendTooltip( Class<SWWMWeapon> which )
|
||||
{
|
||||
if ( !swwm_weapontooltips ) return;
|
||||
CVar v = CVar.FindCVar('swwm_tooltipshown');
|
||||
|
|
@ -53,7 +53,7 @@ Class SWWMUtility
|
|||
Console.Printf(StringTable.Localize("$SWWM_TTNOTE"));
|
||||
}
|
||||
|
||||
static clearscope bool CheatsDisabled( int p = -1 )
|
||||
static bool CheatsDisabled( int p = -1 )
|
||||
{
|
||||
if ( cl_blockcheats || ((G_SkillPropertyInt(SKILLP_DisableCheats) || netgame || deathmatch) && !sv_cheats) )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
extend class SWWMUtility
|
||||
{
|
||||
static clearscope void MarkAchievement( String mvar, PlayerInfo p = null )
|
||||
static void MarkAchievement( String mvar, PlayerInfo p = null )
|
||||
{
|
||||
if ( !p || (p != players[consoleplayer]) ) return;
|
||||
let hnd = SWWMStaticHandler(StaticEventHandler.Find("SWWMStaticHandler"));
|
||||
|
|
@ -16,7 +16,7 @@ extend class SWWMUtility
|
|||
if ( val == "2" ) return;
|
||||
hnd.achievementstate.Insert(mvar,"1");
|
||||
}
|
||||
static clearscope int GetAchievementProgress( String pvar, PlayerInfo p = null )
|
||||
static int GetAchievementProgress( String pvar, PlayerInfo p = null )
|
||||
{
|
||||
if ( !p || (p != players[consoleplayer]) ) return 0;
|
||||
let hnd = SWWMStaticHandler(StaticEventHandler.Find("SWWMStaticHandler"));
|
||||
|
|
@ -29,7 +29,7 @@ extend class SWWMUtility
|
|||
}
|
||||
return pval.ToInt();
|
||||
}
|
||||
static clearscope void AchievementProgress( String pvar, int val, PlayerInfo p = null )
|
||||
static void AchievementProgress( String pvar, int val, PlayerInfo p = null )
|
||||
{
|
||||
if ( !p || (p != players[consoleplayer]) ) return;
|
||||
let hnd = SWWMStaticHandler(StaticEventHandler.Find("SWWMStaticHandler"));
|
||||
|
|
@ -43,7 +43,7 @@ extend class SWWMUtility
|
|||
if ( val <= pval.ToInt() ) return;
|
||||
hnd.achievementprogress.Insert(pvar,String.Format("%d",val));
|
||||
}
|
||||
static clearscope void AchievementProgressInc( String pvar, int inc, PlayerInfo p = null )
|
||||
static void AchievementProgressInc( String pvar, int inc, PlayerInfo p = null )
|
||||
{
|
||||
if ( !p || (p != players[consoleplayer]) ) return;
|
||||
let hnd = SWWMStaticHandler(StaticEventHandler.Find("SWWMStaticHandler"));
|
||||
|
|
@ -56,7 +56,7 @@ extend class SWWMUtility
|
|||
}
|
||||
hnd.achievementprogress.Insert(pvar,String.Format("%d",pval.ToInt()+inc));
|
||||
}
|
||||
static clearscope void AchievementProgressIncDouble( String pvar, double inc, PlayerInfo p = null )
|
||||
static void AchievementProgressIncDouble( String pvar, double inc, PlayerInfo p = null )
|
||||
{
|
||||
if ( !p || (p != players[consoleplayer]) ) return;
|
||||
let hnd = SWWMStaticHandler(StaticEventHandler.Find("SWWMStaticHandler"));
|
||||
|
|
@ -70,7 +70,7 @@ extend class SWWMUtility
|
|||
hnd.achievementprogress.Insert(pvar,String.Format("%g",pval.ToDouble()+inc));
|
||||
}
|
||||
// for bitfields
|
||||
static clearscope void AchievementProgressOr( String pvar, int val, PlayerInfo p = null )
|
||||
static void AchievementProgressOr( String pvar, int val, PlayerInfo p = null )
|
||||
{
|
||||
if ( !p || (p != players[consoleplayer]) ) return;
|
||||
let hnd = SWWMStaticHandler(StaticEventHandler.Find("SWWMStaticHandler"));
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
extend Class SWWMUtility
|
||||
{
|
||||
// try to be as thorough as possible in checking if DEHACKED has altered this actor
|
||||
static clearscope bool CheckDehackery( Class<Actor> cls )
|
||||
static bool CheckDehackery( Class<Actor> cls )
|
||||
{
|
||||
let def = GetDefaultByType(cls);
|
||||
for ( State s=def.SpawnState; s; s=s.NextState )
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// gendered languages are a fuck
|
||||
static clearscope bool SellFemaleItem( Inventory i, String loc = "SWWM_SELLEXTRA_FEM" )
|
||||
static bool SellFemaleItem( Inventory i, String loc = "SWWM_SELLEXTRA_FEM" )
|
||||
{
|
||||
// no gendered string alt
|
||||
if ( StringTable.Localize("$"..loc) == loc )
|
||||
|
|
@ -305,14 +305,14 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// returns the plural tag (if available)
|
||||
static clearscope string GetAmmoTag( Inventory i )
|
||||
static string GetAmmoTag( Inventory i )
|
||||
{
|
||||
if ( i is 'MagAmmo' ) return StringTable.Localize("$T_"..MagAmmo(i).PickupTag.."S");
|
||||
if ( i is 'SWWMAmmo' ) return StringTable.Localize("$T_"..SWWMAmmo(i).PickupTag.."S");
|
||||
return i.GetTag();
|
||||
}
|
||||
// because of zscript fuckery with GetDefaultByType
|
||||
static clearscope string GetAmmoTagClass( Class<Inventory> i )
|
||||
static string GetAmmoTagClass( Class<Inventory> i )
|
||||
{
|
||||
if ( i is 'MagAmmo' ) return StringTable.Localize("$T_"..GetDefaultByType((Class<MagAmmo>)(i)).PickupTag.."S");
|
||||
if ( i is 'SWWMAmmo' ) return StringTable.Localize("$T_"..GetDefaultByType((Class<SWWMAmmo>)(i)).PickupTag.."S");
|
||||
|
|
@ -342,7 +342,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// Is this a beam projectile? (speed == length)
|
||||
static play bool IsBeamProj( Actor a )
|
||||
static bool IsBeamProj( Actor a )
|
||||
{
|
||||
if ( a is 'SaltBeam' ) return true;
|
||||
if ( a is 'BiosparkBeam' ) return true;
|
||||
|
|
@ -356,13 +356,13 @@ extend Class SWWMUtility
|
|||
return false;
|
||||
}
|
||||
// is this a YBeam type? (real pitch is pitch-90)
|
||||
static play bool IsYBeam( Actor a )
|
||||
static bool IsYBeam( Actor a )
|
||||
{
|
||||
if ( a is 'MisterRailBeam' ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static clearscope bool IdentifyingDog( Actor a )
|
||||
static bool IdentifyingDog( Actor a )
|
||||
{
|
||||
if ( a is 'MBFHelperDog' ) return true;
|
||||
if ( a is 'SWWMDog' ) return true;
|
||||
|
|
@ -375,7 +375,7 @@ extend Class SWWMUtility
|
|||
return false;
|
||||
}
|
||||
|
||||
static clearscope bool IdentifyingCaco( Actor a )
|
||||
static bool IdentifyingCaco( Actor a )
|
||||
{
|
||||
if ( a is 'DeadCacodemon' ) return false;
|
||||
if ( a is 'Cacodemon' ) return true;
|
||||
|
|
@ -388,13 +388,13 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// Друг
|
||||
static clearscope bool IdentifyingDrug( Actor a )
|
||||
static bool IdentifyingDrug( Actor a )
|
||||
{
|
||||
if ( a is 'Beast' ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static clearscope bool IdentifyingDoubleBoi( Actor a )
|
||||
static bool IdentifyingDoubleBoi( Actor a )
|
||||
{
|
||||
if ( a is 'Ettin' ) return true;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ extend Class SWWMUtility
|
|||
{
|
||||
// how the fuck is this not available to ZScript?
|
||||
// copied from P_PointOnLineSidePrecise()
|
||||
deprecated("4.11", "Use Level.PointOnLineSide() instead") static clearscope int PointOnLineSide( Vector2 p, Line l )
|
||||
deprecated("4.11", "Use Level.PointOnLineSide() instead") static int PointOnLineSide( Vector2 p, Line l )
|
||||
{
|
||||
if ( !l ) return 0;
|
||||
return (((p.y-l.v1.p.y)*l.delta.x+(l.v1.p.x-p.x)*l.delta.y) > double.epsilon);
|
||||
|
|
@ -19,7 +19,7 @@ extend Class SWWMUtility
|
|||
|
||||
// haha another one
|
||||
// copied from BoxOnLineSide()
|
||||
deprecated("4.11", "Use Level.BoxOnLineSide() instead") static clearscope int BoxOnLineSide( double top, double bottom, double left, double right, Line l )
|
||||
deprecated("4.11", "Use Level.BoxOnLineSide() instead") static int BoxOnLineSide( double top, double bottom, double left, double right, Line l )
|
||||
{
|
||||
if ( !l ) return 0;
|
||||
int p1, p2;
|
||||
|
|
@ -61,7 +61,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// wrapper
|
||||
deprecated("4.11", "Use Level.ActorOnLineSide() instead") static clearscope int ActorOnLineSide( Actor a, Line l )
|
||||
deprecated("4.11", "Use Level.ActorOnLineSide() instead") static int ActorOnLineSide( Actor a, Line l )
|
||||
{
|
||||
double box[4];
|
||||
box[0] = a.pos.y+a.radius;
|
||||
|
|
@ -136,7 +136,7 @@ extend Class SWWMUtility
|
|||
SetToSlopeSpecific(a,dang,plane,flipnorm);
|
||||
}
|
||||
|
||||
static clearscope int GetLineLock( Line l )
|
||||
static int GetLineLock( Line l )
|
||||
{
|
||||
int locknum = l.locknumber;
|
||||
if ( !locknum )
|
||||
|
|
@ -162,7 +162,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// return if a line is an exit, and additionally the type of exit
|
||||
static clearscope bool, int IsExitLine( Line l )
|
||||
static bool, int IsExitLine( Line l )
|
||||
{
|
||||
if ( l.special == Exit_Secret )
|
||||
return true, ET_Secret;
|
||||
|
|
@ -190,7 +190,7 @@ extend Class SWWMUtility
|
|||
return false, ET_Normal;
|
||||
}
|
||||
|
||||
static clearscope bool IsTeleportLine( Line l, bool all = false )
|
||||
static bool IsTeleportLine( Line l, bool all = false )
|
||||
{
|
||||
// must be two-sided and crossable
|
||||
if ( !l.sidedef[1] || !(l.Activation&(SPAC_Cross|SPAC_MCross|SPAC_PCross|SPAC_AnyCross)) ) return false;
|
||||
|
|
@ -208,18 +208,18 @@ extend Class SWWMUtility
|
|||
return false;
|
||||
}
|
||||
|
||||
static clearscope bool IsValidLockNum( int l )
|
||||
static bool IsValidLockNum( int l )
|
||||
{
|
||||
if ( (l < 1) || (l > 255) ) return true;
|
||||
return SWWMCachedLockInfo.IsValidLock(l);
|
||||
}
|
||||
|
||||
static clearscope Color GetLockColor( int l )
|
||||
static Color GetLockColor( int l )
|
||||
{
|
||||
return SWWMCachedLockInfo.GetLockColor(l);
|
||||
}
|
||||
|
||||
static clearscope bool IsDoorSector( Sector s, int part )
|
||||
static bool IsDoorSector( Sector s, int part )
|
||||
{
|
||||
// super-easy mode: check for boss special sectors
|
||||
if ( (level.mapname ~== "E1M8") || (level.mapname ~== "E2M8") || (level.mapname ~== "E3M8")
|
||||
|
|
@ -348,7 +348,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// the stupidest thing ever, it's called BlockingLine but it's not always blocking us
|
||||
static clearscope bool BlockingLineIsBlocking( Actor a, int blockflags = Line.ML_BLOCKEVERYTHING, Line testline = null )
|
||||
static bool BlockingLineIsBlocking( Actor a, int blockflags = Line.ML_BLOCKEVERYTHING, Line testline = null )
|
||||
{
|
||||
Line l = testline?testline:a.BlockingLine;
|
||||
// not blocked
|
||||
|
|
@ -539,7 +539,7 @@ extend Class SWWMUtility
|
|||
|
||||
// gets the hit normal vector for projectiles and hitscan
|
||||
// bNoBounce: actor didn't just bounce, meaning the fallback normal shouldn't be the inverse of velocity
|
||||
static clearscope Vector3 GetActorHitNormal( Actor a, bool bNoBounce = false )
|
||||
static Vector3 GetActorHitNormal( Actor a, bool bNoBounce = false )
|
||||
{
|
||||
Vector3 HitNormal = (0,0,0);
|
||||
F3DFloor ff;
|
||||
|
|
@ -596,7 +596,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
return HitNormal;
|
||||
}
|
||||
static clearscope Vector3 GetLineTraceHitNormal( FLineTraceData d )
|
||||
static Vector3 GetLineTraceHitNormal( FLineTraceData d )
|
||||
{
|
||||
Vector3 HitNormal = (0,0,0);
|
||||
if ( d.HitType == TRACE_HitActor )
|
||||
|
|
@ -631,7 +631,7 @@ extend Class SWWMUtility
|
|||
else HitNormal = -d.HitDir;
|
||||
return HitNormal;
|
||||
}
|
||||
static clearscope Vector3 GetLineTracerHitNormal( TraceResults r )
|
||||
static Vector3 GetLineTracerHitNormal( TraceResults r )
|
||||
{
|
||||
Vector3 HitNormal = (0,0,0);
|
||||
if ( r.HitType == TRACE_HitActor )
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Struct SWWMProjectionData
|
|||
extend Class SWWMUtility
|
||||
{
|
||||
// gutamatics caching
|
||||
static clearscope void PrepareProjData( out SWWMProjectionData d, Vector3 viewpos, double angle, double pitch, double roll, double fov )
|
||||
static void PrepareProjData( out SWWMProjectionData d, Vector3 viewpos, double angle, double pitch, double roll, double fov )
|
||||
{
|
||||
double aspect = Screen.GetAspectRatio();
|
||||
// vertical fov
|
||||
|
|
@ -33,71 +33,71 @@ extend Class SWWMUtility
|
|||
d.viewh = h;
|
||||
}
|
||||
|
||||
static clearscope Vector3 ProjectPoint( SWWMProjectionData d, Vector3 worldpos )
|
||||
static Vector3 ProjectPoint( SWWMProjectionData d, Vector3 worldpos )
|
||||
{
|
||||
return d.wtc.multiplyVector3(worldpos).asVector3();
|
||||
}
|
||||
|
||||
static clearscope Vector2 NDCToViewport( SWWMProjectionData d, Vector3 ndc )
|
||||
static Vector2 NDCToViewport( SWWMProjectionData d, Vector3 ndc )
|
||||
{
|
||||
return (d.viewx,d.viewy)+(((ndc.x+1)*d.vieww)/2,((-ndc.y+1)*d.viewh)/2);
|
||||
}
|
||||
|
||||
// checks if a point is inside the viewport
|
||||
static clearscope bool TestScreenBounds( SWWMProjectionData d, Vector2 vpos )
|
||||
static bool TestScreenBounds( SWWMProjectionData d, Vector2 vpos )
|
||||
{
|
||||
return ((vpos.x == clamp(vpos.x,d.viewx,d.viewx+d.vieww))
|
||||
&& (vpos.y == clamp(vpos.y,d.viewy,d.viewy+d.viewh)));
|
||||
}
|
||||
|
||||
// less code duplication
|
||||
static clearscope void AdjustClean_1( out double x, out double y )
|
||||
static void AdjustClean_1( out double x, out double y )
|
||||
{
|
||||
x = (x-160)*CleanXFac_1+(Screen.GetWidth()*.5);
|
||||
y = (y-100)*CleanYFac_1+(Screen.GetHeight()*.5);
|
||||
}
|
||||
static clearscope void AdjustClean_1x( out double x )
|
||||
static void AdjustClean_1x( out double x )
|
||||
{
|
||||
x = (x-160)*CleanXFac_1+(Screen.GetWidth()*.5);
|
||||
}
|
||||
static clearscope void AdjustClean_1y( out double y )
|
||||
static void AdjustClean_1y( out double y )
|
||||
{
|
||||
y = (y-100)*CleanYFac_1+(Screen.GetHeight()*.5);
|
||||
}
|
||||
|
||||
// Vector/Axis utility functions
|
||||
static clearscope Vector3 Vec3FromAngles( double angle, double pitch )
|
||||
static Vector3 Vec3FromAngles( double angle, double pitch )
|
||||
{
|
||||
return (cos(angle)*cos(pitch),sin(angle)*cos(pitch),-sin(pitch));
|
||||
}
|
||||
static clearscope Vector3 CircleOffset( Vector3 y, Vector3 z, double angle, double radius )
|
||||
static Vector3 CircleOffset( Vector3 y, Vector3 z, double angle, double radius )
|
||||
{
|
||||
return y*cos(angle)*radius+z*sin(angle)*radius;
|
||||
}
|
||||
static clearscope Vector3 ConeSpread( Vector3 x, Vector3 y, Vector3 z, double angle, double spread )
|
||||
static Vector3 ConeSpread( Vector3 x, Vector3 y, Vector3 z, double angle, double spread )
|
||||
{
|
||||
return (x+y*cos(angle)*spread+z*sin(angle)*spread).unit();
|
||||
}
|
||||
static clearscope Vector3 RotateVector3( Vector3 v, double angle )
|
||||
static Vector3 RotateVector3( Vector3 v, double angle )
|
||||
{
|
||||
Vector2 v2d = Actor.RotateVector(v.xy,angle);
|
||||
return (v2d.x,v2d.y,v.z);
|
||||
}
|
||||
static clearscope Vector3 AngleToVector3( double angle, double length = 1. )
|
||||
static Vector3 AngleToVector3( double angle, double length = 1. )
|
||||
{
|
||||
Vector2 v2d = Actor.AngleToVector(angle,length);
|
||||
return (v2d.x,v2d.y,0);
|
||||
}
|
||||
|
||||
// new GetAxes
|
||||
static clearscope Vector3, Vector3, Vector3 GetAxes( double angle, double pitch, double roll )
|
||||
static Vector3, Vector3, Vector3 GetAxes( double angle, double pitch, double roll )
|
||||
{
|
||||
Quat r = Quat.FromAngles(angle,pitch,roll);
|
||||
return r*(1,0,0), r*(0,-1,0), r*(0,0,1);
|
||||
}
|
||||
|
||||
// included here until Gutamatics updates to use native quaternions
|
||||
static clearscope double, double, double ToAngles( Quat q )
|
||||
static double, double, double ToAngles( Quat q )
|
||||
{
|
||||
double angle = 0., pitch = 0., roll = 0.;
|
||||
double stest = q.z*q.x-q.w*q.y;
|
||||
|
|
@ -125,7 +125,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// for aiming and shooting
|
||||
static clearscope Vector3 GetPlayerViewDir( Actor player )
|
||||
static Vector3 GetPlayerViewDir( Actor player )
|
||||
{
|
||||
Quat r = Quat.FromAngles(player.angle+player.viewangle,player.pitch+player.viewpitch,player.roll+player.viewroll);
|
||||
return r*(1,0,0);
|
||||
|
|
@ -139,7 +139,7 @@ extend Class SWWMUtility
|
|||
else r = Quat.FromAngles(player.angle+player.viewangle,pitch,player.roll+player.viewroll);
|
||||
return r*(1,0,0);
|
||||
}
|
||||
static clearscope Vector3, Vector3, Vector3 GetPlayerAxes( Actor player )
|
||||
static Vector3, Vector3, Vector3 GetPlayerAxes( Actor player )
|
||||
{
|
||||
Quat r = Quat.FromAngles(player.angle+player.viewangle,player.pitch+player.viewpitch,player.roll+player.viewroll);
|
||||
return r*(1,0,0), r*(0,-1,0), r*(0,0,1);
|
||||
|
|
@ -153,7 +153,7 @@ extend Class SWWMUtility
|
|||
else r = Quat.FromAngles(player.angle+player.viewangle,pitch,player.roll+player.viewroll);
|
||||
return r*(1,0,0), r*(0,-1,0), r*(0,0,1);
|
||||
}
|
||||
static clearscope Vector3 GetPlayerEye( Actor player )
|
||||
static Vector3 GetPlayerEye( Actor player )
|
||||
{
|
||||
if ( !player.viewpos )
|
||||
return player.Vec2OffsetZ(0,0,player.player.viewz);
|
||||
|
|
@ -165,7 +165,7 @@ extend Class SWWMUtility
|
|||
Quat r = Quat.FromAngles(player.angle,player.pitch,player.roll); // viewangles are not used
|
||||
return level.Vec3Offset(origin,r*player.viewpos.offset);
|
||||
}
|
||||
static clearscope Vector3 GetFireOffset( Actor player, double x, double y, double z )
|
||||
static Vector3 GetFireOffset( Actor player, double x, double y, double z )
|
||||
{
|
||||
Vector3 origin = GetPlayerEye(player);
|
||||
Quat r = Quat.FromAngles(player.angle+player.viewangle,player.pitch+player.viewpitch,player.roll+player.viewroll);
|
||||
|
|
@ -173,24 +173,24 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// thanks zscript
|
||||
static clearscope double fract( double a )
|
||||
static double fract( double a )
|
||||
{
|
||||
return a-floor(a);
|
||||
}
|
||||
|
||||
static clearscope double lerp( double a, double b, double theta )
|
||||
static double lerp( double a, double b, double theta )
|
||||
{
|
||||
return a*(1.-theta)+b*theta;
|
||||
}
|
||||
static clearscope Vector3 LerpVector3( Vector3 a, Vector3 b, double theta )
|
||||
static Vector3 LerpVector3( Vector3 a, Vector3 b, double theta )
|
||||
{
|
||||
return a*(1.-theta)+b*theta;
|
||||
}
|
||||
static clearscope Vector2 LerpVector2( Vector2 a, Vector2 b, double theta )
|
||||
static Vector2 LerpVector2( Vector2 a, Vector2 b, double theta )
|
||||
{
|
||||
return a*(1.-theta)+b*theta;
|
||||
}
|
||||
static clearscope Color LerpColor( Color a, Color b, double theta )
|
||||
static Color LerpColor( Color a, Color b, double theta )
|
||||
{
|
||||
Color c = Color(
|
||||
int(a.a*(1.-theta)+b.a*theta),
|
||||
|
|
@ -202,7 +202,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// this can probably be simplified, but I'm lazy
|
||||
static clearscope Vector3 HSVtoRGB( Vector3 hsv )
|
||||
static Vector3 HSVtoRGB( Vector3 hsv )
|
||||
{
|
||||
Vector3 p;
|
||||
p.x = abs(fract(hsv.x+1.)*6.-3.);
|
||||
|
|
@ -216,7 +216,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// "fast" exponentiation with integer exponents using loops
|
||||
static clearscope double IntPowF( double base, int exp )
|
||||
static double IntPowF( double base, int exp )
|
||||
{
|
||||
if ( exp < 0 ) return 1./IntPowF(base,-exp);
|
||||
if ( exp == 0 ) return 1.;
|
||||
|
|
@ -224,7 +224,7 @@ extend Class SWWMUtility
|
|||
for ( int i=0; i<exp; i++ ) rslt *= base;
|
||||
return rslt;
|
||||
}
|
||||
static clearscope int IntPow( int base, int exp )
|
||||
static int IntPow( int base, int exp )
|
||||
{
|
||||
if ( exp < 0 ) return int(1./IntPow(base,-exp));
|
||||
if ( exp == 0 ) return 1;
|
||||
|
|
@ -245,7 +245,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// extruded box intersection check, useful when checking things that might be hit along a path
|
||||
static clearscope bool ExtrudeIntersect( Actor a, Actor b, Vector3 range, int steps, int pad = 0 )
|
||||
static bool ExtrudeIntersect( Actor a, Actor b, Vector3 range, int steps, int pad = 0 )
|
||||
{
|
||||
if ( steps <= 0 ) return BoxIntersect(a,b,pad:pad);
|
||||
double step = 1./steps;
|
||||
|
|
@ -258,7 +258,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// box intersection check, for collision detection
|
||||
static clearscope bool BoxIntersect( Actor a, Actor b, Vector3 ofs = (0,0,0), int pad = 0 )
|
||||
static bool BoxIntersect( Actor a, Actor b, Vector3 ofs = (0,0,0), int pad = 0 )
|
||||
{
|
||||
Vector3 diff = level.Vec3Diff(level.Vec3Offset(a.pos,ofs),b.pos);
|
||||
if ( (abs(diff.x) > (a.radius+b.radius+pad)) || (abs(diff.y) > (a.radius+b.radius+pad)) ) return false;
|
||||
|
|
@ -267,7 +267,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// sphere intersection check, useful for proximity detection
|
||||
static clearscope bool SphereIntersect( Actor a, Vector3 p, double radius )
|
||||
static bool SphereIntersect( Actor a, Vector3 p, double radius )
|
||||
{
|
||||
Vector3 ap = p+level.Vec3Diff(p,a.pos); // portal-relative actor position
|
||||
Vector3 amin = ap+(-a.radius,-a.radius,0),
|
||||
|
|
@ -283,7 +283,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// hitscan exit point calculation given actor, entry point and direction
|
||||
static clearscope Vector3 TraceExit( Actor a, Vector3 p, Vector3 d )
|
||||
static Vector3 TraceExit( Actor a, Vector3 p, Vector3 d )
|
||||
{
|
||||
Vector3 ap = p+level.Vec3Diff(p,a.pos); // portal-relative actor position
|
||||
Vector3 amin = ap+(-a.radius,-a.radius,0),
|
||||
|
|
@ -299,7 +299,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// Liang-Barsky line clipping
|
||||
static clearscope bool, Vector2, Vector2 LiangBarsky( Vector2 minclip, Vector2 maxclip, Vector2 v0, Vector2 v1 )
|
||||
static bool, Vector2, Vector2 LiangBarsky( Vector2 minclip, Vector2 maxclip, Vector2 v0, Vector2 v1 )
|
||||
{
|
||||
double t0 = 0., t1 = 1.;
|
||||
double xdelta = v1.x-v0.x;
|
||||
|
|
@ -362,7 +362,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// ui-friendly version without CheckSight call
|
||||
static clearscope bool InPlayerFOVSimple( PlayerInfo p, Actor a, double maxdist = 0. )
|
||||
static bool InPlayerFOVSimple( PlayerInfo p, Actor a, double maxdist = 0. )
|
||||
{
|
||||
double vfov = p.fov*.5;
|
||||
double hfov = atan(Screen.GetAspectRatio()*tan(vfov));
|
||||
|
|
@ -378,7 +378,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
|
||||
// calculate angle, pitch and yscale of YBeam based on direction vector and length
|
||||
static clearscope double, double, double CalcYBeam( Vector3 dir, double dist )
|
||||
static double, double, double CalcYBeam( Vector3 dir, double dist )
|
||||
{
|
||||
if ( level.pixelstretch == 1. )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
extend Class SWWMUtility
|
||||
{
|
||||
// bit ugly, but it works
|
||||
static clearscope void ThousandsStr( out String s, int col = Font.CR_UNDEFINED, String colstr = "" )
|
||||
static void ThousandsStr( out String s, int col = Font.CR_UNDEFINED, String colstr = "" )
|
||||
{
|
||||
if ( (col < Font.CR_UNDEFINED) || (col >= Font.NUM_TEXT_COLORS) )
|
||||
ThrowAbortException("col parameter out of range, use colstr for non-standard font colors.");
|
||||
|
|
@ -25,7 +25,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
}
|
||||
}
|
||||
static clearscope String ThousandsNum( int n, int col = Font.CR_UNDEFINED, String colstr = "", int digits = 0 )
|
||||
static String ThousandsNum( int n, int col = Font.CR_UNDEFINED, String colstr = "", int digits = 0 )
|
||||
{
|
||||
String nstr;
|
||||
if ( digits > 0 ) nstr = String.Format("%0*d",digits,n);
|
||||
|
|
@ -34,7 +34,7 @@ extend Class SWWMUtility
|
|||
return nstr;
|
||||
}
|
||||
|
||||
static clearscope void StripColor( out String str )
|
||||
static void StripColor( out String str )
|
||||
{
|
||||
int len = str.CodePointCount();
|
||||
for ( int i=0, pos=0; i<len; i++ )
|
||||
|
|
@ -69,7 +69,7 @@ extend Class SWWMUtility
|
|||
}
|
||||
}
|
||||
|
||||
static clearscope String SuperscriptNum( int val )
|
||||
static String SuperscriptNum( int val )
|
||||
{
|
||||
// unicode is fun
|
||||
static const int digs[] = {0x2070,0x00B9,0x00B2,0x00B3,0x2074,0x2075,0x2076,0x2077,0x2078,0x2079};
|
||||
|
|
@ -83,7 +83,7 @@ extend Class SWWMUtility
|
|||
return str;
|
||||
}
|
||||
|
||||
static clearscope void ObscureText( out String str, int seed, bool alnum = false )
|
||||
static void ObscureText( out String str, int seed, bool alnum = false )
|
||||
{
|
||||
int len = str.CodePointCount();
|
||||
String newstr = "";
|
||||
|
|
@ -105,7 +105,7 @@ extend Class SWWMUtility
|
|||
str = newstr;
|
||||
}
|
||||
|
||||
static clearscope void BeautifyClassName( out String str )
|
||||
static void BeautifyClassName( out String str )
|
||||
{
|
||||
String workstr = str;
|
||||
str.Truncate(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue