private void SyncMatrixFrames(bool first) { this.ApplyPermissions(); List <GameEntity> children = new List <GameEntity>(); this.SpawnedGhostEntity.GetChildrenRecursive(ref children); foreach (GameEntity gameEntity in children) { GameEntity item = gameEntity; if (SpawnerEntityEditorHelper.HasField((object)this.spawner_, item.Name, false)) { if (first) { MatrixFrame fieldValue = (MatrixFrame)SpawnerEntityEditorHelper.GetFieldValue((object)this.spawner_, item.Name); if (!fieldValue.IsZero) { item.SetFrame(ref fieldValue); } } else { SpawnerEntityEditorHelper.SetSpawnerMatrixFrame((object)this.spawner_, item.Name, item.GetFrame()); } } else { MatrixFrame frame = this.stableChildrenFrames.Find((Predicate <KeyValuePair <string, MatrixFrame> >)(x => x.Key == item.Name)).Value; if (!frame.NearlyEquals(item.GetFrame())) { item.SetFrame(ref frame); this.SpawnedGhostEntity.UpdateTriadFrameForEditorForAllChildren(); } } } }
private void ApplyPermissions() { foreach (Tuple <string, SpawnerEntityEditorHelper.Permission, Action <float> > childrenPermission in this._stableChildrenPermissions) { Tuple <string, SpawnerEntityEditorHelper.Permission, Action <float> > item = childrenPermission; KeyValuePair <string, MatrixFrame> keyValuePair = this.stableChildrenFrames.Find((Predicate <KeyValuePair <string, MatrixFrame> >)(x => x.Key == item.Item1)); MatrixFrame frame = this.GetGhostEntityOrChild(item.Item1).GetFrame(); if (!frame.NearlyEquals(keyValuePair.Value)) { switch (item.Item2.TypeOfPermission) { case SpawnerEntityEditorHelper.PermissionType.scale: if (frame.origin.NearlyEquals(keyValuePair.Value.origin, 0.0001f) && frame.rotation.f.NormalizedCopy().NearlyEquals(keyValuePair.Value.rotation.f.NormalizedCopy(), 0.0001f) && (frame.rotation.u.NormalizedCopy().NearlyEquals(keyValuePair.Value.rotation.u.NormalizedCopy(), 0.0001f) && frame.rotation.s.NormalizedCopy().NearlyEquals(keyValuePair.Value.rotation.s.NormalizedCopy(), 0.0001f))) { switch (item.Item2.PermittedAxis) { case SpawnerEntityEditorHelper.Axis.x: if (!frame.rotation.f.NearlyEquals(keyValuePair.Value.rotation.f)) { this.ChangeStableChildMatrixFrame(item.Item1, frame); item.Item3(frame.rotation.f.Length); continue; } continue; case SpawnerEntityEditorHelper.Axis.y: if (!frame.rotation.s.NearlyEquals(keyValuePair.Value.rotation.s)) { this.ChangeStableChildMatrixFrame(item.Item1, frame); item.Item3(frame.rotation.s.Length); continue; } continue; case SpawnerEntityEditorHelper.Axis.z: if (!frame.rotation.u.NearlyEquals(keyValuePair.Value.rotation.u)) { this.ChangeStableChildMatrixFrame(item.Item1, frame); item.Item3(frame.rotation.u.Length); continue; } continue; default: continue; } } else { continue; } case SpawnerEntityEditorHelper.PermissionType.rotation: switch (item.Item2.PermittedAxis) { case SpawnerEntityEditorHelper.Axis.x: if (!frame.rotation.f.NearlyEquals(keyValuePair.Value.rotation.f) && !frame.rotation.u.NearlyEquals(keyValuePair.Value.rotation.u) && frame.rotation.s.NearlyEquals(keyValuePair.Value.rotation.s)) { this.ChangeStableChildMatrixFrame(item.Item1, frame); item.Item3(frame.rotation.GetEulerAngles().x); continue; } continue; case SpawnerEntityEditorHelper.Axis.y: if (!frame.rotation.s.NearlyEquals(keyValuePair.Value.rotation.s) && !frame.rotation.u.NearlyEquals(keyValuePair.Value.rotation.u) && frame.rotation.f.NearlyEquals(keyValuePair.Value.rotation.f)) { this.ChangeStableChildMatrixFrame(item.Item1, frame); item.Item3(frame.rotation.GetEulerAngles().y); continue; } continue; case SpawnerEntityEditorHelper.Axis.z: if (!frame.rotation.f.NearlyEquals(keyValuePair.Value.rotation.f) && !frame.rotation.s.NearlyEquals(keyValuePair.Value.rotation.s) && frame.rotation.u.NearlyEquals(keyValuePair.Value.rotation.u)) { this.ChangeStableChildMatrixFrame(item.Item1, frame); item.Item3(frame.rotation.GetEulerAngles().z); continue; } continue; default: continue; } default: continue; } } } }