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

IGEffectsSystem.EventResponse


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
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
class EventResponse extends Core.Object
    within EffectsSubsystem
    PerObjectConfig
    native;

struct native SpecificationStruct
{
    var Name    SpecificationType;
    var class   SpecificationClass;
};

var config Name                 Event;
var config Name                 SourceClassName;
var class<Actor>                SourceClass;
var config Name                 TargetClassName;
var config Name                 StaticMesh;     //if not None, this is used to filter for Actors with this StaticMesh
var config Name                 Tag;            //if not None, this is used to filter for Actors with this Tag
var config array<int>           Chance;
var config array<SpecificationStruct>          Specification;
var array<EffectSpecification>  SpecificationReference;
var config array<name>          Context;

var private bool initDone;
var private int sum;

simulated function Init()
{
    local int i;

    //init should happen only once
    assert(!initDone);
    if (initDone)
        return;

    if (Chance.length + Specification.length == 0)
    {
        warn("The "$class.name$" named '"$name$"' has no Specification.  This will not cause a problem, but it should be corrected.");
        return;     //no specifications... sum is also zero
    }

    if (Chance.length == 0)
        Chance[0] = 1;

    assertWithDescription(Chance.length == Specification.length,
        "EventResponse "$name$": The number of Chance(s) and Specifications(s) should match, but they don't (except if there's just one Specification, in which case, you may omit the Chance).");

    //set sum
    for (i=0; i<Chance.length; i++)
        sum += Chance[i];

    initDone = true;
}

simulated event EffectSpecification GetSpecification()
{
    local int subSum;
    local int point;
    local int i;

    if (!initDone) Init();

    if (Chance.length + Specification.length == 0)
		return None;

    //select a specification using the random weights specified in the response

    point = rand(sum);

    for (i=0; i<Chance.length; i++)
    {
        subSum += Chance[i];
        if (subSum >= point)
            break;
    }
    assert(i<Chance.length);

    if (SpecificationReference[i] == None)
        assertWithDescription(false,
            "[tcohen] The "$class.name
            $" named "$name
            $" was called to GetSpecification(), but the SpecificationReference (at index "$i
            $") is None.  The Event Response's SourceClass ("$SourceClassName
            $") may need to be added to the PreloadActorClass list in EffectsSystem.ini.  "
            $"Effects will not be played on "$SourceClassName$" instances.  "
            $"(This probably means that the SourceClass was dynamically loaded after the Effects System was initialized, and had not been previously loaded.  "
            $"Therefore the Effects System ignored the Event Response and didn't create any Effect Specifications for it.)");

    return SpecificationReference[i];
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ne 5.9.2004 16:02:12.000 - Creation time: st 23.5.2018 00:10:43.336 - Created with UnCodeX