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; break;
} }
EntityStructInitializer EntityComponentInitializer
structInitializer = structInitializer =
_blockEntityFactory.Build(newBlockID, dbid); //The ghost block index is only used for triggers _blockEntityFactory.Build(newBlockID, dbid); //The ghost block index is only used for triggers
if (colour.indexInPalette != byte.MaxValue) if (colour.indexInPalette != byte.MaxValue)

View file

@ -56,12 +56,8 @@ namespace GamecraftModdingAPI.Blocks
public bool SetSignal(uint signalID, float signal, bool input = true) public bool SetSignal(uint signalID, float signal, bool input = true)
{ {
ExclusiveGroup group = input ? NamedExclusiveGroup<InputPortsGroup>.Group : NamedExclusiveGroup<OutputPortsGroup>.Group; var array = GetSignalStruct(signalID, out uint index, input);
if (entitiesDB.Exists<PortEntityStruct>(signalID, group)) if (array != null) array[index].valueAsFloat = signal;
{
entitiesDB.QueryEntity<PortEntityStruct>(signalID, group).anyChannel.valueAsFloat = signal;
return true;
}
return false; return false;
} }
@ -73,25 +69,27 @@ namespace GamecraftModdingAPI.Blocks
public float AddSignal(uint signalID, float signal, bool clamp = true, bool input = true) public float AddSignal(uint signalID, float signal, bool clamp = true, bool input = true)
{ {
ExclusiveGroup group = input ? NamedExclusiveGroup<InputPortsGroup>.Group : NamedExclusiveGroup<OutputPortsGroup>.Group; var array = GetSignalStruct(signalID, out uint index, input);
if (entitiesDB.Exists<PortEntityStruct>(signalID, group)) if (array != null)
{ {
ref PortEntityStruct pes = ref entitiesDB.QueryEntity<PortEntityStruct>(signalID, group); ref var channelData = ref array[index];
pes.anyChannel.valueAsFloat += signal; channelData.valueAsFloat += signal;
if (clamp) 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; }
return signal;
} }
public float GetSignal(EGID blockID, out uint signalID, bool input = true) public float GetSignal(EGID blockID, out uint signalID, bool input = true)
@ -102,12 +100,8 @@ namespace GamecraftModdingAPI.Blocks
public float GetSignal(uint signalID, bool input = true) public float GetSignal(uint signalID, bool input = true)
{ {
ExclusiveGroup group = input ? NamedExclusiveGroup<InputPortsGroup>.Group : NamedExclusiveGroup<OutputPortsGroup>.Group; var array = GetSignalStruct(signalID, out uint index, input);
if (entitiesDB.Exists<PortEntityStruct>(signalID, group)) return array?[index].valueAsFloat ?? 0f;
{
return entitiesDB.QueryEntity<PortEntityStruct>(signalID, group).anyChannel.valueAsFloat;
}
return 0f;
} }
public uint[] GetSignalIDs(EGID blockID, bool input = true) public uint[] GetSignalIDs(EGID blockID, bool input = true)
@ -147,5 +141,23 @@ namespace GamecraftModdingAPI.Blocks
} }
return res; 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> /// <summary>
/// The event entity struct /// The event entity struct
/// </summary> /// </summary>
public struct ModEventEntityStruct : IEntityStruct, INeedEGID public struct ModEventEntityStruct : IEntityComponent, INeedEGID
{ {
/// <summary> /// <summary>
/// The type of event that has been emitted /// The type of event that has been emitted

View file

@ -232,8 +232,8 @@
<Reference Include="StringFormatter"> <Reference Include="StringFormatter">
<HintPath>..\ref\Gamecraft_Data\Managed\StringFormatter.dll</HintPath> <HintPath>..\ref\Gamecraft_Data\Managed\StringFormatter.dll</HintPath>
</Reference> </Reference>
<Reference Include="Svelto.Common"> <Reference Include="Svelto.Common_3">
<HintPath>..\ref\Gamecraft_Data\Managed\Svelto.Common.dll</HintPath> <HintPath>..\ref\Gamecraft_Data\Managed\Svelto.Common_3.dll</HintPath>
</Reference> </Reference>
<Reference Include="Svelto.ECS.Debugger"> <Reference Include="Svelto.ECS.Debugger">
<HintPath>..\ref\Gamecraft_Data\Managed\Svelto.ECS.Debugger.dll</HintPath> <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 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 get
{ {
return (UnityEntitySubmissionScheduler)fgcr?.Field("_frontEndSubmissionScheduler").GetValue(); return (UnityEntitySubmissionScheduler)fgcr?.Field("_frontEndSubmissionScheduler").GetValue();
} }
} }*/
public static LoadingScreenImplementer _loadingScreen public static LoadingScreenImplementer _loadingScreen
{ {