Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/interfaces/StarToolUserItem.hpp
blob: 34ecfba3e1da3a42c0e9b61c10020fbde56b6466 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include "StarToolUserEntity.hpp"
#include "StarPhysicsEntity.hpp"

namespace Star {

STAR_EXCEPTION(ToolUserItemException, StarException);

STAR_CLASS(ToolUserItem);

// FIXME: You know what another name for an item that a tool user uses is?  A
// Tool.  Three words when one will do, rename.
class ToolUserItem {
public:
  ToolUserItem();
  virtual ~ToolUserItem() = default;

  // Owner must be initialized when a ToolUserItem is initialized and
  // uninitialized before the owner is uninitialized.
  virtual void init(ToolUserEntity* owner, ToolHand hand);
  virtual void uninit();

  // Default implementation does nothing
  virtual void update(float dt, FireMode fireMode, bool shifting, HashSet<MoveControlType> const& moves);

  // Default implementations return empty list
  virtual List<DamageSource> damageSources() const;
  virtual List<PolyF> shieldPolys() const;
  virtual List<PhysicsForceRegion> forceRegions() const;

  bool initialized() const;

  // owner, entityMode, hand, and world throw ToolUserException if
  // initialized() is false
  ToolUserEntity* owner() const;
  EntityMode entityMode() const;
  ToolHand hand() const;
  World* world() const;

private:
  ToolUserEntity* m_owner;
  Maybe<ToolHand> m_hand;
};

}