Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

USARBot.GasSensor


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
// ===============================================================
// USARBot.GasSensor
// ===============================================================

class GasSensor extends sensor config(USARBot);

var config String GasType;
var config Range ValidRange; // the detecting range in percent
var config float Resoluation; // in percent
var array<GasSource> gasSources;

function Init(String SName, Actor parent, vector position, rotator direction, KVehicle platform, name mount)
{
    local int i, j;
    local AmbientSource s;
    
    Super.Init(SName,parent,position,direction,platform,mount);
    
    j = 0;
    for (i=0; i<USARDeathMatch(Level.Game).Sources.length; i++) {
        s = USARDeathMatch(Level.Game).Sources[i];
        if (s.IsA('GasSource') && s.isType(GasType)) {
            gasSources[i] = GasSource(s);
            j += 1;
        }
    }
}

function ConvertParam(USARConverter converter)
{
}

function String GetData()
{
    local string Outstring;
    local int i;
    local float dens;
    
    dens = 0;
    for (i = 0; i < gasSources.length; i++) 
        dens = Max(dens,gasSources[i].getDensity(Location));
    
    dens += RandRange(-Noise,Noise)*dens;
    dens = int(InterpCurveEval(OutputCurve, dens)/Resoluation)*Resoluation;

    if (dens<ValidRange.Min) 
        dens = ValidRange.Min;
    else if (dens>ValidRange.Max) 
        dens = ValidRange.Max;
            
    Outstring = "{Name "$ItemName$"} {Gas "$GasType$"} {Density "$dens$"}";

    return Outstring;
}

function String GetConfData()
{
    local string outstring;
    outstring = Super.GetConfData();
    outstring = outstring @ "{Gas " $ GasType$"}" @
                "{Resoluation " $ Resoluation $ "}" @
                "{Range " $ ValidRange.Min $ "," $ ValidRange.Max $ "}";
    return outstring;
}

defaultproperties
{
     ItemType="GasSensor"
     // Detecting range 0~100%
     ValidRange=(Min=0,Max=100)
     GasType="CO2"
     OutputCurve=(Points=((InVal=0,OutVal=0),(InVal=100,OutVal=100)))
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fr 13.10.2006 20:44:20.000 - Creation time: Mo 16.4.2007 11:20:47.625 - Created with UnCodeX