~vladh/peony

peony/src/entities.cpp -rw-r--r-- 640 bytes
7fc9922bVlad-Stefan Harbuz changes shaders namespace into class a month ago
                                                                                
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
/*
  Peony Game Engine
  Copyright (C) 2020 Vlad-Stefan Harbuz <vlad@vladh.net>
  All rights reserved.
*/

#include "entities.hpp"


EntityHandle entities::make_handle(EntitySet *entity_set) {
  // NOTE: 0 is an invalid handle.
  if (entity_set->next_handle == 0) {
    entity_set->next_handle++;
  }
  return entity_set->next_handle++;
}


Entity* entities::add_entity_to_set(EntitySet *entity_set, const char *debug_name) {
  EntityHandle new_handle = make_handle(entity_set);
  Entity *new_entity = entity_set->entities[new_handle];
  new_entity->handle = new_handle;
  strcpy(new_entity->debug_name, debug_name);
  return new_entity;
}