Files
BITFALL/Assets/Plugins/FImpossible Creations/Plugins - Level Design/PGG/Rules Logics/FieldAndGrid/SR_OffsetCenter.cs

29 lines
1.2 KiB
C#
Raw Normal View History

2023-11-30 00:23:23 +08:00
using UnityEngine;
namespace FIMSpace.Generating.Rules.FieldAndGrid
{
public class SR_OffsetCenter : SpawnRuleBase, ISpawnProcedureType
{
public override string TitleName() { return "Correct to Center"; }
public override string Tooltip() { return "Depending on cell's count something center of grid square is not even and position should be offsetted to fit perfectly with grid center"; }
public EProcedureType Type { get { return EProcedureType.Event; } }
public FieldModification OnlyOn;
public bool Override = false;
public Vector3 MultiplyAxis = Vector3.one;
public override void CellInfluence(FieldSetup preset, FieldModification mod, FieldCell cell, ref SpawnData spawn, FGenGraph<FieldCell, FGenPoint> grid, Vector3? restrictDirection = null)
{
if (OnlyOn != null) if (spawn.OwnerMod != OnlyOn) return;
if (Override)
{
spawn.Offset = (Vector3.Scale(grid.GetCenterOffset(preset.GetCellUnitSize()), MultiplyAxis) );
}
else
{
spawn.Offset += (Vector3.Scale(grid.GetCenterOffset(preset.GetCellUnitSize()), MultiplyAxis));
}
}
}
}