Skip to content

Commit

Permalink
Examples 5-6-7 updated to Svelto.ECS 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sebas77 committed Oct 10, 2021
1 parent bc31398 commit 2cb85a9
Show file tree
Hide file tree
Showing 393 changed files with 11,903 additions and 10,340 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp5.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<OutputType>Exe</OutputType>
<StartupObject>Svelto.ECS.Vanilla.Example.Program</StartupObject>
<LangVersion>latest</LangVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
name: Svelto.Common Nuget Release

on:
workflow_dispatch:
inputs:
name:
description: 'Reason'
default: 'Manual workflow triggering'
push:
branches:
- master
paths:
- version.json
- ".github/workflows/nuget-release.yml"

jobs:
build:
Expand All @@ -19,14 +23,38 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: make temp dirs
run: mkdir temp temp/bin temp/bin/debug temp/bin/release

- name: get preparation tools
run: git clone https://github.com/Ujinjinjin/upm-preparator.git --branch v1.0.12 --single-branch

- name: get package version
run: python3 upm-preparator/version.py --version-file "version.json" --env-file "${GITHUB_ENV}"

# Build for debug
- name: create package for Debug configuration
run: dotnet pack /p:PackageVersion=1.0.0 -o temp/bin/debug Svelto.Common.csproj -c Debug

- name: unzip debug nuget package
run: unzip temp/bin/debug/Svelto.Common.1.0.0.nupkg -d temp/bin/debug

- name: copy debug DLL to temp folder
run: sudo cp temp/bin/debug/lib/netstandard2.0/Svelto.Common.dll temp/bin/debug

# Build for release
- name: create package for Release configuration
run: dotnet pack /p:PackageVersion=1.0.0 -o temp/bin/release Svelto.Common.csproj -c Release

- name: unzip release nuget package
run: unzip temp/bin/release/Svelto.Common.1.0.0.nupkg -d temp/bin/release

- name: copy release DLL to temp folder
run: sudo cp temp/bin/release/lib/netstandard2.0/Svelto.Common.dll temp/bin/release

# Compile into nuget package
- name: build nuget package
run: dotnet pack /p:Version=${PKG_VERSION} -o .
run: sudo dotnet pack /p:PackageVersion=${PKG_VERSION} -o . Svelto.Common.csproj -c NugetPack

- name: publish nuget package
run: dotnet nuget push ${{ env.PKG_NAME }}.${{ env.PKG_VERSION }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
name: Svelto.Common UPM Release

on:
workflow_dispatch:
inputs:
name:
description: 'Reason'
default: 'Manual workflow triggering'
push:
branches:
- master
paths:
- version.json
- ".github/workflows/upm-release.yml"

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
*.meta
netstandard2.0
obj
.idea/
Svelto.Common.sdpkg.user
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog
All notable changes to this project will be documented in this file. I created this file with Svelto.Common version 3.1.
All notable changes to this project will be documented in this file. Changes are listed in random order of importance.

## [3.2.0]

* ICompositionRoot OnContextDestroyed now receive a flag to know if the OnContextInitialized ever had the chance to be called
* Fix some naming case issues, not following the Svelto convention
* Improve FasterList interface
* Add Intersect/Exclude/Union methods to FasterDictionary to work with Sets
* Improve all the SveltoDictionary and derivates interfaces
* Changed (again and still not final) the logic behind the PlatformProfiler markers
* Refactor MemoryUtilities functionalities

## [3.1.3]

### Fixed

* fixed serious mistake in the RefWrapper equality logic that could affect certains kind of keys in the new FasterDictionary (most notable strings)

## [3.1.0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,11 @@ void Awake()
_applicationRoot = new T();

_applicationRoot.OnContextCreated(this);

Application.wantsToQuit += IsQuitting;
}

bool IsQuitting()
{
_isQuitting = true;
_applicationRoot.OnContextDestroyed();

return true;
}

void OnDestroy()
{
if (_isQuitting == false)
_applicationRoot.OnContextDestroyed();
_applicationRoot.OnContextDestroyed(_hasBeenInitialised);
}

void Start()
Expand All @@ -47,11 +36,13 @@ IEnumerator WaitForFrameworkInitialization()
//let's wait until the end of the frame, so we are sure that all the awake and starts are called
yield return new WaitForEndOfFrame();

_hasBeenInitialised = true;

_applicationRoot.OnContextInitialized(this);
}

