Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanZhu committed May 22, 2019
1 parent ec361fc commit 40a4860
Show file tree
Hide file tree
Showing 436 changed files with 25,043 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
Assets/AssetStoreTools*

# Visual Studio cache directory
.vs/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.opendb

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta

# Unity3D Generated File On Crash Reports
sysinfo.txt

# Builds
*.apk
*.unitypackage
.idea/
15 changes: 15 additions & 0 deletions Assets/CodegenExecutor.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 16d40f4c171d6f647a7e84fcaaf26327, type: 3}
m_Name: CodegenExecutor
m_EditorClassIdentifier:
OutputPath: Sources/Generated
8 changes: 8 additions & 0 deletions Assets/CodegenExecutor.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Generated.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions Assets/Generated/Contexts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Entitas.CodeGeneration.Plugins.ContextsGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public partial class Contexts : Entitas.IContexts {

public static Contexts sharedInstance {
get {
if (_sharedInstance == null) {
_sharedInstance = new Contexts();
}

return _sharedInstance;
}
set { _sharedInstance = value; }
}

static Contexts _sharedInstance;

public GameContext game { get; set; }

public Entitas.IContext[] allContexts { get { return new Entitas.IContext [] { game }; } }

public Contexts() {
game = new GameContext();

var postConstructors = System.Linq.Enumerable.Where(
GetType().GetMethods(),
method => System.Attribute.IsDefined(method, typeof(Entitas.CodeGeneration.Attributes.PostConstructorAttribute))
);

foreach (var postConstructor in postConstructors) {
postConstructor.Invoke(this, null);
}
}

public void Reset() {
var contexts = allContexts;
for (int i = 0; i < contexts.Length; i++) {
contexts[i].Reset();
}
}
}

//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Entitas.CodeGeneration.Plugins.EntityIndexGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public partial class Contexts {

public const string Connection = "Connection";
public const string ControlledBy = "ControlledBy";
public const string Id = "Id";

[Entitas.CodeGeneration.Attributes.PostConstructor]
public void InitializeEntityIndices() {
game.AddEntityIndex(new Entitas.PrimaryEntityIndex<GameEntity, ushort>(
Connection,
game.GetGroup(GameMatcher.Connection),
(e, c) => ((Connection)c).Id));

game.AddEntityIndex(new Entitas.PrimaryEntityIndex<GameEntity, ushort>(
ControlledBy,
game.GetGroup(GameMatcher.ControlledBy),
(e, c) => ((ControlledBy)c).Value));

game.AddEntityIndex(new Entitas.PrimaryEntityIndex<GameEntity, ushort>(
Id,
game.GetGroup(GameMatcher.Id),
(e, c) => ((IdComponent)c).Value));
}
}

public static class ContextsExtensions {

public static GameEntity GetEntityWithConnection(this GameContext context, ushort Id) {
return ((Entitas.PrimaryEntityIndex<GameEntity, ushort>)context.GetEntityIndex(Contexts.Connection)).GetEntity(Id);
}

public static GameEntity GetEntityWithControlledBy(this GameContext context, ushort Value) {
return ((Entitas.PrimaryEntityIndex<GameEntity, ushort>)context.GetEntityIndex(Contexts.ControlledBy)).GetEntity(Value);
}

public static GameEntity GetEntityWithId(this GameContext context, ushort Value) {
return ((Entitas.PrimaryEntityIndex<GameEntity, ushort>)context.GetEntityIndex(Contexts.Id)).GetEntity(Value);
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Entitas.VisualDebugging.CodeGeneration.Plugins.ContextObserverGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public partial class Contexts {

#if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR)

[Entitas.CodeGeneration.Attributes.PostConstructor]
public void InitializeContextObservers() {
try {
CreateContextObserver(game);
} catch(System.Exception) {
}
}

public void CreateContextObserver(Entitas.IContext context) {
if (UnityEngine.Application.isPlaying) {
var observer = new Entitas.VisualDebugging.Unity.ContextObserver(context);
UnityEngine.Object.DontDestroyOnLoad(observer.gameObject);
}
}

#endif
}
11 changes: 11 additions & 0 deletions Assets/Generated/Contexts.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/Generated/Events.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/Generated/Events/Components.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Assets/Generated/Events/Components/DestroyedListenerComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Entitas.CodeGeneration.Plugins.EventListenerComponentGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
[Entitas.CodeGeneration.Attributes.DontGenerate(false)]
public sealed class DestroyedListenerComponent : Entitas.IComponent {
public System.Collections.Generic.List<IDestroyedListener> value;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Assets/Generated/Events/GameEventSystems.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Entitas.CodeGeneration.Plugins.EventSystemsGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public sealed class GameEventSystems : Feature {

public GameEventSystems(Contexts contexts) {
Add(new DestroyedEventSystem(contexts)); // priority: 0
}
}
3 changes: 3 additions & 0 deletions Assets/Generated/Events/GameEventSystems.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/Generated/Events/Interfaces.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Assets/Generated/Events/Interfaces/IDestroyedListener.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Entitas.CodeGeneration.Plugins.EventListenertInterfaceGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public interface IDestroyedListener {
void OnDestroyed(GameEntity entity);
}
3 changes: 3 additions & 0 deletions Assets/Generated/Events/Interfaces/IDestroyedListener.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/Generated/Events/Systems.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions Assets/Generated/Events/Systems/DestroyedEventSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Entitas.CodeGeneration.Plugins.EventSystemGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public sealed class DestroyedEventSystem : Entitas.ReactiveSystem<GameEntity> {

readonly System.Collections.Generic.List<IDestroyedListener> _listenerBuffer;

public DestroyedEventSystem(Contexts contexts) : base(contexts.game) {
_listenerBuffer = new System.Collections.Generic.List<IDestroyedListener>();
}

protected override Entitas.ICollector<GameEntity> GetTrigger(Entitas.IContext<GameEntity> context) {
return Entitas.CollectorContextExtension.CreateCollector(
context, Entitas.TriggerOnEventMatcherExtension.Added(GameMatcher.Destroyed)
);
}

protected override bool Filter(GameEntity entity) {
return entity.isDestroyed && entity.hasDestroyedListener;
}

protected override void Execute(System.Collections.Generic.List<GameEntity> entities) {
foreach (var e in entities) {

_listenerBuffer.Clear();
_listenerBuffer.AddRange(e.destroyedListener.value);
foreach (var listener in _listenerBuffer) {
listener.OnDestroyed(e);
}
}
}
}
3 changes: 3 additions & 0 deletions Assets/Generated/Events/Systems/DestroyedEventSystem.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 40a4860

Please sign in to comment.