Browse Source

Update to Gamecraft 2020.04.27.14.21

tags/v0.2.2
NorbiPeti 4 years ago
parent
commit
83427b806e
Signed by: NorbiPeti <szatmari.norbert.peter@gmail.com> GPG Key ID: DBA4C4549A927E56
5 changed files with 51 additions and 39 deletions
  1. +1
    -1
      GamecraftModdingAPI/Blocks/PlacementEngine.cs
  2. +43
    -31
      GamecraftModdingAPI/Blocks/SignalEngine.cs
  3. +1
    -1
      GamecraftModdingAPI/Events/ModEventEntityStruct.cs
  4. +2
    -2
      GamecraftModdingAPI/GamecraftModdingAPI.csproj
  5. +4
    -4
      GamecraftModdingAPI/Utility/FullGameFields.cs

+ 1
- 1
GamecraftModdingAPI/Blocks/PlacementEngine.cs 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)


+ 43
- 31
GamecraftModdingAPI/Blocks/SignalEngine.cs 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,25 +69,27 @@ 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))
{
ref PortEntityStruct pes = ref entitiesDB.QueryEntity<PortEntityStruct>(signalID, group);
pes.anyChannel.valueAsFloat += signal;
if (clamp)
{
if (pes.anyChannel.valueAsFloat > Signals.POSITIVE_HIGH)
{
pes.anyChannel.valueAsFloat = Signals.POSITIVE_HIGH;
}
else if (pes.anyChannel.valueAsFloat < Signals.NEGATIVE_HIGH)
{
pes.anyChannel.valueAsFloat = Signals.NEGATIVE_HIGH;
}
return pes.anyChannel.valueAsFloat;
}
}
return signal;
var array = GetSignalStruct(signalID, out uint index, input);
if (array != null)
{
ref var channelData = ref array[index];
channelData.valueAsFloat += signal;
if (clamp)
{
if (channelData.valueAsFloat > Signals.POSITIVE_HIGH)
{
channelData.valueAsFloat = Signals.POSITIVE_HIGH;
}
else if (channelData.valueAsFloat < Signals.NEGATIVE_HIGH)
{
channelData.valueAsFloat = Signals.NEGATIVE_HIGH;
}

return channelData.valueAsFloat;
}
}

return signal;
}

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)
{
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;
}
}
}

+ 1
- 1
GamecraftModdingAPI/Events/ModEventEntityStruct.cs 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


+ 2
- 2
GamecraftModdingAPI/GamecraftModdingAPI.csproj 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>


+ 4
- 4
GamecraftModdingAPI/Utility/FullGameFields.cs 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
{


Loading…
Cancel
Save