T _applicationRoot;
bool _isQuitting;
bool _hasBeenInitialised;
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Svelto.Context
public interface ICompositionRoot
{
void OnContextInitialized<T>(T contextHolder);
void OnContextDestroyed();
void OnContextDestroyed(bool hasBeenInitialised);
void OnContextCreated<T>(T contextHolder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

namespace Svelto.DataStructures
{
//Note: the burst compatible version of a dynamic array is found in Svelto.ECS and is called NativeDynamicArray/Cast
public class FasterList<T>
{
internal static readonly FasterList<T> DefaultEmptyList = new FasterList<T>();

public int count => (int) _count;
public uint capacity => (uint) _buffer.Length;
public int capacity => _buffer.Length;

public static explicit operator FasterList<T>(T[] array)
{
Expand Down Expand Up @@ -101,7 +100,7 @@ public FasterList(in FasterReadOnlyList<T> source)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
DBC.Common.Check.Require(index < _count, "out of bound index");
DBC.Common.Check.Require(index < _count, $"out of bound index. index {index} - count {_count}");
return ref _buffer[index];
}
}
Expand Down Expand Up @@ -147,7 +146,7 @@ public void AddRange(T[] items, uint count)
if (count == 0) return;

if (_count + count > _buffer.Length)
AllocateMore(_count + count);
AllocateTo(_count + count);

Array.Copy(items, 0, _buffer, _count, count);
_count += count;
Expand All @@ -162,10 +161,8 @@ public void AddRange(T[] items)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Contains(T item)
{
var comp = EqualityComparer<T>.Default;

for (uint index = 0; index < _count; index++)
if (comp.Equals(_buffer[index], item))
if (_comp.Equals(_buffer[index], item))
return true;

return false;
Expand Down Expand Up @@ -292,7 +289,7 @@ public FasterListEnumerator<T> GetEnumerator()
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Insert(int index, in T item)
public void InsertAt(uint index, in T item)
{
DBC.Common.Check.Require(index <= _count, "out of bound index");

Expand All @@ -305,7 +302,7 @@ public void Insert(int index, in T item)
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void RemoveAt(int index)
public void RemoveAt(uint index)
{
DBC.Common.Check.Require(index < _count, "out of bound index");

Expand Down Expand Up @@ -341,15 +338,15 @@ public T[] ToArray()
/// </summary>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T[] ToArrayFast(out uint count)
public T[] ToArrayFast(out int count)
{
count = _count;
count = (int) _count;

return _buffer;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool UnorderedRemoveAt(int index)
public bool UnorderedRemoveAt(uint index)
{
DBC.Common.Check.Require(index < _count && _count > 0, "out of bound index");

Expand Down Expand Up @@ -386,16 +383,15 @@ public void ExpandBy(uint increment)
uint count = _count + increment;

if (_buffer.Length < count)
AllocateMore(count);
AllocateTo(count);

_count = count;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ExpandTo(uint newSize)
{
if (_buffer.Length < newSize)
AllocateMore(newSize);
EnsureCapacity(newSize);

if (_count < newSize)
_count = newSize;
Expand All @@ -404,7 +400,13 @@ public void ExpandTo(uint newSize)
public void EnsureCapacity(uint newSize)
{
if (_buffer.Length < newSize)
AllocateMore(newSize);
AllocateTo(newSize);
}

public void EnsureExtraCapacity(uint newSize)
{
if (_buffer.Length < _count + newSize)
AllocateTo(_count + newSize);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down Expand Up @@ -453,9 +455,20 @@ void AllocateMore(uint newSize)
if (_count > 0) Array.Copy(_buffer, newList, _count);
_buffer = newList;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
void AllocateTo(uint newSize)
{
DBC.Common.Check.Require(newSize > _buffer.Length);

var newList = new T[newSize];
if (_count > 0) Array.Copy(_buffer, newList, _count);
_buffer = newList;
}

T[] _buffer;
uint _count;
T[] _buffer;
uint _count;
static readonly EqualityComparer<T> _comp = EqualityComparer<T>.Default;

public static class NoVirt
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Svelto.DataStructures
{
public struct FasterListEnumerator<T>
public ref struct FasterListEnumerator<T>
{
public T Current =>
_buffer[(uint) _counter - 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ namespace Svelto.DataStructures
{
public readonly struct FasterReadOnlyList<T>
{
public static FasterReadOnlyList<T> DefaultEmptyList = new FasterReadOnlyList<T>(
FasterList<T>.DefaultEmptyList);

public int count => _list.count;
public uint capacity => _list.capacity;
public static FasterReadOnlyList<T> DefaultEmptyList = new FasterReadOnlyList<T>(new FasterList<T>(0));

public int count => (int) _list.count;

public FasterReadOnlyList(FasterList<T> list)
{
_list = list;
Expand Down Expand Up @@ -40,11 +38,11 @@ public FasterListEnumerator<T> GetEnumerator()
public ref T this[uint index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => ref _list[index];
get => ref _list[(int) index];
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T[] ToArrayFast(out uint count)
public T[] ToArrayFast(out int count)
{
return _list.ToArrayFast(out count);
}
Expand Down
Loading

0 comments on commit 2cb85a9

Please sign in to comment.