-
Notifications
You must be signed in to change notification settings - Fork 12
/
VoxelChange.cs
94 lines (85 loc) · 4.58 KB
/
VoxelChange.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Swihoni.Util.Math;
using UnityEngine;
namespace Voxels
{
public enum VoxelVolumeForm : byte
{
Single,
Spherical,
Cylindrical,
Wall,
Prism
}
public struct VoxelChange
{
public Position3Int? position;
public byte? texture, density, orientation;
public bool? hasBlock, isBreakable, natural, replace, modifiesBlocks, noRandom, revert, isBreathable;
public Color32? color;
public float? magnitude, yaw;
public VoxelVolumeForm? form;
public Position3Int? upperBound;
public List<(Chunk, Position3Int, Voxel)> undo;
public bool isUndo;
#region Generated
public void Merge(in VoxelChange change)
{
if (change.position.HasValue) position = change.position.Value;
if (change.texture.HasValue) texture = change.texture.Value;
if (change.hasBlock.HasValue) hasBlock = change.hasBlock.Value;
if (change.density.HasValue) density = change.density.Value;
if (change.orientation.HasValue) orientation = change.orientation.Value;
if (change.isBreakable.HasValue) isBreakable = change.isBreakable.Value;
if (change.natural.HasValue) natural = change.natural.Value;
if (change.replace.HasValue) replace = change.replace.Value;
if (change.modifiesBlocks.HasValue) modifiesBlocks = change.modifiesBlocks.Value;
if (change.revert.HasValue) revert = change.revert.Value;
if (change.isBreathable.HasValue) isBreathable = change.isBreathable.Value;
if (change.noRandom.HasValue) noRandom = change.noRandom.Value;
if (change.color.HasValue) color = change.color.Value;
if (change.magnitude.HasValue) magnitude = change.magnitude.Value;
if (change.yaw.HasValue) yaw = change.yaw.Value;
if (change.form.HasValue) form = change.form.Value;
if (change.upperBound.HasValue) upperBound = change.upperBound.Value;
}
public bool Equals(VoxelChange other)
=> Nullable.Equals(position, other.position) && texture == other.texture && density == other.density && orientation == other.orientation &&
hasBlock == other.hasBlock && isBreakable == other.isBreakable && natural == other.natural && replace == other.replace && modifiesBlocks == other.modifiesBlocks &&
noRandom == other.noRandom && revert == other.revert && isBreathable == other.isBreathable && Nullable.Equals(color, other.color) &&
Nullable.Equals(magnitude, other.magnitude) && Nullable.Equals(yaw, other.yaw) && form == other.form && Nullable.Equals(upperBound, other.upperBound) &&
isUndo == other.isUndo;
public override bool Equals(object other) => other is VoxelChange otherChange && Equals(otherChange);
[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
public override int GetHashCode()
{
unchecked
{
int hashCode = position.GetHashCode();
hashCode = (hashCode * 397) ^ texture.GetHashCode();
hashCode = (hashCode * 397) ^ density.GetHashCode();
hashCode = (hashCode * 397) ^ orientation.GetHashCode();
hashCode = (hashCode * 397) ^ hasBlock.GetHashCode();
hashCode = (hashCode * 397) ^ isBreakable.GetHashCode();
hashCode = (hashCode * 397) ^ natural.GetHashCode();
hashCode = (hashCode * 397) ^ replace.GetHashCode();
hashCode = (hashCode * 397) ^ modifiesBlocks.GetHashCode();
hashCode = (hashCode * 397) ^ noRandom.GetHashCode();
hashCode = (hashCode * 397) ^ revert.GetHashCode();
hashCode = (hashCode * 397) ^ isBreathable.GetHashCode();
hashCode = (hashCode * 397) ^ color.GetHashCode();
hashCode = (hashCode * 397) ^ magnitude.GetHashCode();
hashCode = (hashCode * 397) ^ yaw.GetHashCode();
hashCode = (hashCode * 397) ^ form.GetHashCode();
hashCode = (hashCode * 397) ^ upperBound.GetHashCode();
hashCode = (hashCode * 397) ^ isUndo.GetHashCode();
return hashCode;
}
}
public static bool operator ==(VoxelChange left, VoxelChange right) => left.Equals(right);
public static bool operator !=(VoxelChange left, VoxelChange right) => !left.Equals(right);
#endregion
}
}