Browse Source

Neue Aktion: KONSTANT_GEGENSTAND_TYP

Kolja Strohm 4 years ago
parent
commit
e8611e4a1d

+ 12 - 0
StickmanWorldOnline/Aktionen.cpp

@@ -99,6 +99,18 @@ void KonstantInteger::run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMem
 }
 
 
+KonstantGegenstandTyp::KonstantGegenstandTyp( GegenstandTyp val )
+    : Aktion( KONSTANT_GEGENSTAND_TYP, new RCArray< Aktion >() )
+{
+    this->value = val;
+}
+
+void KonstantGegenstandTyp::run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
+{
+    setReturn( new GegenstandTypVar( value ) );
+}
+
+
 KonstantTaste::KonstantTaste( unsigned char val )
     : Aktion( KONSTANT_TASTE, new RCArray< Aktion >() )
 {

+ 12 - 1
StickmanWorldOnline/Aktionen.h

@@ -207,7 +207,8 @@ enum AktionTyp
     TEXT_AUS_FLOAT,
     FLOAT_ZUFALL,
     INTEGER_AUS_FLOAT,
-    KONSTANT_TASTE
+    KONSTANT_TASTE,
+    KONSTANT_GEGENSTAND_TYP
 };
 
 enum Operator
@@ -278,6 +279,16 @@ public:
     void run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount ) override;
 };
 
+class KonstantGegenstandTyp : public Aktion
+{
+private:
+    GegenstandTyp value;
+
+public:
+    KonstantGegenstandTyp( GegenstandTyp val );
+    void run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount ) override;
+};
+
 class KonstantTaste : public Aktion
 {
 private:

+ 0 - 23
StickmanWorldOnline/Gegenstand.h

@@ -3,29 +3,6 @@
 #include "GameObject.h"
 #include "Resource.h"
 
-enum GegenstandTyp
-{
-    KEIN_GEGENSTAND,
-    PFEIL,
-    LEBEN,
-    SCHILD,
-    SCHUH,
-    GEIST,
-    KUGEL,
-    ROLLE,
-    STURM,
-    DRACHENAUGE,
-    FEUERBALL,
-    ENTERHAKEN,
-    MINE,
-    RWEISHEIT,
-    RSTRENGTH,
-    RBOSHEIT,
-    RLEBEN,
-    RTEMPO,
-    ITEMANZAHL
-};
-
 Resource *zResourceOfItem( GegenstandTyp typ, ResourceRegistry *zResources );
 
 bool consumable( GegenstandTyp typ );

+ 7 - 0
StickmanWorldOnline/Reader.cpp

@@ -366,6 +366,13 @@ Aktion *MapReader::readAktion( Datei &dat )
         dat.lese( (char *)& i, 4 );
         return new KonstantInteger( i );
     }
+    case KONSTANT_GEGENSTAND_TYP:
+    {
+        params->release();
+        int i;
+        dat.lese( (char *)& i, 4 );
+        return new KonstantGegenstandTyp( (GegenstandTyp)i );
+    }
     case KONSTANT_TASTE:
     {
         params->release();

+ 23 - 0
StickmanWorldOnline/Variablen.h

@@ -61,6 +61,29 @@ Richtung invert( Richtung r );
 
 Richtung getRichtungFromString( Text str );
 
+enum GegenstandTyp
+{
+    KEIN_GEGENSTAND,
+    PFEIL,
+    LEBEN,
+    SCHILD,
+    SCHUH,
+    GEIST,
+    KUGEL,
+    ROLLE,
+    STURM,
+    DRACHENAUGE,
+    FEUERBALL,
+    ENTERHAKEN,
+    MINE,
+    RWEISHEIT,
+    RSTRENGTH,
+    RBOSHEIT,
+    RLEBEN,
+    RTEMPO,
+    ITEMANZAHL
+};
+
 bool operator==( VariableTyp a, VariableTyp b );
 bool operator!=( VariableTyp a, VariableTyp b );