void OnSceneClean(GameMessage msg) { FlagsHelper.Unset(ref currentState, GameState.started); FlagsHelper.Unset(ref currentState, GameState.ended); FlagsHelper.Unset(ref currentState, GameState.arenaAnimating); FlagsHelper.Unset(ref currentState, GameState.firstOut); FlagsHelper.Set(ref currentState, GameState.gameReloaded); }
// Private private PlayerSkeleton AttachLimb(Limb limb) { FlagsHelper.Set(ref existing, limb); SetActive(limb, true); Events.Raise(OnLimbAttached, existing, limb); return(this); }
private (bool, Size) GeRadius(CssReader reader, RadialGradientShape shape, ref RadialGradientFlags flags) { if (reader.CanRead) { var size = Dimensions.Zero; if (shape == RadialGradientShape.Circle) { var radiusToken = reader.Read(); var isRadius = OffsetConverter.TryExtractOffset(radiusToken, out var radius); if (isRadius) { size = new Dimensions(radius, radius); reader.MoveNext(); } } if (shape == RadialGradientShape.Ellipse) { var radiusHToken = reader.Read(); var radiusVToken = reader.ReadNext(); var isRadiusH = OffsetConverter.TryExtractOffset(radiusHToken, out var radiusH); var isRadiusV = OffsetConverter.TryExtractOffset(radiusVToken, out var radiusV); if (isRadiusH && isRadiusV) { size = new Dimensions(radiusH, radiusV); reader.MoveNext(); } else { // Revert radiusVToken reader.Rollback(); } } if (size != Dimensions.Zero) { if (size.Width.Type == OffsetType.Proportional) { FlagsHelper.Set(ref flags, WidthProportional); } if (size.Height.Type == OffsetType.Proportional) { FlagsHelper.Set(ref flags, HeightProportional); } return(true, new Size(size.Width.Value, size.Height.Value)); } } // Value -1 means undefined for RadialGradientShader return(false, new Size(-1, -1)); }
public void AddStatus(BallStatus newStatus, Material newMat) { if (newMat != null) { GetComponent <Renderer>().sharedMaterial = newMat; matQueue.Add(newMat); } FlagsHelper.Set <BallStatus>(ref status, newStatus); CheckStatus(); }
//Adds a new Layer this object can collide with public void AddToCollisions(string layerName) { FlagsHelper.Set(ref collisionLayerMask, 1 << LayerMask.NameToLayer(layerName)); FlagsHelper.Set(ref collisionLayerMaskDown, 1 << LayerMask.NameToLayer(layerName)); //Handle Terrain and PassThroughBottom at the same time for ease of use if (layerName == "Terrain") { FlagsHelper.Set(ref collisionLayerMaskDown, 1 << LayerMask.NameToLayer("PassThroughBottom")); } }
/// <summary> /// Sets a bit flag to a file attribute. /// </summary> /// <param name="user"></param> /// <param name="attrib"></param> /// <param name="value"></param> public void SetWin32Attribute(FileAttributes attrib, bool value) { if (value) { Win32FileAttribute = (int)FlagsHelper.Set(((FileAttributes)Win32FileAttribute), attrib); } else { Win32FileAttribute = (int)FlagsHelper.Unset(((FileAttributes)Win32FileAttribute), attrib); } }
private void HandleLimbActivationChange(bool isActive, Limb limb) { if (isActive) { FlagsHelper.Set(ref active, limb); } else { FlagsHelper.Unset(ref active, limb); } }
public void UpdateState(State state, bool value) { var states = State; if (value) { FlagsHelper.Set(ref states, state); } else { FlagsHelper.Unset(ref states, state); } State = states; }
public void UpdateState(State state, bool value) { var states = State; if (value) { FlagsHelper.Set(ref states, state); } else { FlagsHelper.Unset(ref states, state); } State = states; //DebugLog.DebugWrite($"State of player {NetId} is now : {Environment.NewLine}" + // $"{DebugLog.GenerateTable(Enum.GetNames(typeof(State)).ToList(), FlagsHelper.FlagsToListSet(State))}"); }
/// <summary> /// Sets a bit flag to a file attribute. /// </summary> /// <param name="user"></param> /// <param name="attrib"></param> /// <param name="value"></param> public void SetWin32Attribute(Principal user, FileAttributes attrib, bool value) { using (var context = new OnlineFilesEntities()) if (!(context.FileSecurities.Where(d => d.fk_FileId == pk_FileId).ToList().Any(x => user.UserProfile.mySecurityGroups.Contains(x.SecurityObjectId) && x.canWrite))) { throw new SecurityException("Not Authorized."); } if (value) { Win32FileAttribute = (int)FlagsHelper.Set(((FileAttributes)Win32FileAttribute), attrib); } else { Win32FileAttribute = (int)FlagsHelper.Unset(((FileAttributes)Win32FileAttribute), attrib); } }
private (bool, Point) GetPosition(CssReader reader, ref RadialGradientFlags flags) { if (reader.CanRead) { var token = reader.Read().Trim(); if (token == "at") { var tokenX = reader.ReadNext(); var tokenY = reader.ReadNext(); var isPosX = OffsetConverter.TryExtractOffset(tokenX, out var posX); var isPosY = OffsetConverter.TryExtractOffset(tokenY, out var posY); var direction = Vector2.Zero; if (!isPosX && !string.IsNullOrEmpty(tokenX)) { direction.SetNamedDirection(tokenX); } if (!isPosY && !string.IsNullOrEmpty(tokenY)) { direction.SetNamedDirection(tokenY); } if (!isPosX || posX.Type == OffsetType.Proportional) { FlagsHelper.Set(ref flags, XProportional); } if (!isPosY || posY.Type == OffsetType.Proportional) { FlagsHelper.Set(ref flags, YProportional); } var center = new Point( isPosX ? posX.Value : (direction.X + 1) / 2, isPosY ? posY.Value : (direction.Y + 1) / 2); return(true, center); } } FlagsHelper.Set(ref flags, PositionProportional); return(false, new Point(0.5, 0.5)); }
public static void BitMaskField <T>(ref T enumValue) where T : System.Enum { Dictionary <int, bool> toggleBools = new Dictionary <int, bool>(); int possiableInt = System.Enum.GetValues(typeof(T)).Cast <int>().Max(); foreach (T item in System.Enum.GetValues(typeof(T))) { int intValue = System.Convert.ToInt32(item); if (intValue == 0 || intValue == possiableInt) { toggleBools.Add(intValue, object.Equals(enumValue, item)); continue; } toggleBools.Add(intValue, FlagsHelper.IsSet(enumValue, item)); } using (var horizon = new EditorGUILayout.HorizontalScope()) { foreach (T item in System.Enum.GetValues(typeof(T))) { int intValue = System.Convert.ToInt32(item); using (var check = new EditorGUI.ChangeCheckScope()) { toggleBools[intValue] = GUILayout.Toggle(toggleBools[intValue], item.ToString(), toggleStyle); if (check.changed) { if (intValue == 0 || intValue == possiableInt) { if (toggleBools[intValue]) { enumValue = item; } continue; } if (toggleBools[intValue]) { FlagsHelper.Set(ref enumValue, item); } else { FlagsHelper.Unset(ref enumValue, item); } } } } } }
// Released public Direction2D GetInputReleased(Direction2D oldInput, Direction2D newInput) { var result = Direction2D.NONE; var check = 1; for (var i = 0; i < 8 * sizeof(int); ++i) { var current = (Direction2D)(check << i); if (FlagsHelper.IsSet(oldInput, current) && !FlagsHelper.IsSet(newInput, current)) { FlagsHelper.Set(ref result, current); } } return(result); }
void Awake() { previousFrameProperties.position = transform.position; properties.position = transform.position; collisionLayerMask = 1 << LayerMask.NameToLayer("Terrain"); collisionLayerMaskDown = collisionLayerMask; FlagsHelper.Set(ref collisionLayerMaskDown, 1 << LayerMask.NameToLayer("PassThroughBottom")); if (gameObject.tag == "Player") { AddToCollisions("Boundaries"); } if (rexObject == null) { rexObject = GetComponent <RexObject>(); } }
protected Piece(Point2D positionPoint2D, Color color, string letter, string name, bool moveRepeat) { Name = name; _flags = moveRepeat ? PieceEnum.InPlay | PieceEnum.MoveRepeat : PieceEnum.InPlay; Letter = letter; _positionPoint2D = positionPoint2D; Color = color; if (positionPoint2D.X % 2 == positionPoint2D.Y % 2) { FlagsHelper.Set(ref _flags, PieceEnum.LightColor); } else { FlagsHelper.Unset(ref _flags, PieceEnum.LightColor); } }
private void BtnOk_Click(object sender, EventArgs e) { if (!FieldsIsValid()) { MessageBox.Show("Заполните все поля", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } CurrentUser.TUSER = tbUserName.Text; CurrentUser.FullName = tbFullUserName.Text; CurrentUser.PASSWORD = tbUserPassword.Text; UsersStages stageAgregate = UsersStages.None; foreach (CheckedListBoxItem en in cbStageList.Items) { if (!(en.CheckState == CheckState.Checked)) { continue; } Enum.TryParse(en.Value.GetType().Name, out UsersStages result); FlagsHelper.Set(ref stageAgregate, result); } CurrentUser.UserStagesMask = (long)stageAgregate; var funcAgregate = UserExtraFunc.None; foreach (CheckedListBoxItem en in cbFunctionsList.Items) { if (!(en.CheckState == CheckState.Checked)) { continue; } Enum.TryParse(en.Value.GetType().Name, out UserExtraFunc result); FlagsHelper.Set(ref funcAgregate, result); } CurrentUser.UserExtraFuncMask = (long)funcAgregate; DialogResult = DialogResult.OK; Close(); }
private Direction2D Convert(Vector2 v) { var result = Direction2D.NONE; var fallback = Direction2D.NONE; var list = new List <Direction2D>() { v.x > 0 ? Direction2D.RIGHT : fallback, v.x < 0 ? Direction2D.LEFT : fallback, v.y > 0 ? Direction2D.UP : fallback, v.y < 0 ? Direction2D.DOWN : fallback }; foreach (Direction2D d in list) { FlagsHelper.Set(ref result, d); } return(result); }
void OnArenaAnimating(GameMessage msg) { FlagsHelper.Set(ref currentState, GameState.arenaAnimating); //currentState |= GameState.arenaAnimating; }
void OnEndGame(GameMessage msg) { FlagsHelper.Set(ref currentState, GameState.ended); }
void OnStartGame(GameMessage msg) { // Set a bit at position to 1. FlagsHelper.Set(ref currentState, GameState.started); //currentState |= GameState.started; }
public void Update(Direction2D d, bool isSet) { FlagsHelper.Set(ref varFlags, d, isSet); Vector = Convert(varFlags); }
internal Channels(int pos, String line, DataRoot dataRoot) { this.confLine = line; this.RecordIndex = this.RecordOrder = this.OldProgramNr = pos+1; try { if (line[0] == ':') { this.Name = Convert.ToString(line.Split(':').GetValue(1)); return; } var fields = line.Split(':'); // field 0 - ChannelName[,ShotName][;ProviderName] if (fields[0].IndexOf(',') >= 0 || fields[0].IndexOf(';') >= 0) { if (fields[0].IndexOf(',') >= 0) { this.Name = fields[0].Substring(0, fields[0].LastIndexOf(',')); if (fields[0].IndexOf(';') >= 0) this.ShortName = fields[0].Split(';').GetValue(0).ToString().Substring(fields[0].LastIndexOf(',')+1); else this.ShortName = fields[0].Substring(fields[0].LastIndexOf(',')+1); } else this.Name = Convert.ToString(fields[0].Split(';').GetValue(0)); if (fields[0].IndexOf(';') >= 0) this.Provider = Convert.ToString(fields[0].Split(';').GetValue(1)); } else this.Name = Convert.ToString(fields[0]); if (fields.Length >= 9) { // field 1 - Freqency // DVB-S - Frequency in MHz. // DVB-C/T - Frequency in MHz, kHz or Hz. // analogue- Frequency in MHz. (analogTV plugin) int freq = Convert.ToInt32(fields[1]); // TODO - corrent DVB-C/T to MHz this.FreqInMhz = freq; // field 2 - Params ParseParams(Convert.ToString(fields[2])); // field 3 - Source string ntype = Convert.ToString(fields[3]); switch (ntype[0]) { case 'S': SignalSource = FlagsHelper.Set(SignalSource, SignalSource.DVBS); this.Satellite = ntype.Substring(1,ntype.Length -1); this.SatPosition = ntype.Substring(1, ntype.Length - 1); break; case 'C': SignalSource = FlagsHelper.Set(SignalSource, SignalSource.DVBC); this.Satellite = "DVB-C"; break; case 'T': SignalSource = FlagsHelper.Set(SignalSource, SignalSource.DVBT); this.Satellite = "DVB-T"; break; } // field 4 - SymbolRate this.SymbolRate = Convert.ToInt32(fields[4]); // field 5 - Video-PID[+PCR-PID][=Stream-Type] vtype = 0; string tmp = fields[5]; if (tmp.IndexOf('=') >= 0 || tmp.IndexOf('+') >= 0) { SignalSource = FlagsHelper.Set(SignalSource, SignalSource.TV); if (tmp.IndexOf('+') >= 0) { this.VideoPid = Convert.ToInt32(fields[5].Split('+').GetValue(0)); if (tmp.IndexOf('=') >= 0) vtype = Convert.ToInt32(fields[5].Split('=').GetValue(1)); } else { this.VideoPid = Convert.ToInt32(fields[5].Split('=').GetValue(0)); vtype = Convert.ToInt32(fields[5].Split('=').GetValue(1)); } } else if (tmp == "0" || tmp == "1") { this.SignalSource |= SignalSource.Radio; if (tmp == "1") this.Encrypted = true; } else this.VideoPid = Convert.ToInt32(fields[5]); if (this.VideoPid != 0 && vtype == 0) vtype = 2; // default is MPEG-2 // field 6 - Audio-PID[=Language-ID][@Stream-Type][;Dolby-PID[=Language-ID][@Stream-Type]] int NumApids = 0; int NumDpids = 0; apids[0] = 0; atypes[0] = 0; dpids[0] = 0; dtypes[0] = 0; // example field: 5102=deu@3,5103=deu;5106 // 101=deu@3;103=deu@106 foreach (string f1 in fields[6].Split(',')) { int i = 0; foreach (string apid in f1.Split(';')) { if(i == 0) // apids { atypes[NumApids] = 4; // backwards compatibility if (apid.IndexOf('=') >= 0) { apids[NumApids] = Convert.ToInt32(apid.Split('=').GetValue(0)); if (apid.IndexOf('@') >= 0) { tmp = Convert.ToString(apid.Split('=').GetValue(1)); alangs[NumApids] = Convert.ToString(tmp.Split('@').GetValue(0)); atypes[NumApids] = Convert.ToInt32(tmp.Split('@').GetValue(1)); } else alangs[NumApids] = Convert.ToString(apid.Split('=').GetValue(1)); } else if (apid.IndexOf('@') >= 0) { apids[NumApids] = Convert.ToInt32(apid.Split('@').GetValue(0)); atypes[NumApids] = Convert.ToInt32(apid.Split('@').GetValue(1)); } else apids[NumApids] = Convert.ToInt32(apid); NumApids++; } else // dpids { //dtypes[NumDpids] //dlangs[NumDpids] //dpids[NumDpids] NumDpids++; } i++; } } this.AudioPid = apids[0]; this.ServiceType = getServiceType(); // field 7 - Teletext-PID (TPID) // field 8 - Conditional Access-ID (CAID) if (Convert.ToString(fields[8]) == "0") this.Encrypted = false; else this.Encrypted = true; // field 9 - Service ID (SID) this.ServiceId = Convert.ToInt32(fields[9]); // field 10 - Network ID (NID) this.OriginalNetworkId = Convert.ToInt32(fields[10]); // field 11 - Transport Steam ID (TID) this.TransportStreamId = Convert.ToInt32(fields[11]); // field 12 - Radio ID (RID) } } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } }
//Enables collision with one-way platforms public void EnableOneWayPlatforms() { FlagsHelper.Set(ref collisionLayerMaskDown, 1 << LayerMask.NameToLayer("PassThroughBottom")); }
internal DbChannel(SQLiteDataReader r, IDictionary <string, int> field, DataRoot dataRoot, Encoding encoding) { RecordIndex = r.GetInt32(field["rowid"]); RecordOrder = r.GetInt32(field["major_channel"]); OldProgramNr = r.GetInt32(field["major_channel"]); int ntype = r.GetInt32(field["ntype"]); DeliveryType = r.GetInt32(field["delivery_type"]); if (ntype == 1) { SignalSource = FlagsHelper.Set(SignalSource, SignalSource.DVBS); if (r.GetInt32(field["ya_svcid"]) >= 0) { SignalSource = FlagsHelper.Set(SignalSource, SignalSource.Preset_Freesat); } } else if (ntype == 2) { SignalSource = FlagsHelper.Set(SignalSource, SignalSource.DVBT); } else if (ntype == 3) { SignalSource = FlagsHelper.Set(SignalSource, SignalSource.DVBC); } else if (ntype == 10) { SignalSource = FlagsHelper.Set(SignalSource, SignalSource.AnalogAntenna | SignalSource.TV); } else if (ntype == 14) { SignalSource = FlagsHelper.Set(SignalSource, SignalSource.AnalogCable | SignalSource.TV); } else if (ntype == 15) { if (DeliveryType == 15) { SignalSource = FlagsHelper.Set(SignalSource, SignalSource.DVBIPSat); } //else if (this.DeliveryType == 0) // Currently no sample for AntennaIP found // SignalSource = FlagsHelper.Set(SignalSource, SignalSource.DVBIPAntenna); else if (DeliveryType == 18) { SignalSource = FlagsHelper.Set(SignalSource, SignalSource.DVBIPCable); } else { SignalSource = FlagsHelper.Set(SignalSource, SignalSource.DVBIPSat); } } byte[] buffer = new byte[1000]; if (!r.IsDBNull(field["delivery"])) { var len = r.GetBytes(field["delivery"], 0, buffer, 0, 1000); AddDebug(buffer, 0, (int)len); } Skip = r.GetInt32(field["skip"]) != 0; Encrypted = r.GetInt32(field["free_CA_mode"]) != 0; Lock = r.GetInt32(field["child_lock"]) != 0; ParseFavorites(r, field); ReadNamesWithEncodingDetection(r, field, encoding); if (ntype == 10 || ntype == 14) { ReadAnalogData(r, field); } else { ReadDvbData(r, field, dataRoot, buffer); } }
private void LoadServiceData(SQLiteCommand cmd) { cmd.CommandText = @" select s.pid, s.type, anls.Frequency, digs.TunerId, digs.Sid, Name, ShortName, Encrypted, Visible, Selectable, ParentalLock, MediaType from service s left outer join AnalogService anls on anls.ServiceId=s.Pid left outer join DVBService digs on digs.ServiceId=s.Pid "; using (var r = cmd.ExecuteReader()) { while (r.Read()) { ChannelInfo ci = null; if (!r.IsDBNull(2)) // AnalogService { ci = new ChannelInfo(SignalSource.Analog, r.GetInt32(0), -1, r.GetString(5)); } else if (!r.IsDBNull(3)) // DvbService { var trans = (HisTransponder)DataRoot.Transponder.TryGet(r.GetInt32(3)); ci = new ChannelInfo(trans.SignalSource, r.GetInt32(0), -1, r.GetString(5)); ci.Transponder = trans; ci.FreqInMhz = trans.FrequencyInMhz; ci.OriginalNetworkId = trans.OriginalNetworkId; ci.TransportStreamId = trans.TransportStreamId; ci.Source = trans.Source; ci.ServiceId = r.GetInt32(4); ci.ShortName = r.GetString(6); ci.Encrypted = r.GetInt32(7) != 0; ci.Hidden = r.GetInt32(8) == 0; ci.Skip = r.GetInt32(9) == 0; ci.Lock = r.GetInt32(10) != 0; var mediaType = r.GetInt32(11); if (mediaType == 1) { ci.SignalSource = FlagsHelper.Set(ci.SignalSource, SignalSource.TV); ci.ServiceTypeName = "TV"; } else if (mediaType == 2) { ci.SignalSource |= SignalSource.Radio; ci.ServiceTypeName = "Radio"; } else { ci.ServiceTypeName = mediaType.ToString(); } } else if (r.GetInt32(1) == 0) // A/V input { ci = new ChannelInfo(SignalSource.AvInput, r.GetInt32(0), -1, r.GetString(5)); ci.ServiceTypeName = "A/V"; } if (ci != null) { channelsById.Add(ci.RecordIndex, ci); } } } }
private void HandleGrounded() { var movement = input.held.direction.Vector; var resolvedVelocity = entity.velocity; FlagsHelper.Unset(ref state, State.JUMP); wallJumpImpactDirection.Clear(); // Horizontal movement. resolvedVelocity.x = movement.x * data.velocityHorizontalGroundMax; if (!FlagsHelper.IsSet(state, State.CROUCH)) { if (input.held.crouch) { var newBounds = entity.LocalScale; var crouchPosition = entity.Position; newBounds.x *= data.boundsMultiplierCrouchX; newBounds.y *= data.boundsMultiplierCrouchY; crouchPosition.y -= entity.LocalScale.y; var sizeOffset = CoreUtilities.GetWorldSpaceSize(newBounds, entity.collider as BoxCollider2D, 0.5f).x; var checkDistance = newBounds.x; var hitLeft = entity.Check(Constants.Directions.LEFT, checkDistance); var hitRight = entity.Check(Constants.Directions.RIGHT, checkDistance); if (hitLeft) { crouchPosition.x = hitLeft.point.x + sizeOffset; } if (hitRight) { crouchPosition.x = hitRight.point.x - sizeOffset; } entity.SetLocalScale(newBounds); entity.SetPosition(crouchPosition); FlagsHelper.Set(ref state, State.CROUCH); } } if (!input.held.jump) { additiveJumpFrameCount = 0; jumpCount = 0; } // Jump if (input.pressed.jump) { if (jumpCount < data.jumpCountMax) { resolvedVelocity.y = data.velocityJumpImpulse; jumpCount++; } } entity.SetVelocity(resolvedVelocity); }
void OnSceneLoading(Scene scene, LoadSceneMode mode) { FlagsHelper.Set(ref currentState, GameState.gameReloaded); }