Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync #1

Merged
merged 25 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<p align="center">
<img src="http://pixeye.games/images/logo_actors-1024.png" width="512" height="512" alt="Actors">
</p>

[![Twitter Follow](https://img.shields.io/twitter/follow/PixeyeHQ?color=blue&label=Follow%20on%20Twitter&logo=%20&logoColor=%20&style=flat-square)](https://twitter.com/PixeyeHQ)
[![Discord](https://img.shields.io/discord/320945300892286996.svg?label=Discord)](http://discord.pixeye.games)
[![license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/dimmpixeye/Actors-Unity3d-Framework/blob/master/LICENSE)
Expand Down Expand Up @@ -840,7 +836,7 @@ openupm add com.pixeye.ecs
#### Manual Installation
- Download latest package from the [Release](https://github.com/PixeyeHQ/actors.unity/releases) section
- Import ```actors.unitypackage``` to your Unity Project
- Optionally import ```actors-template.unitypackage``` from the Install folder of Actors

#### How To Update
<details> <summary>
Press Tools->Actors->Update Actors to get a new update.
Expand All @@ -857,6 +853,7 @@ This is a list of known projects that uses Actors by far. If you want to add a p
#### Snake Demo | [Github link](https://github.com/PixeyeHQ/actors.unity.snake)
#### Rocket Science Snake Demo | [Github link](https://github.com/Gavolot/Actors3RocketScienceSnakeGame)
#### Actors Benchmark | [Github link](https://github.com/PixeyeHQ/actors.unity.benchmark)
#### 2D Roguelike Actors | [Github link](https://github.com/Allexeee/2D-Roguelike-Actors)

## 📖 About <a name="About"></a>
### 💬 How to help
Expand Down
20 changes: 11 additions & 9 deletions Runtime/Core/ImplActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public Actor Create(string prefabID, Vector3 position = default, bool pooled = f
// actor.isPooled = pooled;

actor.BootstrapCreated(layer);
actor.entity.managed.isPooled = pooled;
return actor;
}

Expand All @@ -39,8 +40,8 @@ public Actor Create(string prefabID, Transform parent, Vector3 position = defaul
? layer.Obj.Create(Pool.Entities, prefabID, parent, position)
: layer.Obj.Create(prefabID, parent, position);
var actor = transform.GetActor();
// actor.isPooled = pooled;
actor.BootstrapCreated(layer);
actor.entity.managed.isPooled = pooled;
return actor;
}

Expand All @@ -49,9 +50,9 @@ public Actor Create(string prefabID, ModelComposer model, Vector3 position = def
{
var transform = pooled ? layer.Obj.Create(Pool.Entities, prefabID, position) : layer.Obj.Create(prefabID, position);
var actor = transform.GetActor();
// actor.isPooled = pooled;

actor.BootstrapCreated(layer, model);
actor.entity.managed.isPooled = pooled;
return actor;
}

Expand All @@ -63,9 +64,9 @@ public Actor Create(string prefabID, Transform parent, ModelComposer model, Vect
? layer.Obj.Create(Pool.Entities, prefabID, parent, position)
: layer.Obj.Create(prefabID, parent, position);
var actor = transform.GetActor();
//actor.isPooled = pooled;

actor.BootstrapCreated(layer, model);
actor.entity.managed.isPooled = pooled;
return actor;
}

Expand All @@ -78,9 +79,9 @@ public Actor Create(GameObject prefab, Vector3 position = default, bool pooled =
{
var transform = pooled ? layer.Obj.Create(Pool.Entities, prefab, position) : layer.Obj.Create(prefab, position);
var actor = transform.GetActor();
//actor.isPooled = pooled;


actor.BootstrapCreated(layer);
actor.entity.managed.isPooled = pooled;
return actor;
}

Expand All @@ -90,9 +91,9 @@ public Actor Create(GameObject prefab, Transform parent, Vector3 position = defa
var transform =
pooled ? layer.Obj.Create(Pool.Entities, prefab, parent, position) : layer.Obj.Create(prefab, parent, position);
var actor = transform.GetActor();
//actor.isPooled = pooled;

actor.BootstrapCreated(layer);
actor.entity.managed.isPooled = pooled;
return actor;
}

Expand All @@ -101,9 +102,10 @@ public Actor Create(GameObject prefab, ModelComposer model, Vector3 position = d
{
var transform = pooled ? layer.Obj.Create(Pool.Entities, prefab, position) : layer.Obj.Create(prefab, position);
var actor = transform.GetActor();
//actor.isPooled = pooled;


actor.BootstrapCreated(layer, model);
actor.entity.managed.isPooled = pooled;
return actor;
}

Expand All @@ -114,10 +116,10 @@ public Actor Create(GameObject prefab, Transform parent, ModelComposer model, Ve
var transform =
pooled ? layer.Obj.Create(Pool.Entities, prefab, parent, position) : layer.Obj.Create(prefab, parent, position);
var actor = transform.GetActor();
//actor.isPooled = pooled;

actor.BootstrapCreated(layer, model);
actor.entity.managed.isPooled = pooled;
return actor;
}
}
}
}
5 changes: 5 additions & 0 deletions Runtime/LibEcs/ent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public ref readonly Transform transform
get => ref ProcessorEcs.EntitiesManaged[id].transform;
}

public void SetTransform(Transform tr)
{
ProcessorEcs.EntitiesManaged[id].transform = tr;
}

public Layer layer
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
29 changes: 21 additions & 8 deletions Runtime/LibProcessors/ProcessorEcs.Handle.Operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,9 @@ internal void Execute()
eMeta->AddGroup(group.id);
}
}

eMeta->isDirty = false;
}

// Pixeye: Even if no components were added on initilization clean entity dirty flag. Fixes #78
eMeta->isDirty = false;
operation.entity.RenameGameobject();
}
break;
Expand All @@ -184,17 +183,31 @@ internal void Execute()
for (var l = 0; l < groups.length; l++)
{
var group = groups.Elements[l];

if (group.composition.Check(eMeta, ref eManaged))

var inGroup = eMeta->AlreadyInGroup(group.id);
var canBeAdded = group.composition.Check(eMeta, ref eManaged);

if (inGroup == false)
{
if (!canBeAdded) continue;
group.Insert(operation.entity);
eMeta->AddGroup(group.id);
}
else
else if (!canBeAdded)
{
if (group.TryRemove(entityID))
eMeta->RemoveGroup(group.id);
group.RemoveFast(entityID);
eMeta->RemoveGroup(group.id);
}
// if (group.composition.Check(eMeta, ref eManaged))
// {
// group.Insert(operation.entity);
// eMeta->AddGroup(group.id);
// }
// else
// {
// if (group.TryRemove(entityID))
// eMeta->RemoveGroup(group.id);
// }
}

operation.entity.RenameGameobject();
Expand Down
2 changes: 2 additions & 0 deletions Runtime/LibProcessors/ProcessorEcs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public void Dispose()
managed.signature[ii] = 0;
}

managed.childs.length = 0;

meta->isAlive = false;
meta->componentsAmount = 0;
meta->groupsAmount = 0;
Expand Down
1 change: 1 addition & 0 deletions Runtime/Utils/Buffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public void Bootstrap(Layer layer)
int queueIndex;

public ref T this[int index] => ref elements[pointers[index]];
public ref T GetByPointer(int pointer) => ref elements[pointer];

public Buffer(int size)
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"displayName": "Actors",
"description": "🚀 Actors is a framework empowering developers to make better games faster on Unity.",
"unity": "2019.4",
"version": "2020.6.4",
"version": "2021.4.22",
"keywords": [
"ecs",
"pixeye",
Expand Down