about summary refs log tree commit diff stats
path: root/data/maps/daedalus/rooms/Moat.txtpb
blob: 7bdb040fcae187950ee6fa441802fb6bb5212f9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
name: "Moat"
panel_display_name: "East Area"
paintings {
  name: "CASTLE"
  path: "Components/Paintings/Group1/castle"
}
ports {
  name: "HIVE"
  display_name: "Moat Worldport"
  path: "Components/Warps/Worldports/worldport9"
  destination { x: 64 y: 1 z: 24.5 }
  rotation: 0
}
/* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#ifndef AI_H
#define AI_H

#include <list>
#include <map>
#include <string>
#include <memory>

#include "entity.h"

class AIAction {
  public:
    virtual void start(Game& game, Entity& entity) = 0;
    virtual void perform(Game& game, Entity& entity, double dt) = 0;
    virtual bool isDone() const = 0;
};

class AIActionContainer {
  public:
    void addAction(std::shared_ptr<AIAction> action);
    virtual void start(Game& game, Entity& entity);
    virtual void perform(Game& game, Entity& entity, double dt);
    virtual bool isDone() const;
  
  private:
    std::list<std::shared_ptr<AIAction>> actions;
    std::list<std::shared_ptr<AIAction>>::iterator currentAction {end(actions)};
};

class AI : public AIActionContainer {
  public:
    AI(int chance);
    
    int getChance() const;
    
  private:
    int chance;
};

class AIComponent : public Component {
  public:
    AI& emplaceAI(int chance);
    void tick(Game& game, Entity& entity, double dt);

  private:
    int maxChance = 0;
    std::list<AI> ais;
    AI* currentAI = nullptr;
};

class MoveAIAction : public AIAction {
  public:
    enum class Direction {
      Left,
      Right,
      Up,
      Down
    };
    
    MoveAIAction(Direction dir, int len, int speed);
    
    void start(Game& game, Entity& entity);
    void perform(Game& game, Entity& entity, double dt);
    bool isDone() const;
    
  private:
    Direction dir;
    int len;
    int speed;
    double remaining;
};

#endif /* end of include guard: AI_H */