-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#78 Battle revisit: unit hover fixes for build
- Loading branch information
Konstantin Krupovich
committed
Mar 15, 2023
1 parent
87020b0
commit 9ece6ac
Showing
45 changed files
with
476 additions
and
449 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
using Assets.Scripts.ECS.Data; | ||
using Assets.Scripts.Services; | ||
using Leopotam.EcsLite; | ||
using UnityEngine; | ||
|
||
namespace Assets.Scripts.ECS | ||
{ | ||
public partial class BaseEntityView<T> : IEntityView<T> | ||
where T : struct | ||
{ | ||
#region IEntityView<T> | ||
|
||
public EcsPackedEntityWithWorld? PackedEntity { get; set; } | ||
public IEcsService EcsService { get; set; } | ||
public DataLoadDelegate<T> DataLoader { get; set; } | ||
|
||
public virtual void Destroy() => | ||
GameObject.Destroy(gameObject); | ||
|
||
public virtual void UpdateData() => | ||
CurrentData = DataLoader?.Invoke(PackedEntity); | ||
|
||
#endregion | ||
|
||
#region IEntityView | ||
|
||
public void AttachChild<C>(ITransform<C> child) | ||
where C : struct | ||
{ | ||
if (PackedEntity == null || !PackedEntity.Value.Unpack(out var world, out var entity)) | ||
return; //throw new Exception("No Entity for Entity view"); | ||
|
||
ref var transformRef = ref world.GetPool<TransformRef<C>>().Add(entity); | ||
transformRef.Transform = child.Transform; | ||
} | ||
|
||
public void AttachChild<C>(IItemsContainer<C> child) | ||
where C : struct | ||
{ | ||
|
||
if (PackedEntity == null || !PackedEntity.Value.Unpack(out var world, out var entity)) | ||
return; //throw new Exception("No Entity for Entity view"); | ||
|
||
ref var transformRef = ref world.GetPool<ItemsContainerRef<C>>().Add(entity); | ||
transformRef.Container = child; | ||
} | ||
|
||
public void AttachChild<C>(IDataView<C> child) | ||
where C : struct | ||
{ | ||
if (PackedEntity == null || !PackedEntity.Value.Unpack(out var world, out var entity)) | ||
return; //throw new Exception("No Entity for Entity view"); | ||
|
||
ref var transformRef = ref world.GetPool<DataViewRef<C>>().Add(entity); | ||
transformRef.DataView = child; | ||
child.Reset(); | ||
} | ||
|
||
public void DetachChild<C>(IItemsContainer<C> child) | ||
where C : struct | ||
{ | ||
if (PackedEntity == null || !PackedEntity.Value.Unpack(out var world, out var entity)) | ||
return; //throw new Exception("No Entity for Entity view"); | ||
|
||
var pool = world.GetPool<ItemsContainerRef<C>>(); | ||
if (!pool.Has(entity)) | ||
return; | ||
|
||
ref var transformRef = ref pool.Get(entity); | ||
transformRef.Container = null; | ||
pool.Del(entity); | ||
} | ||
|
||
public void DetachChild<C>(ITransform<C> child) | ||
where C : struct | ||
{ | ||
if (PackedEntity == null || !PackedEntity.Value.Unpack(out var world, out var entity)) | ||
return; //throw new Exception("No Entity for Entity view"); | ||
|
||
var pool = world.GetPool<TransformRef<C>>(); | ||
if (!pool.Has(entity)) | ||
return; | ||
|
||
ref var transformRef = ref pool.Get(entity); | ||
transformRef.Transform = null; | ||
pool.Del(entity); | ||
} | ||
|
||
public void DetachChild<C>(IDataView<C> child) | ||
where C : struct | ||
{ | ||
if (PackedEntity == null || !PackedEntity.Value.Unpack(out var world, out var entity)) | ||
return; //throw new Exception("No Entity for Entity view"); | ||
|
||
var pool = world.GetPool<DataViewRef<C>>(); | ||
if (!pool.Has(entity)) | ||
return; | ||
|
||
ref var transformRef = ref pool.Get(entity); | ||
transformRef.DataView = null; | ||
pool.Del(entity); | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../LibraryUpdateCardSelectionSystem.cs.meta → ...ts/ECS/BaseEntityView+IEntityView.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.