Skip to content

Commit

Permalink
feat: some unity game object interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
tolstenko committed Nov 22, 2022
1 parent 3aef39a commit f411699
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 0 deletions.
5 changes: 5 additions & 0 deletions engine/GameObject.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// Created by atolstenko on 11/22/2022.
//

#include "GameObject.h"
8 changes: 8 additions & 0 deletions engine/GameObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef MOBAGEN_ENGINE_GAMEOBJECT_H_
#define MOBAGEN_ENGINE_GAMEOBJECT_H_

class GameObject {

};

#endif //MOBAGEN_ENGINE_GAMEOBJECT_H_
22 changes: 22 additions & 0 deletions engine/HideFlags.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// ref https://docs.unity3d.com/ScriptReference/HideFlags.html
// If you set hide flags to DontSaveInEditor, DontSaveInBuild or HideInHierarchy, this internally removes the object from the Unity Scene, as well as from its current physics scene (this includes both 2D and 3D physics scenes). This also causes the object to trigger its OnDisable and OnEnable calls.
enum class HideFlags{
// A normal, visible object. This is the default.
None=0,
// The object will not appear in the hierarchy.
HideInHierarchy=1,
// It is not possible to view it in the inspector.
HideInInspector=2,
// The object will not be saved to the Scene in the editor.
DontSaveInEditor=4,
// The object is not editable in the Inspector.
NotEditable=8,
// The object will not be saved when building a player.
DontSaveInBuild=16,
// The object will not be unloaded by Resources.UnloadUnusedAssets.
DontUnloadUnusedAsset = 32,
// The object will not be saved to the Scene. It will not be destroyed when a new Scene is loaded. It is a shortcut for HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor | HideFlags.DontUnloadUnusedAsset.
DontSave = 52,
// The GameObject is not shown in the Hierarchy, not saved to Scenes, and not unloaded by Resources.UnloadUnusedAssets.
HideAndDontSave=128
};
5 changes: 5 additions & 0 deletions engine/JobManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "JobManager.h"
bool JobManager::IsRunningInMainThread() {
// todo: implement
return true;
}
9 changes: 9 additions & 0 deletions engine/JobManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef MOBAGEN_ENGINE_JOBMANAGER_H_
#define MOBAGEN_ENGINE_JOBMANAGER_H_

class JobManager {
public:
static bool IsRunningInMainThread();
};

#endif //MOBAGEN_ENGINE_JOBMANAGER_H_
8 changes: 8 additions & 0 deletions engine/Object.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "Object.h"
#include <typeinfo>

template<class T>
std::vector<T> Object::FindObjectsOfType() {
auto typehash = typeid(T).hash_code();
return std::vector<T>();
}
39 changes: 39 additions & 0 deletions engine/Object.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef MOBAGEN_ENGINE_OBJECT_H_
#define MOBAGEN_ENGINE_OBJECT_H_

#include <string>
#include <vector>

class Object {
public:
const std::string& name() const { return _name; }
void name(const std::string& name) { _name = name; }
private:
std::string _name;

public:
const std::uint64_t& instanceId() const { return _instanceId; }
private:
int _instanceId; // todo: initialize this properly

// todo: equals comparison and attribution via copy or move ?
public:
Object(); // todo: implement copy and set internal variables

public:
// todo: mark to be deleted next frame
static void Destroy(const Object& object);

public:
template<class T>
static std::vector<T> FindObjectsOfType();

public:
static void DontDestroyOnLoad(const Object& object);

public:
std::string ToString();
};


#endif //MOBAGEN_ENGINE_OBJECT_H_
5 changes: 5 additions & 0 deletions engine/Scene.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// Created by atolstenko on 11/22/2022.
//

#include "Scene.h"
8 changes: 8 additions & 0 deletions engine/Scene.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef MOBAGEN_ENGINE_SCENE_H_
#define MOBAGEN_ENGINE_SCENE_H_

class Scene {

};

#endif //MOBAGEN_ENGINE_SCENE_H_
5 changes: 5 additions & 0 deletions engine/Utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// Created by atolstenko on 11/22/2022.
//

#include "Utils.h"
7 changes: 7 additions & 0 deletions engine/Utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef MOBAGEN_ENGINE_UTILS_H_
#define MOBAGEN_ENGINE_UTILS_H_

class Utils {
};

#endif //MOBAGEN_ENGINE_UTILS_H_

0 comments on commit f411699

Please sign in to comment.