Update to Gamecraft 2020.04.27.14.21

This commit is contained in:
Norbi Peti 2020-04-28 15:55:08 +02:00
parent 2963517764
commit 83427b806e
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
5 changed files with 51 additions and 39 deletions

View file

@ -92,7 +92,7 @@ namespace GamecraftModdingAPI.Blocks
break;
}
EntityStructInitializer
EntityComponentInitializer
structInitializer =
_blockEntityFactory.Build(newBlockID, dbid); //The ghost block index is only used for triggers
if (colour.indexInPalette != byte.MaxValue)

View file

@ -56,12 +56,8 @@ namespace GamecraftModdingAPI.Blocks
public bool SetSignal(uint signalID, float signal, bool input = true)
{
ExclusiveGroup group = input ? NamedExclusiveGroup<InputPortsGroup>.Group : NamedExclusiveGroup<OutputPortsGroup>.Group;
if (entitiesDB.Exists<PortEntityStruct>(signalID, group))
{
entitiesDB.QueryEntity<PortEntityStruct>(signalID, group).anyChannel.valueAsFloat = signal;
return true;
}
var array = GetSignalStruct(signalID, out uint index, input);
if (array != null) array[index].valueAsFloat = signal;
return false;
}
@ -73,24 +69,26 @@ namespace GamecraftModdingAPI.Blocks
public float AddSignal(uint signalID, float signal, bool clamp = true, bool input = true)
{
ExclusiveGroup group = input ? NamedExclusiveGroup<InputPortsGroup>.Group : NamedExclusiveGroup<OutputPortsGroup>.Group;
if (entitiesDB.Exists<PortEntityStruct>(signalID, group))
var array = GetSignalStruct(signalID, out uint index, input);
if (array != null)
{
ref PortEntityStruct pes = ref entitiesDB.QueryEntity<PortEntityStruct>(signalID, group);
pes.anyChannel.valueAsFloat += signal;
ref var channelData = ref array[index];
channelData.valueAsFloat += signal;
if (clamp)
{
if (pes.anyChannel.valueAsFloat > Signals.POSITIVE_HIGH)
if (channelData.valueAsFloat > Signals.POSITIVE_HIGH)
{
pes.anyChannel.valueAsFloat = Signals.POSITIVE_HIGH;
channelData.valueAsFloat = Signals.POSITIVE_HIGH;
}
else if (pes.anyChannel.valueAsFloat < Signals.NEGATIVE_HIGH)
else if (channelData.valueAsFloat < Signals.NEGATIVE_HIGH)
{
pes.anyChannel.valueAsFloat = Signals.NEGATIVE_HIGH;
channelData.valueAsFloat = Signals.NEGATIVE_HIGH;
}
return pes.anyChannel.valueAsFloat;
return channelData.valueAsFloat;
}
}
return signal;
}
@ -102,12 +100,8 @@ namespace GamecraftModdingAPI.Blocks
public float GetSignal(uint signalID, bool input = true)
{
ExclusiveGroup group = input ? NamedExclusiveGroup<InputPortsGroup>.Group : NamedExclusiveGroup<OutputPortsGroup>.Group;
if (entitiesDB.Exists<PortEntityStruct>(signalID, group))
{
return entitiesDB.QueryEntity<PortEntityStruct>(signalID, group).anyChannel.valueAsFloat;
}
return 0f;
var array = GetSignalStruct(signalID, out uint index, input);
return array?[index].valueAsFloat ?? 0f;
}
public uint[] GetSignalIDs(EGID blockID, bool input = true)
@ -147,5 +141,23 @@ namespace GamecraftModdingAPI.Blocks
}
return res;
}
private ChannelDataStruct[] GetSignalStruct(uint signalID, out uint index, bool input = true)
{
ExclusiveGroup group = input
? NamedExclusiveGroup<InputPortsGroup>.Group
: NamedExclusiveGroup<OutputPortsGroup>.Group;
if (entitiesDB.Exists<PortEntityStruct>(signalID, group))
{
index = entitiesDB.QueryEntity<PortEntityStruct>(signalID, group).anyChannelIndex;
ChannelDataStruct[] channelData = entitiesDB
.QueryEntities<ChannelDataStruct>(NamedExclusiveGroup<ChannelDataGroup>.Group)
.ToFastAccess(out uint _);
return channelData;
}
index = 0;
return null;
}
}
}

View file

@ -11,7 +11,7 @@ namespace GamecraftModdingAPI.Events
/// <summary>
/// The event entity struct
/// </summary>
public struct ModEventEntityStruct : IEntityStruct, INeedEGID
public struct ModEventEntityStruct : IEntityComponent, INeedEGID
{
/// <summary>
/// The type of event that has been emitted

View file

@ -232,8 +232,8 @@
<Reference Include="StringFormatter">
<HintPath>..\ref\Gamecraft_Data\Managed\StringFormatter.dll</HintPath>
</Reference>
<Reference Include="Svelto.Common">
<HintPath>..\ref\Gamecraft_Data\Managed\Svelto.Common.dll</HintPath>
<Reference Include="Svelto.Common_3">
<HintPath>..\ref\Gamecraft_Data\Managed\Svelto.Common_3.dll</HintPath>
</Reference>
<Reference Include="Svelto.ECS.Debugger">
<HintPath>..\ref\Gamecraft_Data\Managed\Svelto.ECS.Debugger.dll</HintPath>

View file

@ -64,11 +64,11 @@ namespace GamecraftModdingAPI.Utility
}
}
public static SimpleSubmissionEntityViewScheduler _mainGameSubmissionScheduler
public static SimpleEntitiesSubmissionScheduler _mainGameSubmissionScheduler
{
get
{
return (SimpleSubmissionEntityViewScheduler)fgcr?.Field("_mainGameSubmissionScheduler").GetValue();
return (SimpleEntitiesSubmissionScheduler)fgcr?.Field("_sub").Field("_mainGameSubmissionScheduler").GetValue();
}
}
@ -112,13 +112,13 @@ namespace GamecraftModdingAPI.Utility
}
}
public static UnityEntitySubmissionScheduler _frontEndSubmissionScheduler
/*public static UnityEntitySubmissionScheduler _frontEndSubmissionScheduler
{
get
{
return (UnityEntitySubmissionScheduler)fgcr?.Field("_frontEndSubmissionScheduler").GetValue();
}
}
}*/
public static LoadingScreenImplementer _loadingScreen
{