Announcement

Collapse
No announcement yet.

totally-rediculous-obvious-to-answer question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    totally-rediculous-obvious-to-answer question

    Ok, I've been exposed to OO programming for a while but only in the sense of staring at code trying to understand what's going on. My programming experience is more inline with the old C language.

    This whole Class thing is starting to click in my head now thanks to Unreal and the mega amounts of information about darned near every aspect of the engine.

    So, while cruising through some of the actor classes inside the editor, I've noticed more than a few subclasses that contain only the 'class NewSubClass extends ParentClass;' line. I know now that this new subclass contains all the properties of the parent class. Now here is my question concerning these specific 'one-liner' subclasses: Are these sub classes only made subclasses because their default properties differ from the default properties of it's parent class?

    To clarify by example:
    Code:
    class redLight extends Light;
    
    defaultproperties
    {
    LightBrightness=255
    LightHue=255
    LightSaturation=127
    }
    Of course you'd not have to add the default properties inside the code because you can change those via the 'Default Properties' dialog you get when you right click on the class list in the editor.

    I know this sounds so obvious but confirmation will definitely aid my understanding to the point where I might actually be able to, finally, code something.

    Perhaps there are other people that lurk these boards that are on the verge of understanding, like myself, and just need a switched turned on.

    Thank ya

    #2
    just think of the defaultproperties as a constructor.

    Because in UScript you dont have constructor methods like this:
    new Weapon(Model mod, float xy, int brightness).

    Lets say you wanted to make 5 different pawns but the only difference between these 5 pawns is the model and skin then all you have to do is subclass your pawn class and change the model and skin in the defaultproperties.

    also you can access the defaultproperties with default eg.
    weapon.default.damage;

    so dont be setting the values of stuff in the function postbeginplay() or nething like that as i once did, :bulb:

    Comment


      #3
      Code:
      class redLight extends Light;
      Thats all that you need to define a new subclass.
      The defaulproperties are there just to change some properties.

      I think you got this idea because of some Epic Classes like UT2K4TabPanel that is defiend bellow.

      Code:
      class UT2K4TabPanel extends GUITabPanel
      	abstract;
      
      DefaultProperties
      {
      
      }
      The Epic guys do this as a "place holder". So they can refer all possible TabPanels as being a UT2K4TabPanel. If they extend all the UT2K4Tab's through GUITabPane they couldn't make a easy to reference thing.

      Comment


        #4
        Originally posted by mkhaos7
        Code:
        class redLight extends Light;
        Thats all that you need to define a new subclass.
        The defaulproperties are there just to change some properties.

        I think you got this idea because of some Epic Classes like UT2K4TabPanel that is defiend bellow.

        Code:
        class UT2K4TabPanel extends GUITabPanel
        	abstract;
        
        DefaultProperties
        {
        
        }
        The Epic guys do this as a "place holder". So they can refer all possible TabPanels as being a UT2K4TabPanel. If they extend all the UT2K4Tab's through GUITabPane they couldn't make a easy to reference thing.
        Yes, I can see doing it as a manner of keeping such things organized within the class structure but take the spotlight subclass:
        Code:
        class spotLight extends Light;
        That's all the code to that script yet inside the default properties dialog, under advanced it's bDirectional property is true whereas it's parents bDirectional is false. I'm sure there's more of the properties that are different but that is one that's obvious. There isn't any other code to that subclass. I showed it the way I did to show that you can do it both ways.

        Comment


          #5
          Code:
          class Spotlight extends Light;
          
          defaultproperties
          {
               bDirectional=True
               LightEffect=LE_Spotlight
          }

          This is my Spotlight class
          I think you have some thing missing on your side
          Maybe when you exported the scripts from the .u's'. Try getting the ziped sources from Epic, they are available at BU (http://download.beyondunreal.com/fil...cripts3236.zip)

          Comment


            #6
            Whats happening is he's looking at them in UED which often does not list default properties in the code, you have to use the right click menu to alter them, and of course not all properties will show up in an actors property dialog either

            Comment


              #7
              What I think you mean is, why have a subclass which only changes a few details in the default properties when you can easily change that in the editor. The thing is, if you place a light, and change a few properties to make it a red light, then you have a red light. But if you want to place another one somewhere down the line, you need to make a light, and make it red again. Instead, you make the class, and put as many red lights as you want without editing the default properties. So, you use the same everything, except for a property or two or more, but it allows you to easily add this new red light.

              Comment


                #8
                Well the reason here is just for the sake of simplicity, these are defaultproperties that are thaught to be 'often used' so they are put in as classes to speed things up. It also helps organisisation, for example instead of lights 0 - 500 mabye you have only 400 lights and 100 spotlights so it's easier to find and identify them.

                Comment


                  #9
                  Thanks guys, that's pretty much where my line of thinking was at but just needed someone to clarify the obvious.

                  As for not seeing the defaultproperties in the code, Hsoolian was correct, I was viewing them via UnrealEd but on the other hand, Mkhaos pointed me to the fact that the code was not all there. I went into WOTgreal and sure enough the spotlight code wasn't the same as what was seen in UnrealEd. Thanks.

                  I did manage to compile a new light subclass for testing, so far so good.

                  Comment

                  Working...
                  X