Browse Source

Argghg adding the EGID in the DispatchOnSet and DispatchOnChange was a mistake. Revert it.

Avoid to remove and create dictionaries more than needed
tags/Rel25b
sebas77 6 years ago
parent
commit
35948a5883
7 changed files with 18 additions and 25 deletions
  1. +1
    -1
      Svelto.Common
  2. +2
    -1
      Svelto.ECS/DataStructures/TypeSafeDictionary.cs
  3. +0
    -3
      Svelto.ECS/Dispatcher/DispatchOnChange.cs
  4. +11
    -16
      Svelto.ECS/Dispatcher/DispatchOnSet.cs
  5. +0
    -2
      Svelto.ECS/EGID.cs
  6. +3
    -1
      Svelto.ECS/EnginesRoot.Entities.cs
  7. +1
    -1
      Svelto.ECS/EnginesRoot.Submission.cs

+ 1
- 1
Svelto.Common

@@ -1 +1 @@
Subproject commit 4f7d4d96407f3ce390a23b930ba235a2447729ec
Subproject commit 70c3fa30662f89cd1b023802f114dd917e156d2e

+ 2
- 1
Svelto.ECS/DataStructures/TypeSafeDictionary.cs View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Svelto.DataStructures;
using Svelto.DataStructures.Experimental;
@@ -32,6 +32,7 @@ namespace Svelto.ECS.Internal
bool Remove(int idGid);
int Count { get; }
void Trim();
}

class TypeSafeDictionary<TValue> : FasterDictionary<int, TValue>, ITypeSafeDictionary where TValue : IEntityStruct


+ 0
- 3
Svelto.ECS/Dispatcher/DispatchOnChange.cs View File

@@ -7,9 +7,6 @@ namespace Svelto.ECS
public DispatchOnChange(int senderID) : base(senderID)
{ }
public DispatchOnChange(EGID senderID) : base(senderID)
{ }

public DispatchOnChange() {}

public new T value


+ 11
- 16
Svelto.ECS/Dispatcher/DispatchOnSet.cs View File

@@ -4,22 +4,17 @@ namespace Svelto.ECS
{
public class DispatchOnSet<T> where T:struct
{
public DispatchOnSet(int senderID):this()
public DispatchOnSet(int senderID)
{
_senderID = new EGID(senderID, ExclusiveGroup.StandardEntitiesGroup);
_senderID = senderID;
_subscribers = new WeakEvent<int, T>();
}
public DispatchOnSet(EGID senderID):this()
{
_senderID = senderID;
}

public DispatchOnSet()
{
_senderID = new EGID();
_subscribers = new WeakEvent<EGID, T>();
{
_subscribers = new WeakEvent<int, T>();
}
public T value
{
set
@@ -35,19 +30,19 @@ namespace Svelto.ECS
}
}
public void NotifyOnValueSet(System.Action<EGID, T> action)
public void NotifyOnValueSet(System.Action<int, T> action)
{
_subscribers += action;
}

public void StopNotify(System.Action<EGID, T> action)
public void StopNotify(System.Action<int, T> action)
{
_subscribers -= action;
}

protected T _value;
readonly EGID _senderID;
readonly int _senderID;

WeakEvent<EGID, T> _subscribers;
WeakEvent<int, T> _subscribers;
}
}

+ 0
- 2
Svelto.ECS/EGID.cs View File

@@ -1,5 +1,3 @@
using Svelto.ECS.Internal;

namespace Svelto.ECS
{
public struct EGID


+ 3
- 1
Svelto.ECS/EnginesRoot.Entities.cs View File

@@ -150,7 +150,9 @@ namespace Svelto.ECS
{
_groupedGroups[entityType].Remove(toGroupID);

fromGroup.Remove(entityType);
//it's probably better to not remove this, but the dictionary should be trimmed?
//fromGroup.Remove(entityType);
fromTypeSafeDictionary.Trim();
}
//it doesn't eliminate the fromGroup itself on purpose


+ 1
- 1
Svelto.ECS/EnginesRoot.Submission.cs View File

@@ -90,7 +90,7 @@ namespace Svelto.ECS
//one datastructure rule them all:
//split by group
//split by type per group. It's possible to get all the entities of a give type T per group thanks
//to the FasterDictionary capabilitiies OR it's possible to get a specific entityView indexed by
//to the FasterDictionary capabilities OR it's possible to get a specific entityView indexed by
//ID. This ID doesn't need to be the EGID, it can be just the entityID
readonly Dictionary<int, Dictionary<Type, ITypeSafeDictionary>> _groupEntityDB;


Loading…
Cancel
Save