private void UpdatePieceRestrictions(ModularPlacableObject Placable) { _PositionRestriction = ((int)_PositionRestriction < (int)Placable.PositionRestriction)?Placable.PositionRestriction:_PositionRestriction; // position restrictions _Scalable = (!Placable.Scalable)?Placable.Scalable:_Scalable; // scaling restriction _RotationStepRestriction = (Placable.RotationStepRestriction > _RotationStepRestriction)?Placable.RotationStepRestriction:_RotationStepRestriction; // rotation step restrictions _RotationRestriction = ((int)_RotationRestriction < (int)Placable.RotationRestriction)?Placable.RotationRestriction:_RotationRestriction; // Rotation restrictions _SpaceRestriction = ((int)_SpaceRestriction < (int)Placable.SpaceRestriction)?Placable.SpaceRestriction:_SpaceRestriction; // Space restrictions if (_PositionRestriction != PositionRestrictions.None) { _PositionGridRestriction = (_PositionGridRestriction < Placable.PositionGridRestriction) ? Placable.PositionGridRestriction : _PositionGridRestriction; // set position grid restriction } }
private void OnDuplicate(object[] Data) { List <GameObject> DuplicatedObjects = new List <GameObject> (); List <LayerMask> CustomMasks = new List <LayerMask> (); bool CanDuplicate = true; string Message = ""; for (int i = 0; i < ScopedObjects.Length; i++) { if (!ScopedObjects [i].CanDuplicate(out Message)) { CanDuplicate = false; break; } } if (CanDuplicate) { for (int i = 0; i < ScopedObjects.Length; i++) { ModularPlacableObject Duplicate = ScopedObjects [i].Duplicate(); Duplicate.transform.localScale = Vector3.Scale(Duplicate.transform.localScale, LocalMover.transform.localScale); DuplicatedObjects.Add(Duplicate.gameObject); // Duplicate item CustomMasks.Add(Duplicate.SelectionLayerMask); // add custom selection layermask // remove money and spawn indicator int Price = GameManager.I.Economy.EvaluateModularPlacable(ScopedObjects [i]); GameManager.I.Economy.RemoveMoney(Price); GameManager.I.Economy.SpawnMoneyIndicator(ScopedObjects [i].Position, Price); } GameManager.I.Select.SelectObjects(DuplicatedObjects.ToArray(), CustomMasks.ToArray()); // select new duplicated items } else { GameManager.I.UI.Toast(Message); } }