public ThroughputI() { _byteSeq = new byte[ByteSeqSize.value]; _stringSeq = new string[StringSeqSize.value]; for(int i = 0; i < StringSeqSize.value; ++i) { _stringSeq[i] = "hello"; } _structSeq = new StringDouble[StringDoubleSeqSize.value]; for(int i = 0; i < StringDoubleSeqSize.value; ++i) { _structSeq[i] = new StringDouble(); _structSeq[i].s = "hello"; _structSeq[i].d = 3.14; } _fixedSeq = new Fixed[FixedSeqSize.value]; for(int i = 0; i < FixedSeqSize.value; ++i) { _fixedSeq[i].i = 0; _fixedSeq[i].j = 0; _fixedSeq[i].d = 0; } }
public static void clearCache() { cache.clear(); Fixed.clearCache(); }
public override void Run() { SectorActionResult result; var sa = this.world.SectorAction; switch (this.direction) { case 0: // In statis. break; case 1: // Up. result = sa.MovePlane(this.sector, this.speed, this.topHeight, false, 1, this.direction); if ((this.world.LevelTime & 7) == 0) { switch (this.type) { case CeilingMoveType.SilentCrushAndRaise: break; default: this.world.StartSound(this.sector.SoundOrigin, Sfx.STNMOV, SfxType.Misc); break; } } if (result == SectorActionResult.PastDestination) { switch (this.type) { case CeilingMoveType.RaiseToHighest: sa.RemoveActiveCeiling(this); break; case CeilingMoveType.SilentCrushAndRaise: case CeilingMoveType.FastCrushAndRaise: case CeilingMoveType.CrushAndRaise: if (this.type == CeilingMoveType.SilentCrushAndRaise) { this.world.StartSound(this.sector.SoundOrigin, Sfx.PSTOP, SfxType.Misc); } this.direction = -1; break; default: break; } } break; case -1: // Down. result = sa.MovePlane(this.sector, this.speed, this.bottomHeight, this.crush, 1, this.direction); if ((this.world.LevelTime & 7) == 0) { switch (this.type) { case CeilingMoveType.SilentCrushAndRaise: break; default: this.world.StartSound(this.sector.SoundOrigin, Sfx.STNMOV, SfxType.Misc); break; } } if (result == SectorActionResult.PastDestination) { switch (this.type) { case CeilingMoveType.SilentCrushAndRaise: case CeilingMoveType.CrushAndRaise: case CeilingMoveType.FastCrushAndRaise: if (this.type == CeilingMoveType.SilentCrushAndRaise) { this.world.StartSound(this.sector.SoundOrigin, Sfx.PSTOP, SfxType.Misc); } if (this.type == CeilingMoveType.CrushAndRaise) { this.speed = SectorAction.CeilingSpeed; } this.direction = 1; break; case CeilingMoveType.LowerAndCrush: case CeilingMoveType.LowerToFloor: sa.RemoveActiveCeiling(this); break; default: break; } } else { if (result == SectorActionResult.Crushed) { switch (this.type) { case CeilingMoveType.SilentCrushAndRaise: case CeilingMoveType.CrushAndRaise: case CeilingMoveType.LowerAndCrush: this.speed = SectorAction.CeilingSpeed / 8; break; default: break; } } } break; } }
public override object Visit (Fixed fixedStatement) { var result = new FixedStatement (); var location = LocationsBag.GetLocations (fixedStatement); result.AddChild (new CSharpTokenNode (Convert (fixedStatement.loc), FixedStatement.FixedKeywordRole), FixedStatement.FixedKeywordRole); if (location != null) result.AddChild (new CSharpTokenNode (Convert (location [0]), Roles.LPar), Roles.LPar); if (fixedStatement.Variables != null) { var blockVariableDeclaration = fixedStatement.Variables; result.AddChild (ConvertToType (blockVariableDeclaration.TypeExpression), Roles.Type); var varInit = new VariableInitializer (); var initLocation = LocationsBag.GetLocations (blockVariableDeclaration); varInit.AddChild (Identifier.Create (blockVariableDeclaration.Variable.Name, Convert (blockVariableDeclaration.Variable.Location)), Roles.Identifier); if (blockVariableDeclaration.Initializer != null) { if (initLocation != null) varInit.AddChild (new CSharpTokenNode (Convert (initLocation [0]), Roles.Assign), Roles.Assign); varInit.AddChild ((Expression)blockVariableDeclaration.Initializer.Accept (this), Roles.Expression); } result.AddChild (varInit, Roles.Variable); if (blockVariableDeclaration.Declarators != null) { foreach (var decl in blockVariableDeclaration.Declarators) { var loc = LocationsBag.GetLocations (decl); var init = new VariableInitializer (); if (loc != null && loc.Count > 0) result.AddChild (new CSharpTokenNode (Convert (loc [0]), Roles.Comma), Roles.Comma); init.AddChild (Identifier.Create (decl.Variable.Name, Convert (decl.Variable.Location)), Roles.Identifier); if (decl.Initializer != null) { if (loc != null && loc.Count > 1) init.AddChild (new CSharpTokenNode (Convert (loc [1]), Roles.Assign), Roles.Assign); init.AddChild ((Expression)decl.Initializer.Accept (this), Roles.Expression); } else { } result.AddChild (init, Roles.Variable); } } } if (location != null && location.Count > 1) result.AddChild (new CSharpTokenNode (Convert (location [1]), Roles.RPar), Roles.RPar); if (fixedStatement.Statement != null) result.AddChild ((Statement)fixedStatement.Statement.Accept (this), Roles.EmbeddedStatement); return result; }
public virtual void VisitFixed(Fixed Fixed) { if (Fixed == null) return; this.Visit(Fixed.Declarators); this.VisitBlock(Fixed.Body); }
public override Statement VisitFixed(Fixed Fixed) { return Fixed; }
public virtual Statement VisitFixed(Fixed fixed1, Fixed fixed2) { if (fixed1 == null) return null; if (fixed2 == null) { fixed1.Declarators = (Statement)this.Visit(fixed1.Declarators, null); fixed1.Body = this.VisitBlock(fixed1.Body, null); } else { fixed1.Declarators = (Statement)this.Visit(fixed1.Declarators, fixed2.Declarators); fixed1.Body = this.VisitBlock(fixed1.Body, fixed2.Body); } return fixed1; }
/// <summary> /// Attempt to move to a new position, crossing special lines unless /// MobjFlags.Teleport is set. /// </summary> public bool TryMove(Mobj thing, Fixed x, Fixed y) { this.floatOk = false; if (!this.CheckPosition(thing, x, y)) { // Solid wall or thing. return(false); } if ((thing.Flags & MobjFlags.NoClip) == 0) { if (this.currentCeilingZ - this.currentFloorZ < thing.Height) { // Doesn't fit. return(false); } this.floatOk = true; if ((thing.Flags & MobjFlags.Teleport) == 0 && this.currentCeilingZ - thing.Z < thing.Height) { // Mobj must lower itself to fit. return(false); } if ((thing.Flags & MobjFlags.Teleport) == 0 && this.currentFloorZ - thing.Z > Fixed.FromInt(24)) { // Too big a step up. return(false); } if ((thing.Flags & (MobjFlags.DropOff | MobjFlags.Float)) == 0 && this.currentFloorZ - this.currentDropoffZ > Fixed.FromInt(24)) { // Don't stand over a dropoff. return(false); } } // The move is ok, // so link the thing into its new position. this.UnsetThingPosition(thing); var oldx = thing.X; var oldy = thing.Y; thing.FloorZ = this.currentFloorZ; thing.CeilingZ = this.currentCeilingZ; thing.X = x; thing.Y = y; this.SetThingPosition(thing); // If any special lines were hit, do the effect. if ((thing.Flags & (MobjFlags.Teleport | MobjFlags.NoClip)) == 0) { while (this.crossedSpecialCount-- > 0) { // See if the line was crossed. var line = this.crossedSpecials[this.crossedSpecialCount]; var newSide = Geometry.PointOnLineSide(thing.X, thing.Y, line); var oldSide = Geometry.PointOnLineSide(oldx, oldy, line); if (newSide != oldSide) { if (line.Special != 0) { this.world.MapInteraction.CrossSpecialLine(line, oldSide, thing); } } } } return(true); }
/// <summary> /// The MomX / MomY move is bad, so try to slide along a wall. /// Find the first line hit, move flush to it, and slide along it. /// This is a kludgy mess. /// </summary> private void SlideMove(Mobj thing) { var pt = this.world.PathTraversal; this.slideThing = thing; var hitCount = 0; retry: // Don't loop forever. if (++hitCount == 3) { // The move most have hit the middle, so stairstep. this.StairStep(thing); return; } Fixed leadX; Fixed leadY; Fixed trailX; Fixed trailY; // Trace along the three leading corners. if (thing.MomX > Fixed.Zero) { leadX = thing.X + thing.Radius; trailX = thing.X - thing.Radius; } else { leadX = thing.X - thing.Radius; trailX = thing.X + thing.Radius; } if (thing.MomY > Fixed.Zero) { leadY = thing.Y + thing.Radius; trailY = thing.Y - thing.Radius; } else { leadY = thing.Y - thing.Radius; trailY = thing.Y + thing.Radius; } this.bestSlideFrac = Fixed.OnePlusEpsilon; pt.PathTraverse(leadX, leadY, leadX + thing.MomX, leadY + thing.MomY, PathTraverseFlags.AddLines, this.slideTraverseFunc); pt.PathTraverse(trailX, leadY, trailX + thing.MomX, leadY + thing.MomY, PathTraverseFlags.AddLines, this.slideTraverseFunc); pt.PathTraverse(leadX, trailY, leadX + thing.MomX, trailY + thing.MomY, PathTraverseFlags.AddLines, this.slideTraverseFunc); // Move up to the wall. if (this.bestSlideFrac == Fixed.OnePlusEpsilon) { // The move most have hit the middle, so stairstep. this.StairStep(thing); return; } // Fudge a bit to make sure it doesn't hit. this.bestSlideFrac = new Fixed(this.bestSlideFrac.Data - 0x800); if (this.bestSlideFrac > Fixed.Zero) { var newX = thing.MomX * this.bestSlideFrac; var newY = thing.MomY * this.bestSlideFrac; if (!this.TryMove(thing, thing.X + newX, thing.Y + newY)) { // The move most have hit the middle, so stairstep. this.StairStep(thing); return; } } // Now continue along the wall. // First calculate remainder. this.bestSlideFrac = new Fixed(Fixed.FracUnit - (this.bestSlideFrac.Data + 0x800)); if (this.bestSlideFrac > Fixed.One) { this.bestSlideFrac = Fixed.One; } if (this.bestSlideFrac <= Fixed.Zero) { return; } this.slideMoveX = thing.MomX * this.bestSlideFrac; this.slideMoveY = thing.MomY * this.bestSlideFrac; // Clip the moves. this.HitSlideLine(this.bestSlideLine); thing.MomX = this.slideMoveX; thing.MomY = this.slideMoveY; if (!this.TryMove(thing, thing.X + this.slideMoveX, thing.Y + this.slideMoveY)) { goto retry; } }
private bool CheckThing(Mobj thing) { if ((thing.Flags & (MobjFlags.Solid | MobjFlags.Special | MobjFlags.Shootable)) == 0) { return(true); } var blockDist = thing.Radius + this.currentThing.Radius; if (Fixed.Abs(thing.X - this.currentX) >= blockDist || Fixed.Abs(thing.Y - this.currentY) >= blockDist) { // Didn't hit it. return(true); } // Don't clip against self. if (thing == this.currentThing) { return(true); } // Check for skulls slamming into things. if ((this.currentThing.Flags & MobjFlags.SkullFly) != 0) { var damage = ((this.world.Random.Next() % 8) + 1) * this.currentThing.Info.Damage; this.world.ThingInteraction.DamageMobj(thing, this.currentThing, this.currentThing, damage); this.currentThing.Flags &= ~MobjFlags.SkullFly; this.currentThing.MomX = this.currentThing.MomY = this.currentThing.MomZ = Fixed.Zero; this.currentThing.SetState(this.currentThing.Info.SpawnState); // Stop moving. return(false); } // Missiles can hit other things. if ((this.currentThing.Flags & MobjFlags.Missile) != 0) { // See if it went over / under. if (this.currentThing.Z > thing.Z + thing.Height) { // Overhead. return(true); } if (this.currentThing.Z + this.currentThing.Height < thing.Z) { // Underneath. return(true); } if (this.currentThing.Target != null && (this.currentThing.Target.Type == thing.Type || (this.currentThing.Target.Type == MobjType.Knight && thing.Type == MobjType.Bruiser) || (this.currentThing.Target.Type == MobjType.Bruiser && thing.Type == MobjType.Knight))) { // Don't hit same species as originator. if (thing == this.currentThing.Target) { return(true); } if (thing.Type != MobjType.Player) { // Explode, but do no damage. // Let players missile other players. return(false); } } if ((thing.Flags & MobjFlags.Shootable) == 0) { // Didn't do any damage. return((thing.Flags & MobjFlags.Solid) == 0); } // Damage / explode. var damage = ((this.world.Random.Next() % 8) + 1) * this.currentThing.Info.Damage; this.world.ThingInteraction.DamageMobj(thing, this.currentThing, this.currentThing.Target, damage); // Don't traverse any more. return(false); } // Check for special pickup. if ((thing.Flags & MobjFlags.Special) != 0) { var solid = (thing.Flags & MobjFlags.Solid) != 0; if ((this.currentFlags & MobjFlags.PickUp) != 0) { // Can remove thing. this.world.ItemPickup.TouchSpecialThing(thing, this.currentThing); } return(!solid); } return((thing.Flags & MobjFlags.Solid) == 0); }
/// <summary> /// This is purely informative, nothing is modified /// (except things picked up). /// /// In: /// A Mobj (can be valid or invalid) /// A position to be checked /// (doesn't need to be related to the mobj.X and Y) /// /// During: /// Special things are touched if MobjFlags.PickUp /// Early out on solid lines? /// /// Out: /// New subsector /// CurrentFloorZ /// CurrentCeilingZ /// CurrentDropoffZ /// The lowest point contacted /// (monsters won't move to a dropoff) /// crossedSpecials[] /// crossedSpecialCount /// </summary> public bool CheckPosition(Mobj thing, Fixed x, Fixed y) { var map = this.world.Map; var bm = map.BlockMap; this.currentThing = thing; this.currentFlags = thing.Flags; this.currentX = x; this.currentY = y; this.currentBox[Box.Top] = y + this.currentThing.Radius; this.currentBox[Box.Bottom] = y - this.currentThing.Radius; this.currentBox[Box.Right] = x + this.currentThing.Radius; this.currentBox[Box.Left] = x - this.currentThing.Radius; var newSubsector = Geometry.PointInSubsector(x, y, map); this.currentCeilingLine = null; // The base floor / ceiling is from the subsector that contains the point. // Any contacted lines the step closer together will adjust them. this.currentFloorZ = this.currentDropoffZ = newSubsector.Sector.FloorHeight; this.currentCeilingZ = newSubsector.Sector.CeilingHeight; var validCount = this.world.GetNewValidCount(); this.crossedSpecialCount = 0; if ((this.currentFlags & MobjFlags.NoClip) != 0) { return(true); } // Check things first, possibly picking things up. // The bounding box is extended by MaxThingRadius because mobj_ts are grouped into // mapblocks based on their origin point, and can overlap into adjacent blocks by up // to MaxThingRadius units. { var blockX1 = bm.GetBlockX(this.currentBox[Box.Left] - GameConst.MaxThingRadius); var blockX2 = bm.GetBlockX(this.currentBox[Box.Right] + GameConst.MaxThingRadius); var blockY1 = bm.GetBlockY(this.currentBox[Box.Bottom] - GameConst.MaxThingRadius); var blockY2 = bm.GetBlockY(this.currentBox[Box.Top] + GameConst.MaxThingRadius); for (var bx = blockX1; bx <= blockX2; bx++) { for (var by = blockY1; by <= blockY2; by++) { if (!map.BlockMap.IterateThings(bx, by, this.checkThingFunc)) { return(false); } } } } // Check lines. { var blockX1 = bm.GetBlockX(this.currentBox[Box.Left]); var blockX2 = bm.GetBlockX(this.currentBox[Box.Right]); var blockY1 = bm.GetBlockY(this.currentBox[Box.Bottom]); var blockY2 = bm.GetBlockY(this.currentBox[Box.Top]); for (var bx = blockX1; bx <= blockX2; bx++) { for (var by = blockY1; by <= blockY2; by++) { if (!map.BlockMap.IterateLines(bx, by, this.checkLineFunc, validCount)) { return(false); } } } } return(true); }
/// <summary> /// Adjusts currentFloorZ and currentCeilingZ as lines are contacted. /// </summary> private bool CheckLine(LineDef line) { var mc = this.world.MapCollision; if (this.currentBox.Right() <= line.BoundingBox.Left() || this.currentBox.Left() >= line.BoundingBox.Right() || this.currentBox.Top() <= line.BoundingBox.Bottom() || this.currentBox.Bottom() >= line.BoundingBox.Top()) { return(true); } if (Geometry.BoxOnLineSide(this.currentBox, line) != -1) { return(true); } // A line has been hit. // // The moving thing's destination position will cross the given line. // If this should not be allowed, return false. // If the line is special, keep track of it to process later if the move is proven ok. // // NOTE: // specials are NOT sorted by order, so two special lines that are only 8 pixels // apart could be crossed in either order. if (line.BackSector == null) { // One sided line. return(false); } if ((this.currentThing.Flags & MobjFlags.Missile) == 0) { if ((line.Flags & LineFlags.Blocking) != 0) { // Explicitly blocking everything. return(false); } if (this.currentThing.Player == null && (line.Flags & LineFlags.BlockMonsters) != 0) { // Block monsters only. return(false); } } // Set openrange, opentop, openbottom. mc.LineOpening(line); // Adjust floor / ceiling heights. if (mc.OpenTop < this.currentCeilingZ) { this.currentCeilingZ = mc.OpenTop; this.currentCeilingLine = line; } if (mc.OpenBottom > this.currentFloorZ) { this.currentFloorZ = mc.OpenBottom; } if (mc.LowFloor < this.currentDropoffZ) { this.currentDropoffZ = mc.LowFloor; } // If contacted a special line, add it to the list. if (line.Special != 0) { this.crossedSpecials[this.crossedSpecialCount] = line; this.crossedSpecialCount++; } return(true); }
public BuiltInFunctions() { // Text Functions["len"] = new Len(); Functions["lower"] = new Lower(); Functions["upper"] = new Upper(); Functions["left"] = new Left(); Functions["right"] = new Right(); Functions["mid"] = new Mid(); Functions["replace"] = new Replace(); Functions["rept"] = new Rept(); Functions["substitute"] = new Substitute(); Functions["concatenate"] = new Concatenate(); Functions["char"] = new CharFunction(); Functions["exact"] = new Exact(); Functions["find"] = new Find(); Functions["fixed"] = new Fixed(); Functions["proper"] = new Proper(); Functions["text"] = new Text.Text(); Functions["t"] = new T(); Functions["hyperlink"] = new Hyperlink(); // Numbers Functions["int"] = new CInt(); // Math Functions["abs"] = new Abs(); Functions["asin"] = new Asin(); Functions["asinh"] = new Asinh(); Functions["cos"] = new Cos(); Functions["cosh"] = new Cosh(); Functions["power"] = new Power(); Functions["sign"] = new Sign(); Functions["sqrt"] = new Sqrt(); Functions["sqrtpi"] = new SqrtPi(); Functions["pi"] = new Pi(); Functions["product"] = new Product(); Functions["ceiling"] = new Ceiling(); Functions["count"] = new Count(); Functions["counta"] = new CountA(); Functions["countblank"] = new CountBlank(); Functions["countif"] = new CountIf(); Functions["countifs"] = new CountIfs(); Functions["fact"] = new Fact(); Functions["floor"] = new Floor(); Functions["sin"] = new Sin(); Functions["sinh"] = new Sinh(); Functions["sum"] = new Sum(); Functions["sumif"] = new SumIf(); Functions["sumifs"] = new SumIfs(); Functions["sumproduct"] = new SumProduct(); Functions["sumsq"] = new Sumsq(); Functions["stdev"] = new Stdev(); Functions["stdevp"] = new StdevP(); Functions["stdev.s"] = new Stdev(); Functions["stdev.p"] = new StdevP(); Functions["subtotal"] = new Subtotal(); Functions["exp"] = new Exp(); Functions["log"] = new Log(); Functions["log10"] = new Log10(); Functions["ln"] = new Ln(); Functions["max"] = new Max(); Functions["maxa"] = new Maxa(); Functions["median"] = new Median(); Functions["min"] = new Min(); Functions["mina"] = new Mina(); Functions["mod"] = new Mod(); Functions["average"] = new Average(); Functions["averagea"] = new AverageA(); Functions["averageif"] = new AverageIf(); Functions["averageifs"] = new AverageIfs(); Functions["round"] = new Round(); Functions["rounddown"] = new Rounddown(); Functions["roundup"] = new Roundup(); Functions["rand"] = new Rand(); Functions["randbetween"] = new RandBetween(); Functions["quotient"] = new Quotient(); Functions["trunc"] = new Trunc(); Functions["tan"] = new Tan(); Functions["tanh"] = new Tanh(); Functions["atan"] = new Atan(); Functions["atan2"] = new Atan2(); Functions["atanh"] = new Atanh(); Functions["acos"] = new Acos(); Functions["acosh"] = new Acosh(); Functions["var"] = new Var(); Functions["varp"] = new VarP(); Functions["large"] = new Large(); Functions["small"] = new Small(); Functions["degrees"] = new Degrees(); // Information Functions["isblank"] = new IsBlank(); Functions["isnumber"] = new IsNumber(); Functions["istext"] = new IsText(); Functions["isnontext"] = new IsNonText(); Functions["iserror"] = new IsError(); Functions["iserr"] = new IsErr(); Functions["error.type"] = new ErrorType(); Functions["iseven"] = new IsEven(); Functions["isodd"] = new IsOdd(); Functions["islogical"] = new IsLogical(); Functions["isna"] = new IsNa(); Functions["na"] = new Na(); Functions["n"] = new N(); // Logical Functions["if"] = new If(); Functions["iferror"] = new IfError(); Functions["ifna"] = new IfNa(); Functions["not"] = new Not(); Functions["and"] = new And(); Functions["or"] = new Or(); Functions["true"] = new True(); Functions["false"] = new False(); // Reference and lookup Functions["address"] = new Address(); Functions["hlookup"] = new HLookup(); Functions["vlookup"] = new VLookup(); Functions["lookup"] = new Lookup(); Functions["match"] = new Match(); Functions["row"] = new Row() { SkipArgumentEvaluation = true }; Functions["rows"] = new Rows() { SkipArgumentEvaluation = true }; Functions["column"] = new Column() { SkipArgumentEvaluation = true }; Functions["columns"] = new Columns() { SkipArgumentEvaluation = true }; Functions["choose"] = new Choose(); Functions["index"] = new Index(); Functions["indirect"] = new Indirect(); Functions["offset"] = new Offset() { SkipArgumentEvaluation = true }; // Date Functions["date"] = new Date(); Functions["today"] = new Today(); Functions["now"] = new Now(); Functions["day"] = new Day(); Functions["month"] = new Month(); Functions["year"] = new Year(); Functions["time"] = new Time(); Functions["hour"] = new Hour(); Functions["minute"] = new Minute(); Functions["second"] = new Second(); Functions["weeknum"] = new Weeknum(); Functions["weekday"] = new Weekday(); Functions["days360"] = new Days360(); Functions["yearfrac"] = new Yearfrac(); Functions["edate"] = new Edate(); Functions["eomonth"] = new Eomonth(); Functions["isoweeknum"] = new IsoWeekNum(); Functions["workday"] = new Workday(); }
public void Init() { gtkWin = new Window("DRAL Retag"); var size = gtkWin.Display.PrimaryMonitor.Workarea.Size; Image <Pixel> icon = new Image <Pixel>(32, 32); icon.ApplyFilter((_, _2) => Pixels.Black); Graphics.FromImage(icon).DrawString("DR", new FontSize(BaseFonts.Premia, 2), Pixels.Red, 0, 0); Graphics.FromImage(icon).DrawString("AL", new FontSize(BaseFonts.Premia, 2), Pixels.Red, 0, 16); gtkWin.Icon = GtkWrapper.ToPixbuf(icon); gtkWin.Resize(size.Width, size.Height); //Wfrm = 13/9 of Wimg //Wimg = 9*Wfrm/13 int maxImageWidth = 9 * size.Width / 13; int maxImageHeight = size.Height - 100; int maxImageWidthTakingImageHeight = maxImageHeight * 4 / 3; int maxImageHeightTakingImageWidth = maxImageWidth * 3 / 4; var imageWidth = Math.Min(maxImageWidth, maxImageWidthTakingImageHeight); var imageHeight = Math.Min(maxImageHeight, maxImageHeightTakingImageWidth); Box bx = new Box(Orientation.Vertical, 1); Box menu = new Box(Orientation.Horizontal, 1); Button buttonLoadLabels = new Button() { Label = "Load labels" }; buttonLoadLabels.Clicked += ButtonLoadLabels_Clicked; menu.Add(buttonLoadLabels); buttons.Add(buttonLoadLabels); Button buttonLoadImages = new Button() { Label = "Load Image" }; buttonLoadImages.Clicked += ButtonLoadImages_Clicked; menu.Add(buttonLoadImages); buttons.Add(buttonLoadImages); Button buttonSave = new Button() { Label = "Save" }; buttonSave.Clicked += ButtonSave_Clicked; menu.Add(buttonSave); buttons.Add(buttonSave); Button btnFixMissing = new Button() { Label = "Repair Dataset" }; btnFixMissing.Clicked += BtnFixMissing_Clicked; menu.Add(btnFixMissing); buttons.Add(btnFixMissing); chkGenNow = new CheckButton("Generate now"); chkGenNow.Active = true; menu.Add(chkGenNow); lblCount = new Label("0"); menu.Add(lblCount); Label lblImageInTraining = new Label("images in training"); menu.Add(lblImageInTraining); Box bottom = new Box(Orientation.Horizontal, 1); EventBox evt = new EventBox(); left = new Fixed(); evt.Add(left); pictureBox = new FixedSizeImage(new MoyskleyTech.ImageProcessing.Image.Size(imageWidth, imageHeight)); pictureBox.WidthRequest = imageWidth; left.Put(pictureBox, 0, 0); evt.AddEvents((int)Gdk.EventMask.AllEventsMask); evt.MotionNotifyEvent += Left_MotionNotifyEvent; evt.ButtonPressEvent += Evt_ButtonPressEvent; evt.ButtonReleaseEvent += Evt_ButtonReleaseEvent; right = new Box(Orientation.Vertical, 1); right.WidthRequest = 200; var siz = new MoyskleyTech.ImageProcessing.Image.Size(imageWidth * 4 / 9, imageHeight / 3); iOri = new FixedSizeImage(siz); iActivated = new FixedSizeImage(siz); iActivation = new FixedSizeImage(siz); right.Add(iOri); right.Add(iActivated); right.Add(iActivation); rectangle_top = new DrawingArea(); rectangle_left = new DrawingArea(); rectangle_right = new DrawingArea(); rectangle_bottom = new DrawingArea(); rectangle_top.Drawn += Black_Drawn; rectangle_left.Drawn += Black_Drawn; rectangle_right.Drawn += Black_Drawn; rectangle_bottom.Drawn += Black_Drawn; viewCircle = new DrawingArea(); viewCircle.WidthRequest = windowSize; viewCircle.HeightRequest = windowSize; viewCircle.Drawn += Da_Drawn; left.Put(rectangle_top, 0, 0); left.Put(rectangle_left, 0, 0); left.Put(rectangle_right, 0, 0); left.Put(rectangle_bottom, 0, 0); left.Put(viewCircle, 0, 0); bottom.Add(evt); bottom.Add(right); menu.HeightRequest = 30; bx.Add(menu); bx.Add(bottom); gtkWin.KeyPressEvent += GtkWin_KeyPressEvent; gtkWin.Add(bx); //Show Everything gtkWin.DeleteEvent += delegate { Application.Quit(); }; }
static void Main(string[] args) { Console.WriteLine("Q24_8:"); { var f1 = new Fixed <Q24_8>(3); Console.WriteLine($"3: {f1}"); var f2 = new Fixed <Q24_8>(2); var f3 = f1.Add(f2); Console.WriteLine($"3 + 2: {f3}"); f3 = f1.Multiply(f2); Console.WriteLine($"3 * 2: {f3}"); f1 = new Fixed <Q24_8>(19); f2 = new Fixed <Q24_8>(13); f3 = f1.Multiply(f2); Console.WriteLine($"19 * 13: {f3}"); f1 = new Fixed <Q24_8>(3); f2 = new Fixed <Q24_8>(2); f3 = f1.Divide(f2); Console.WriteLine($"3 / 2: {f3}"); f1 = new Fixed <Q24_8>(248); f2 = new Fixed <Q24_8>(10); f3 = f1.Divide(f2); Console.WriteLine($"248 / 10: {f3}"); f1 = new Fixed <Q24_8>(625); f2 = new Fixed <Q24_8>(1000); f3 = f1.Divide(f2); Console.WriteLine($"625 / 1000: {f3}"); } // Console.WriteLine(); Console.WriteLine("Q16_16:"); { var f1 = new Fixed <Q16_16>(3); Console.WriteLine($"3: {f1}"); var f2 = new Fixed <Q16_16>(2); var f3 = f1.Add(f2); Console.WriteLine($"3 + 2: {f3}"); f3 = f1.Multiply(f2); Console.WriteLine($"3 * 2: {f3}"); f1 = new Fixed <Q16_16>(19); f2 = new Fixed <Q16_16>(13); f3 = f1.Multiply(f2); Console.WriteLine($"19 * 13: {f3}"); f1 = new Fixed <Q16_16>(248); f2 = new Fixed <Q16_16>(10); f3 = f1.Divide(f2); Console.WriteLine($"248 / 10: {f3}"); f1 = new Fixed <Q16_16>(625); f2 = new Fixed <Q16_16>(1000); f3 = f1.Divide(f2); Console.WriteLine($"625 / 1000: {f3}"); } // Console.WriteLine(); Console.WriteLine("Q8_24:"); { var f1 = new Fixed <Q8_24>(3); var f2 = new Fixed <Q8_24>(2); var f3 = f1.Add(f2); Console.WriteLine($"3 + 2: {f3}"); f3 = f1.Multiply(f2); Console.WriteLine($"3 * 2: {f3}"); f1 = new Fixed <Q8_24>(19); f2 = new Fixed <Q8_24>(13); f3 = f1.Multiply(f2); Console.WriteLine($"19 * 13: {f3}"); f1 = new Fixed <Q8_24>(248); f2 = new Fixed <Q8_24>(10); f3 = f1.Divide(f2); Console.WriteLine($"248 / 10: {f3}"); f1 = new Fixed <Q8_24>(625); f2 = new Fixed <Q8_24>(1000); f3 = f1.Divide(f2); Console.WriteLine($"625 / 1000: {f3}"); } }
public static Action im(CPU cpu, Fixed o) => () => cpu.interruptMode = o.Target;
public override Statement VisitFixed(Fixed Fixed){ if (Fixed == null) return null; Block result = new Block(new StatementList()); LocalDeclarationsStatement locStat = Fixed.Declarators as LocalDeclarationsStatement; if (locStat == null) return null; LocalDeclarationList locDecList = locStat.Declarations; for (int i = 0, n = locDecList == null ? 0 : locDecList.Count; i < n; i++){ LocalDeclaration locDec = locDecList[i]; if (locDec == null) continue; Field f = locDec.Field; if (f == null || f.Initializer == null) continue; TypeNode t = f.Type; if (t == null) continue; bool noPinning = false; // NOTE: fixed pointer locals have type pinned T& not T* Pointer declaredPointerType = t as Pointer; if (declaredPointerType != null) { UnaryExpression arrayAddressOfElem0 = f.Initializer as UnaryExpression; if (arrayAddressOfElem0 != null && arrayAddressOfElem0.Operand is Indexer) { Indexer arrayElem0 = (Indexer)arrayAddressOfElem0.Operand; if (arrayElem0.ArgumentListIsIncomplete) { // Using IsIncomplete is the hacky way in which the Checker transmits to the normalizer that the right // hand of the fixed declaration was just an array and that the compiler added &arr[0]. // Now we need to do 2 more things: check that arr is not null and that arr.Length > 0. Expression array = arrayElem0.Object; Local arrayLocal = new Local(array.Type); Statement assignment = new AssignmentStatement(arrayLocal, array, array.SourceContext); arrayElem0.Object = arrayLocal; BinaryExpression arrayIsNull = new BinaryExpression(arrayLocal, Literal.Null, NodeType.Eq); Expression arrayLength = new UnaryExpression(arrayLocal, NodeType.Ldlen, SystemTypes.Int32); BinaryExpression arrayIsEmpty = new BinaryExpression(arrayLength, Literal.Int32Zero, NodeType.Eq); TernaryExpression cond1 = new TernaryExpression(arrayIsEmpty, Literal.Null, arrayAddressOfElem0, NodeType.Conditional, t); TernaryExpression cond2 = new TernaryExpression(arrayIsNull, Literal.Null, cond1, NodeType.Conditional, t); StatementList statements = new StatementList(assignment, new ExpressionStatement(cond2)); f.Initializer = new BlockExpression(new Block(statements), t); } } else if (f.Initializer.Type == SystemTypes.String) { Debug.Assert(((Pointer)t).ElementType == SystemTypes.Char); Local pinnedString = new Local(SystemTypes.String); pinnedString.Pinned = true; Statement assignment = new AssignmentStatement(pinnedString, f.Initializer, f.Initializer.SourceContext); BinaryExpression stringIsNull = new BinaryExpression(pinnedString, Literal.Null, NodeType.Eq); Expression call = new MethodCall(new MemberBinding(null, Runtime.GetOffsetToStringData), null, NodeType.Call); Expression add = new BinaryExpression(new UnaryExpression(pinnedString, NodeType.Conv_I), new UnaryExpression(call, NodeType.Conv_I), NodeType.Add); TernaryExpression cond = new TernaryExpression(stringIsNull, Literal.Null, add, NodeType.Conditional, t); StatementList statements = new StatementList(assignment, new ExpressionStatement(cond)); f.Initializer = new BlockExpression(new Block(statements), t); noPinning = true; } } f.Flags &= ~FieldFlags.InitOnly; AssignmentStatement aStat = new AssignmentStatement(new MemberBinding(new ImplicitThis(), f), f.Initializer); aStat.SourceContext = f.Initializer.SourceContext; result.Statements.Add((Statement)this.Visit(aStat)); LocalBinding lb = aStat.Target as LocalBinding; if (lb != null && !noPinning) { f.Type = declaredPointerType.ElementType.GetReferenceType(); // must be declared as a pinned T& lb.BoundLocal.Pinned = true; lb.BoundLocal.Type = f.Type; } } result.Statements.Add(this.VisitBlock(Fixed.Body)); return result; }
/// <summary> /// Check for item pickup. /// </summary> public void TouchSpecialThing(Mobj special, Mobj toucher) { var delta = special.Z - toucher.Z; if (delta > toucher.Height || delta < Fixed.FromInt(-8)) { // Out of reach. return; } var sound = Sfx.ITEMUP; var player = toucher.Player; // Dead thing touching. // Can happen with a sliding player corpse. if (toucher.Health <= 0) { return; } var healthComponent = player.Entity.GetComponent <Health>(); // Identify by sprite. switch (special.Sprite) { // Armor. case Sprite.ARM1: if (!this.GiveArmor(player, ItemPickup.GreenArmorClass)) { return; } player.SendMessage(DoomInfo.Strings.GOTARMOR); break; case Sprite.ARM2: if (!this.GiveArmor(player, ItemPickup.BlueArmorClass)) { return; } player.SendMessage(DoomInfo.Strings.GOTMEGA); break; // Bonus items. case Sprite.BON1: healthComponent.Current++; if (healthComponent.Current > healthComponent.Info.Maximum) { healthComponent.Current = healthComponent.Info.Maximum; } player.Mobj.Health = healthComponent.Current; player.SendMessage(DoomInfo.Strings.GOTHTHBONUS); break; case Sprite.BON2: // Can go over 100%. player.ArmorPoints++; if (player.ArmorPoints > Player.MaxArmor) { player.ArmorPoints = Player.MaxArmor; } if (player.ArmorType == 0) { player.ArmorType = ItemPickup.GreenArmorClass; } player.SendMessage(DoomInfo.Strings.GOTARMBONUS); break; case Sprite.SOUL: healthComponent.Current += ItemPickup.SoulsphereHealth; if (healthComponent.Current > healthComponent.Info.Maximum) { healthComponent.Current = healthComponent.Info.Maximum; } player.Mobj.Health = healthComponent.Current; player.SendMessage(DoomInfo.Strings.GOTSUPER); sound = Sfx.GETPOW; break; case Sprite.MEGA: if (DoomApplication.Instance.IWad != "doom2" && DoomApplication.Instance.IWad != "freedoom2" && DoomApplication.Instance.IWad != "plutonia" && DoomApplication.Instance.IWad != "tnt") { return; } healthComponent.Current = ItemPickup.MegasphereHealth; player.Mobj.Health = healthComponent.Current; this.GiveArmor(player, ItemPickup.BlueArmorClass); player.SendMessage(DoomInfo.Strings.GOTMSPHERE); sound = Sfx.GETPOW; break; // Cards. // Leave cards for everyone. case Sprite.BKEY: if (player.Entity.GetComponent <InventoryComponent>().TryAdd(EntityInfo.Create <BlueCard>(this.world))) { player.SendMessage(DoomInfo.Strings.GOTBLUECARD); } break; case Sprite.YKEY: if (player.Entity.GetComponent <InventoryComponent>().TryAdd(EntityInfo.Create <YellowCard>(this.world))) { player.SendMessage(DoomInfo.Strings.GOTYELWCARD); } break; case Sprite.RKEY: if (player.Entity.GetComponent <InventoryComponent>().TryAdd(EntityInfo.Create <RedCard>(this.world))) { player.SendMessage(DoomInfo.Strings.GOTREDCARD); } break; case Sprite.BSKU: if (player.Entity.GetComponent <InventoryComponent>().TryAdd(EntityInfo.Create <BlueSkull>(this.world))) { player.SendMessage(DoomInfo.Strings.GOTBLUESKUL); } break; case Sprite.YSKU: if (player.Entity.GetComponent <InventoryComponent>().TryAdd(EntityInfo.Create <YellowSkull>(this.world))) { player.SendMessage(DoomInfo.Strings.GOTYELWSKUL); } break; case Sprite.RSKU: if (player.Entity.GetComponent <InventoryComponent>().TryAdd(EntityInfo.Create <RedSkull>(this.world))) { player.SendMessage(DoomInfo.Strings.GOTREDSKULL); } break; // Medikits, heals. case Sprite.STIM: if (!this.GiveHealth(player, 10)) { return; } player.SendMessage(DoomInfo.Strings.GOTSTIM); break; case Sprite.MEDI: if (!this.GiveHealth(player, 25)) { return; } if (healthComponent.Current < 25) { player.SendMessage(DoomInfo.Strings.GOTMEDINEED); } else { player.SendMessage(DoomInfo.Strings.GOTMEDIKIT); } break; // Power ups. case Sprite.PINV: if (!this.GivePower(player, PowerType.Invulnerability)) { return; } player.SendMessage(DoomInfo.Strings.GOTINVUL); sound = Sfx.GETPOW; break; case Sprite.PSTR: if (!this.GivePower(player, PowerType.Strength)) { return; } player.SendMessage(DoomInfo.Strings.GOTBERSERK); var fists = player.Entity.GetComponent <InventoryComponent>().Items.FirstOrDefault(weapon => weapon.Info is WeaponFists); if (fists != null && player.ReadyWeapon != fists) { player.PendingWeapon = fists; } sound = Sfx.GETPOW; break; case Sprite.PINS: if (!this.GivePower(player, PowerType.Invisibility)) { return; } player.SendMessage(DoomInfo.Strings.GOTINVIS); sound = Sfx.GETPOW; break; case Sprite.SUIT: if (!this.GivePower(player, PowerType.IronFeet)) { return; } player.SendMessage(DoomInfo.Strings.GOTSUIT); sound = Sfx.GETPOW; break; case Sprite.PMAP: if (!this.GivePower(player, PowerType.AllMap)) { return; } player.SendMessage(DoomInfo.Strings.GOTMAP); sound = Sfx.GETPOW; break; case Sprite.PVIS: if (!this.GivePower(player, PowerType.Infrared)) { return; } player.SendMessage(DoomInfo.Strings.GOTVISOR); sound = Sfx.GETPOW; break; // Ammo. case Sprite.CLIP: if ((special.Flags & MobjFlags.Dropped) != 0) { if (!this.GiveAmmo(player, nameof(AmmoBullets), 0)) { return; } } else { if (!this.GiveAmmo(player, nameof(AmmoBullets), 1)) { return; } } player.SendMessage(DoomInfo.Strings.GOTCLIP); break; case Sprite.AMMO: if (!this.GiveAmmo(player, nameof(AmmoBullets), 5)) { return; } player.SendMessage(DoomInfo.Strings.GOTCLIPBOX); break; case Sprite.ROCK: if (!this.GiveAmmo(player, nameof(AmmoRockets), 1)) { return; } player.SendMessage(DoomInfo.Strings.GOTROCKET); break; case Sprite.BROK: if (!this.GiveAmmo(player, nameof(AmmoRockets), 5)) { return; } player.SendMessage(DoomInfo.Strings.GOTROCKBOX); break; case Sprite.CELL: if (!this.GiveAmmo(player, nameof(AmmoCells), 1)) { return; } player.SendMessage(DoomInfo.Strings.GOTCELL); break; case Sprite.CELP: if (!this.GiveAmmo(player, nameof(AmmoCells), 5)) { return; } player.SendMessage(DoomInfo.Strings.GOTCELLBOX); break; case Sprite.SHEL: if (!this.GiveAmmo(player, nameof(AmmoShells), 1)) { return; } player.SendMessage(DoomInfo.Strings.GOTSHELLS); break; case Sprite.SBOX: if (!this.GiveAmmo(player, nameof(AmmoShells), 5)) { return; } player.SendMessage(DoomInfo.Strings.GOTSHELLBOX); break; case Sprite.BPAK: if (!player.Backpack) { // TODO Re-implement this! /*for (var i = 0; i < (int) AmmoType.Count; i++) * { * player.MaxAmmo[i] *= 2; * }*/ player.Backpack = true; } foreach (var entityInfo in EntityInfo.WithComponent <AmmoComponentInfo>()) { this.GiveAmmo(player, entityInfo.Name, 1); } player.SendMessage(DoomInfo.Strings.GOTBACKPACK); break; // Weapons. case Sprite.BFUG: if (!this.GiveWeapon(player, nameof(WeaponBfg), false)) { return; } player.SendMessage(DoomInfo.Strings.GOTBFG9000); sound = Sfx.WPNUP; break; case Sprite.MGUN: if (!this.GiveWeapon(player, nameof(WeaponChaingun), (special.Flags & MobjFlags.Dropped) != 0)) { return; } player.SendMessage(DoomInfo.Strings.GOTCHAINGUN); sound = Sfx.WPNUP; break; case Sprite.CSAW: if (!this.GiveWeapon(player, nameof(WeaponChainsaw), false)) { return; } player.SendMessage(DoomInfo.Strings.GOTCHAINSAW); sound = Sfx.WPNUP; break; case Sprite.LAUN: if (!this.GiveWeapon(player, nameof(WeaponRocketLauncher), false)) { return; } player.SendMessage(DoomInfo.Strings.GOTLAUNCHER); sound = Sfx.WPNUP; break; case Sprite.PLAS: if (!this.GiveWeapon(player, nameof(WeaponPlasmagun), false)) { return; } player.SendMessage(DoomInfo.Strings.GOTPLASMA); sound = Sfx.WPNUP; break; case Sprite.SHOT: if (!this.GiveWeapon(player, nameof(WeaponShotgun), (special.Flags & MobjFlags.Dropped) != 0)) { return; } player.SendMessage(DoomInfo.Strings.GOTSHOTGUN); sound = Sfx.WPNUP; break; case Sprite.SGN2: if (!this.GiveWeapon(player, nameof(WeaponSuperShotgun), (special.Flags & MobjFlags.Dropped) != 0)) { return; } player.SendMessage(DoomInfo.Strings.GOTSHOTGUN2); sound = Sfx.WPNUP; break; default: throw new Exception("Unknown gettable thing!"); } if ((special.Flags & MobjFlags.CountItem) != 0) { player.ItemCount++; } this.world.ThingAllocation.RemoveMobj(special); player.BonusCount += ItemPickup.bonusAdd; this.world.StartSound(player.Mobj, sound, SfxType.Misc); }
public static Action res(CPU cpu, Fixed bit, Operand<byte> value) => () => value.Target = Utils.SetBit(value.Target, bit.Target);
private static Fixed Operation(Fixed firstValue, OperationType operationType, Fixed secondValue) => default;
public virtual object Visit (Fixed fixedStatement) { return null; }
private Fixed CalcAbsoluteStats(Fixed @base, Fixed lp, Fixed lf, Fixed arena, Fixed bp, Fixed bf, Fixed ap, Fixed af, Fixed mp, Fixed mf) => default;
void case_1012() #line 6771 "cs-parser.jay" { if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE) Warning_EmptyStatement (GetLocation (yyVals[0+yyTop])); Fixed f = new Fixed ((Fixed.VariableDeclaration) yyVals[-1+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-9+yyTop])); current_block.AddStatement (f); lbag.AddStatement (f, GetLocation (yyVals[-8+yyTop]), GetLocation (yyVals[-2+yyTop])); yyVal = end_block (GetLocation (yyVals[-2+yyTop])); }
private Fixed CalcPercentageStats(Fixed @base, Fixed lp, Fixed lf, Fixed bp, Fixed bf, Fixed ap, Fixed af, Fixed mp, Fixed mf) => default;
public virtual Statement VisitFixed(Fixed Fixed){ if (Fixed == null) return null; Fixed.Declarators = (Statement)this.Visit(Fixed.Declarators); Fixed.Body = this.VisitBlock(Fixed.Body); return Fixed; }
private static Fixed CalcValue(Fixed baseStat, HeroGrade heroGrade, int level) => default;
public void CannotChangeValue() { Fixed f = new Fixed(0x50); f.Target = 0xFF; Assert.Equal(0x50, f.Target); }
public bool AnyLessThan(Fixed value) => default;
public void setSlippageForTest(double newSlippage) { overrideSlippageCalculator(typeof(Fixed)); Fixed.setSlippageForTest(this, newSlippage); }
public bool AnyLessThanOrEqual(Fixed value) => default;
public CalibrationDialog( string name, Window parent, GetCalibrationValueHandler GetCalibrationValue, CalibrationState startingState = CalibrationState.ZeroValue) : base(name + " Calibration", parent, DialogFlags.DestroyWithParent) { Name = "AquaPic.Calibration." + name; WindowPosition = (WindowPosition)4; SetSizeRequest(600, 300); #if RPI_BUILD Decorated = false; ExposeEvent += (o, args) => { using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) { cr.MoveTo(Allocation.Left, Allocation.Top); cr.LineTo(Allocation.Right, Allocation.Top); cr.LineTo(Allocation.Right, Allocation.Bottom); cr.LineTo(Allocation.Left, Allocation.Bottom); cr.ClosePath(); cr.LineWidth = 1.8; TouchColor.SetSource(cr, "grey4"); cr.Stroke(); } }; #endif ModifyBg(StateType.Normal, TouchColor.NewGtkColor("grey0")); foreach (var w in Children) { Remove(w); w.Destroy(); } ExposeEvent += OnExpose; this.GetCalibrationValue = GetCalibrationValue; if ((startingState == CalibrationState.ZeroActual) || (startingState == CalibrationState.ZeroValue)) { calState = startingState; } else { calState = CalibrationState.ZeroValue; } calArgs = new CalibrationArguments(); forced = false; init = false; fix = new Fixed(); fix.SetSizeRequest(600, 300); tv = new TextView(); tv.ModifyFont(Pango.FontDescription.FromString("Sans 11")); tv.ModifyBase(StateType.Normal, TouchColor.NewGtkColor("grey4")); tv.ModifyText(StateType.Normal, TouchColor.NewGtkColor("black")); tv.CanFocus = false; tv.Editable = false; ScrolledWindow sw = new ScrolledWindow(); sw.SetSizeRequest(580, 225); sw.Add(tv); tv.Show(); fix.Put(sw, 10, 25); sw.Show(); var l = new TouchLabel(); l.text = name; l.WidthRequest = 600; l.textAlignment = TouchAlignment.Center; fix.Put(l, 0, 3); l.Show(); valTb = new TouchTextBox(); valTb.SetSizeRequest(110, 30); valTb.textAlignment = TouchAlignment.Center; valTb.backgroundColor = "grey1"; if (calState == CalibrationState.ZeroActual) { valTb.text = "Enter Actual"; valTb.enableTouch = true; valTb.backgroundColor = "grey4"; valTb.TextChangedEvent += OnValueTextBoxTextChanged; } else { valTb.text = GetCalibrationValue().ToString("F2"); } fix.Put(valTb, 10, 260); valTb.Show(); actionBtn = new TouchButton(); actionBtn.SetSizeRequest(150, 30); if (calState == CalibrationState.ZeroActual) { actionBtn.text = "Zero Actual"; } else { actionBtn.text = "Zero Value"; } actionBtn.ButtonReleaseEvent += OnActionButtonReleaseEvent; fix.Put(actionBtn, 440, 260); actionBtn.Show(); var cancelBtn = new TouchButton(); cancelBtn.SetSizeRequest(100, 30); cancelBtn.text = "Cancel"; cancelBtn.buttonColor = "compl"; cancelBtn.ButtonReleaseEvent += (o, args) => Destroy(); fix.Put(cancelBtn, 335, 260); cancelBtn.Show(); skipBtn = new TouchButton(); skipBtn.SetSizeRequest(100, 30); skipBtn.text = "Skip"; skipBtn.buttonColor = "seca"; skipBtn.ButtonReleaseEvent += OnSkipButtonReleaseEvent; fix.Put(skipBtn, 230, 260); skipBtn.Show(); var forceBtn = new TouchButton(); forceBtn.SetSizeRequest(100, 30); forceBtn.text = "Force"; forceBtn.buttonColor = "grey3"; forceBtn.ButtonReleaseEvent += OnForceButtonReleaseEvent; fix.Put(forceBtn, 125, 260); forceBtn.Show(); Add(fix); fix.Show(); timerId = GLib.Timeout.Add(1000, OnUpdateTimer); }
public bool AnyGreaterThan(Fixed value) => default;
public override Statement VisitFixed(Fixed Fixed){ if (Fixed == null) return null; Scope savedScope = this.scope; BlockScope scope = Fixed.ScopeForTemporaryVariables = new BlockScope(savedScope, Fixed.Body); scope.MembersArePinned = true; this.scope = scope; this.AddToAllScopes(scope); Declarer declarer = new Declarer(this.ErrorHandler); declarer.VisitFixed(Fixed, scope); Statement result = base.VisitFixed(Fixed); this.scope = savedScope; return result; }
public void Change(StatKindId statKindId, OperationType operationType, Fixed value) { }
public static Action rst(CPU cpu, Fixed o) => () => cpu.Call(o.Target, 1);
public PosTablesDialog(Window pSourceWindow, DialogFlags pDialogFlags, TableFilterMode pFilterMode = TableFilterMode.Default) : base(pSourceWindow, pDialogFlags) { //Init Local Vars String windowTitle = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_orders"); //TODO:THEME //Size windowSize = new Size(837, 650); Size windowSize = new Size(720, 580); String fileDefaultWindowIcon = string.Empty; /* IN009035 */ String fileActionViewOrders = string.Empty; /* IN008024 */ if (!SettingsApp.IsDefaultTheme) { fileDefaultWindowIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Windows\icon_window_tables_retail.png"); fileActionViewOrders = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\icon_pos_retail_view_order.png"); } else { fileDefaultWindowIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Windows\icon_window_tables.png"); fileActionViewOrders = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\icon_pos_table_view_order.png"); } //ActionArea Icons String fileActionTableReservation = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\icon_pos_table_reservation.png"); String fileActionTableFilterAll = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\icon_pos_table_filter_all.png"); String fileActionTableFilterFree = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\icon_pos_table_filter_free.png"); String fileActionTableFilterOpen = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\icon_pos_table_filter_open.png"); String fileActionTableFilterReserved = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\icon_pos_table_filter_reserved.png"); String fileActionTableViewTables = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\icon_pos_table_view_tables.png"); //Parameters _FilterMode = pFilterMode; //Init Content _fixedContent = new Fixed(); //Init Base Queries _sqlPlaceBase = @" SELECT Oid as id, Designation as name, NULL as label, ButtonImage as image, {0} FROM pos_configurationplace as p WHERE (Disabled IS NULL or Disabled <> 1) "; //Used to filter Places Tab, based o View Mode (Order or Table) _sqlPlaceBaseOrder = string.Format(_sqlPlaceBase, string.Format(@" (SELECT COUNT(*) FROM fin_documentordermain as om LEFT JOIN pos_configurationplacetable as pt ON om.PlaceTable = pt.Oid WHERE (om.OrderStatus = {0} AND pt.Place = p.Oid)) as childs", (int)OrderStatus.Open) ); _sqlPlaceBaseTable = string.Format(_sqlPlaceBase, @"(SELECT COUNT(*) FROM pos_configurationplacetable WHERE (Disabled IS NULL or Disabled <> 1) AND Place = p.Oid) as childs"); //Build TablePads BuildPlace(); BuildOrders(); BuildTable(); //ActionArea Buttons _buttonOk = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Ok); _buttonCancel = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Cancel); //Table Actions _buttonTableReservation = new TouchButtonIconWithText("touchButtonTableReservation_DialogActionArea", _colorBaseDialogActionAreaButtonBackground, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "pos_button_label_table_reservation"), _fontBaseDialogActionAreaButton, _colorBaseDialogActionAreaButtonFont, fileActionTableReservation, _sizeBaseDialogActionAreaButtonIcon, _sizeBaseDialogActionAreaButton.Width, _sizeBaseDialogActionAreaButton.Height) { Sensitive = false }; //Tables _buttonTableFilterAll = new TouchButtonIconWithText("touchButtonTableFilterAll_Green", Color.Transparent, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_orders_button_label_tables_all"), _fontBaseDialogActionAreaButton, _colorBaseDialogActionAreaButtonFont, fileActionTableFilterAll, _sizeBaseDialogActionAreaButtonIcon, _sizeBaseDialogActionAreaButton.Width, _sizeBaseDialogActionAreaButton.Height) { Visible = false, Sensitive = false }; _buttonTableFilterFree = new TouchButtonIconWithText("touchButtonTableFilterFree_Green", Color.Transparent, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_orders_button_label_tables_free"), _fontBaseDialogActionAreaButton, _colorBaseDialogActionAreaButtonFont, fileActionTableFilterFree, _sizeBaseDialogActionAreaButtonIcon, _sizeBaseDialogActionAreaButton.Width, _sizeBaseDialogActionAreaButton.Height) { Visible = false }; _buttonTableFilterOpen = new TouchButtonIconWithText("touchButtonTableFilterOpen_Green", Color.Transparent, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_orders_button_label_tables_open"), _fontBaseDialogActionAreaButton, _colorBaseDialogActionAreaButtonFont, fileActionTableFilterOpen, _sizeBaseDialogActionAreaButtonIcon, _sizeBaseDialogActionAreaButton.Width, _sizeBaseDialogActionAreaButton.Height) { Visible = false }; _buttonTableFilterReserved = new TouchButtonIconWithText("touchButtonTableFilterReserved_Green", Color.Transparent, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_orders_button_label_tables_reserved"), _fontBaseDialogActionAreaButton, _colorBaseDialogActionAreaButtonFont, fileActionTableFilterReserved, _sizeBaseDialogActionAreaButtonIcon, _sizeBaseDialogActionAreaButton.Width, _sizeBaseDialogActionAreaButton.Height) { Visible = false }; //Views _buttonTableViewOrders = new TouchButtonIconWithText("touchButtonViewOrders_Red", Color.Transparent, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_orders_button_label_view_orders"), _fontBaseDialogActionAreaButton, _colorBaseDialogActionAreaButtonFont, fileActionViewOrders, _sizeBaseDialogActionAreaButtonIcon, _sizeBaseDialogActionAreaButton.Width, _sizeBaseDialogActionAreaButton.Height); _buttonTableViewTables = new TouchButtonIconWithText("touchButtonViewTables_Green", Color.Transparent, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_orders_button_label_view_tables"), _fontBaseDialogActionAreaButton, _colorBaseDialogActionAreaButtonFont, fileActionTableViewTables, _sizeBaseDialogActionAreaButtonIcon, _sizeBaseDialogActionAreaButton.Width, _sizeBaseDialogActionAreaButton.Height); //Orders //_buttonOrderChangeTable = new TouchButtonIconWithText("touchButtonOrderChangeTable_Red", Color.Transparent, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "pos_button_label_change_table, _fontBaseDialogActionAreaButton, _colorBaseDialogActionAreaButtonFont, _fileActionDefault, _sizeBaseDialogActionAreaButtonIcon, _sizeBaseDialogActionAreaButton.Width, _sizeBaseDialogActionAreaButton.Height) { Sensitive = false }; //ActionArea ActionAreaButtons actionAreaButtons = new ActionAreaButtons(); //Orders //actionAreaButtons.Add(new ActionAreaButton(_buttonOrderChangeTable, _responseTypeOrderChangeTable)); //Tables if (SettingsApp.IsDefaultTheme)/* IN008024 */ { actionAreaButtons.Add(new ActionAreaButton(_buttonTableFilterAll, (ResponseType)_tablesStatusShowAllIndex)); actionAreaButtons.Add(new ActionAreaButton(_buttonTableFilterFree, (ResponseType)TableStatus.Free)); actionAreaButtons.Add(new ActionAreaButton(_buttonTableFilterOpen, (ResponseType)TableStatus.Open)); actionAreaButtons.Add(new ActionAreaButton(_buttonTableFilterReserved, (ResponseType)TableStatus.Reserved)); //ViewMode actionAreaButtons.Add(new ActionAreaButton(_buttonTableViewOrders, _responseTypeViewOrders)); actionAreaButtons.Add(new ActionAreaButton(_buttonTableViewTables, _responseTypeViewTables)); //Modal Result actionAreaButtons.Add(new ActionAreaButton(_buttonTableReservation, _responseTypeTableReservation)); } actionAreaButtons.Add(new ActionAreaButton(_buttonOk, ResponseType.Ok)); actionAreaButtons.Add(new ActionAreaButton(_buttonCancel, ResponseType.Cancel)); //Init Object this.InitObject(this, pDialogFlags, fileDefaultWindowIcon, windowTitle, windowSize, _fixedContent, actionAreaButtons); this.ExposeEvent += delegate { //Disable Buttons if in OnlyFreeTables FilterMode if (_FilterMode == TableFilterMode.OnlyFreeTables) { //Filter Buttons _buttonTableFilterAll.Visible = false; _buttonTableFilterFree.Visible = false; _buttonTableFilterOpen.Visible = false; _buttonTableFilterReserved.Visible = false; //Other ActionButtons _buttonTableViewOrders.Visible = false; _buttonTableReservation.Visible = false; } }; //After Init, Disabled Widgets ToggleViewMode(); }
public virtual Statement VisitFixed(Fixed Fixed, Class scope) { if (Fixed == null) return null; Class savedScope = this.scope; this.scope = scope; LocalDeclarationsStatement locDecs = Fixed.Declarators as LocalDeclarationsStatement; if (locDecs != null) { locDecs.InitOnly = true; Fixed.Declarators = this.VisitLocalDeclarationsStatement(locDecs); } Fixed.Body = this.VisitBlock(Fixed.Body); this.scope = savedScope; return Fixed; }
public Fixed ReadFixed() { return(Fixed.FromRaw(ReadInt64())); }
public static Action bit(CPU cpu, Fixed bit, Operand<byte> value) => () => { cpu.Zero = Utils.Bit(value.Target, bit.Target); cpu.HalfCarry = true; cpu.AddSub = false; };
public void Update() { if (this.zoomIn) { this.zoom += this.zoom / 16; } if (this.zoomOut) { this.zoom -= this.zoom / 16; } if (this.zoom < Fixed.One / 2) { this.zoom = Fixed.One / 2; } else if (this.zoom > Fixed.One * 32) { this.zoom = Fixed.One * 32; } if (this.left) { this.viewX -= 64 / this.zoom; } if (this.right) { this.viewX += 64 / this.zoom; } if (this.up) { this.viewY += 64 / this.zoom; } if (this.down) { this.viewY -= 64 / this.zoom; } if (this.viewX < this.minX) { this.viewX = this.minX; } else if (this.viewX > this.maxX) { this.viewX = this.maxX; } if (this.viewY < this.minY) { this.viewY = this.minY; } else if (this.viewY > this.maxY) { this.viewY = this.maxY; } if (this.follow) { var player = this.world.ConsolePlayer.Mobj; this.viewX = player.X; this.viewY = player.Y; } }
public override Statement VisitFixed(Fixed Fixed) { if (Fixed == null) return null; return base.VisitFixed((Fixed)Fixed.Clone()); }
/// <summary> /// Fire a hitscan bullet along the aiming line. /// </summary> private bool ShootTraverse(Intercept intercept) { var mi = this.world.MapInteraction; var pt = this.world.PathTraversal; if (intercept.Line != null) { var line = intercept.Line; if (line.Special != 0) { mi.ShootSpecialLine(this.currentShooter, line); } if ((line.Flags & LineFlags.TwoSided) == 0) { goto hitLine; } var mc = this.world.MapCollision; // Crosses a two sided line. mc.LineOpening(line); var dist = this.currentRange * intercept.Frac; // Similar to AimTraverse, the code below is imported from Chocolate Doom. if (line.BackSector == null) { { var slope = (mc.OpenBottom - this.currentShooterZ) / dist; if (slope > this.currentAimSlope) { goto hitLine; } } { var slope = (mc.OpenTop - this.currentShooterZ) / dist; if (slope < this.currentAimSlope) { goto hitLine; } } } else { if (line.FrontSector.FloorHeight != line.BackSector.FloorHeight) { var slope = (mc.OpenBottom - this.currentShooterZ) / dist; if (slope > this.currentAimSlope) { goto hitLine; } } if (line.FrontSector.CeilingHeight != line.BackSector.CeilingHeight) { var slope = (mc.OpenTop - this.currentShooterZ) / dist; if (slope < this.currentAimSlope) { goto hitLine; } } } // Shot continues. return(true); // Hit line. hitLine: // Position a bit closer. var frac = intercept.Frac - Fixed.FromInt(4) / this.currentRange; var x = pt.Trace.X + pt.Trace.Dx * frac; var y = pt.Trace.Y + pt.Trace.Dy * frac; var z = this.currentShooterZ + this.currentAimSlope * (frac * this.currentRange); if (line.FrontSector.CeilingFlat == this.world.Map.SkyFlatNumber) { // Don't shoot the sky! if (z > line.FrontSector.CeilingHeight) { return(false); } // It's a sky hack wall. if (line.BackSector != null && line.BackSector.CeilingFlat == this.world.Map.SkyFlatNumber) { return(false); } } // Spawn bullet puffs. this.SpawnPuff(x, y, z); // Don't go any farther. return(false); } { // Shoot a thing. var thing = intercept.Thing; if (thing == this.currentShooter) { // Can't shoot self. return(true); } if ((thing.Flags & MobjFlags.Shootable) == 0) { // Corpse or something. return(true); } // Check angles to see if the thing can be aimed at. var dist = this.currentRange * intercept.Frac; var thingTopSlope = (thing.Z + thing.Height - this.currentShooterZ) / dist; if (thingTopSlope < this.currentAimSlope) { // Shot over the thing. return(true); } var thingBottomSlope = (thing.Z - this.currentShooterZ) / dist; if (thingBottomSlope > this.currentAimSlope) { // Shot under the thing. return(true); } // Hit thing. // Position a bit closer. var frac = intercept.Frac - Fixed.FromInt(10) / this.currentRange; var x = pt.Trace.X + pt.Trace.Dx * frac; var y = pt.Trace.Y + pt.Trace.Dy * frac; var z = this.currentShooterZ + this.currentAimSlope * (frac * this.currentRange); // Spawn bullet puffs or blod spots, depending on target type. if ((intercept.Thing.Flags & MobjFlags.NoBlood) != 0) { this.SpawnPuff(x, y, z); } else { this.SpawnBlood(x, y, z, this.currentDamage); } if (this.currentDamage != 0) { this.world.ThingInteraction.DamageMobj(thing, this.currentShooter, this.currentShooter, this.currentDamage); } // Don't go any farther. return(false); } }
public override int run(string[] args) { if(args.Length > 0) { Console.Error.WriteLine(appName() + ": too many arguments"); return 1; } ThroughputPrx throughput = ThroughputPrxHelper.checkedCast( communicator().propertyToProxy("Throughput.Proxy")); if(throughput == null) { Console.Error.WriteLine("invalid proxy"); return 1; } ThroughputPrx throughputOneway = ThroughputPrxHelper.uncheckedCast(throughput.ice_oneway()); byte[] byteSeq = new byte[ByteSeqSize.value]; string[] stringSeq = new string[StringSeqSize.value]; for(int i = 0; i < StringSeqSize.value; ++i) { stringSeq[i] = "hello"; } StringDouble[] structSeq = new StringDouble[StringDoubleSeqSize.value]; for(int i = 0; i < StringDoubleSeqSize.value; ++i) { structSeq[i] = new StringDouble(); structSeq[i].s = "hello"; structSeq[i].d = 3.14; } Fixed[] fixedSeq = new Fixed[FixedSeqSize.value]; for(int i = 0; i < FixedSeqSize.value; ++i) { fixedSeq[i].i = 0; fixedSeq[i].j = 0; fixedSeq[i].d = 0; } // // A method needs to be invoked thousands of times before the // JIT compiler will convert it to native code. To ensure an // accurate throughput measurement, we need to "warm up" the // JIT compiler. // { byte[] emptyBytes = new byte[1]; string[] emptyStrings = new string[1]; StringDouble[] emptyStructs = new StringDouble[1]; emptyStructs[0] = new StringDouble(); Fixed[] emptyFixed = new Fixed[1]; throughput.startWarmup(); Console.Error.Write("warming up the client/server..."); Console.Error.Flush(); for(int i = 0; i < 10000; i++) { throughput.sendByteSeq(emptyBytes); throughput.sendStringSeq(emptyStrings); throughput.sendStructSeq(emptyStructs); throughput.sendFixedSeq(emptyFixed); throughput.recvByteSeq(); throughput.recvStringSeq(); throughput.recvStructSeq(); throughput.recvFixedSeq(); throughput.echoByteSeq(emptyBytes); throughput.echoStringSeq(emptyStrings); throughput.echoStructSeq(emptyStructs); throughput.echoFixedSeq(emptyFixed); } throughput.endWarmup(); Console.Error.WriteLine("ok"); } menu(); // // By default use byte sequence. // char currentType = '1'; int seqSize = ByteSeqSize.value; string line = null; do { try { Console.Write("==> "); Console.Out.Flush(); line = Console.In.ReadLine(); if(line == null) { break; } long tmsec = System.DateTime.Now.Ticks / 10000; const int repetitions = 100; if(line.Equals("1") || line.Equals("2") || line.Equals("3") || line.Equals("4")) { currentType = line[0]; switch(currentType) { case '1': { Console.WriteLine("using byte sequences"); seqSize = ByteSeqSize.value; break; } case '2': { Console.WriteLine("using string sequences"); seqSize = StringSeqSize.value; break; } case '3': { Console.WriteLine("using variable-length struct sequences"); seqSize = StringDoubleSeqSize.value; break; } case '4': { Console.WriteLine("using fixed-length struct sequences"); seqSize = FixedSeqSize.value; break; } } } else if(line.Equals("t") || line.Equals("o") || line.Equals("r") || line.Equals("e")) { char c = line[0]; switch (c) { case 't': { Console.Write("sending"); break; } case 'o': { Console.Write("sending"); break; } case 'r': { Console.Write("receiving"); break; } case 'e': { Console.Write("sending and receiving"); break; } } Console.Write(" " + repetitions); switch(currentType) { case '1': { Console.Write(" byte"); break; } case '2': { Console.Write(" string"); break; } case '3': { Console.Write(" variable-length struct"); break; } case '4': { Console.Write(" fixed-length struct"); break; } } Console.Write(" sequences of size " + seqSize); if(c == 'o') { Console.Write(" as oneway"); } Console.WriteLine("..."); for (int i = 0; i < repetitions; ++i) { switch(currentType) { case '1': { switch(c) { case 't': { throughput.sendByteSeq(byteSeq); break; } case 'o': { throughputOneway.sendByteSeq(byteSeq); break; } case 'r': { throughput.recvByteSeq(); break; } case 'e': { throughput.echoByteSeq(byteSeq); break; } } break; } case '2': { switch(c) { case 't': { throughput.sendStringSeq(stringSeq); break; } case 'o': { throughputOneway.sendStringSeq(stringSeq); break; } case 'r': { throughput.recvStringSeq(); break; } case 'e': { throughput.echoStringSeq(stringSeq); break; } } break; } case '3': { switch(c) { case 't': { throughput.sendStructSeq(structSeq); break; } case 'o': { throughputOneway.sendStructSeq(structSeq); break; } case 'r': { throughput.recvStructSeq(); break; } case 'e': { throughput.echoStructSeq(structSeq); break; } } break; } case '4': { switch(c) { case 't': { throughput.sendFixedSeq(fixedSeq); break; } case 'o': { throughputOneway.sendFixedSeq(fixedSeq); break; } case 'r': { throughput.recvFixedSeq(); break; } case 'e': { throughput.echoFixedSeq(fixedSeq); break; } } break; } } } double dmsec = System.DateTime.Now.Ticks / 10000 - tmsec; Console.WriteLine("time for " + repetitions + " sequences: " + dmsec.ToString("F") + "ms"); Console.WriteLine("time per sequence: " + ((double)(dmsec / repetitions)).ToString("F") + "ms"); int wireSize = 0; switch(currentType) { case '1': { wireSize = 1; break; } case '2': { wireSize = stringSeq[0].Length; break; } case '3': { wireSize = structSeq[0].s.Length; wireSize += 8; // Size of double on the wire. break; } case '4': { wireSize = 16; // Sizes of two ints and a double on the wire. break; } } double mbit = repetitions * seqSize * wireSize * 8.0 / dmsec / 1000.0; if(c == 'e') { mbit *= 2; } Console.WriteLine("throughput: " + mbit.ToString("#.##") + "Mbps"); } else if(line.Equals("s")) { throughput.shutdown(); } else if(line.Equals("x")) { // Nothing to do } else if(line.Equals("?")) { menu(); } else { Console.WriteLine("unknown command `" + line + "'"); menu(); } } catch(System.Exception ex) { Console.Error.WriteLine(ex); } } while(!line.Equals("x")); return 0; }
/// <summary> /// Find a thing or wall which is on the aiming line. /// Sets lineTaget and aimSlope when a target is aimed at. /// </summary> private bool AimTraverse(Intercept intercept) { if (intercept.Line != null) { var line = intercept.Line; if ((line.Flags & LineFlags.TwoSided) == 0) { // Stop. return(false); } var mc = this.world.MapCollision; // Crosses a two sided line. // A two sided line will restrict the possible target ranges. mc.LineOpening(line); if (mc.OpenBottom >= mc.OpenTop) { // Stop. return(false); } var dist = this.currentRange * intercept.Frac; // The null check of the backsector below is necessary to avoid crash // in certain PWADs, which contain two-sided lines with no backsector. // These are imported from Chocolate Doom. if (line.BackSector == null || line.FrontSector.FloorHeight != line.BackSector.FloorHeight) { var slope = (mc.OpenBottom - this.currentShooterZ) / dist; if (slope > this.bottomSlope) { this.bottomSlope = slope; } } if (line.BackSector == null || line.FrontSector.CeilingHeight != line.BackSector.CeilingHeight) { var slope = (mc.OpenTop - this.currentShooterZ) / dist; if (slope < this.topSlope) { this.topSlope = slope; } } if (this.topSlope <= this.bottomSlope) { // Stop. return(false); } // Shot continues. return(true); } // Shoot a thing. var thing = intercept.Thing; if (thing == this.currentShooter) { // Can't shoot self. return(true); } { if ((thing.Flags & MobjFlags.Shootable) == 0) { // Corpse or something. return(true); } // Check angles to see if the thing can be aimed at. var dist = this.currentRange * intercept.Frac; var thingTopSlope = (thing.Z + thing.Height - this.currentShooterZ) / dist; if (thingTopSlope < this.bottomSlope) { // Shot over the thing. return(true); } var thingBottomSlope = (thing.Z - this.currentShooterZ) / dist; if (thingBottomSlope > this.topSlope) { // Shot under the thing. return(true); } // This thing can be hit! if (thingTopSlope > this.topSlope) { thingTopSlope = this.topSlope; } if (thingBottomSlope < this.bottomSlope) { thingBottomSlope = this.bottomSlope; } this.currentAimSlope = (thingTopSlope + thingBottomSlope) / 2; this.lineTarget = thing; // Don't go any farther. return(false); } }
public override Statement VisitFixed(Fixed Fixed) { bool savedInsideFixed = this.insideFixed; this.insideFixed = true; bool savedInsideFixedDeclarator = this.insideFixedDeclarator; this.insideFixedDeclarator = true; Fixed.Declarators = (Statement)this.Visit(Fixed.Declarators); this.insideFixedDeclarator = savedInsideFixedDeclarator; Fixed.Body = this.VisitBlock(Fixed.Body); this.insideFixed = savedInsideFixed; return Fixed; }
public override void Update() { if (netData.Input.GetKeyDown(key)) { UnityEngine.Debug.LogError("keyDown " + key + " " + netData.view.gameObject.name); } if (netData.Input.GetKeyUp(key)) { UnityEngine.Debug.LogError("keyUp " + key + " " + netData.view.gameObject.name); } if (status == SkillStatus.CanUse) { if (netData.Input.GetKeyDown(key)) { StartUse(); status = SkillStatus.UseStart; } } if (status == SkillStatus.UseStart) { if (netData.Input.GetKey(key)) { UnityEngine.Debug.LogError("GetKey使用技能 [" + skillId + "] "); StayUse(); } if (netData.Input.GetKeyUp(key)) { UseOver(); UnityEngine.Debug.LogError("GetKeyUp使用技能 [" + skillId + "] "); if (skillData.animTime > 0) { (netData as PlayerData).SetAnimTrigger("UseSkill"); } timer = skillData.animTime; status = SkillStatus.UseOver; } } if (status == SkillStatus.UseOver) { if (timer > 0) { timer -= netData.deltaTime; } else { timer = skillData.coolDownTime; AnimOver(); status = SkillStatus.CoolDown; } } else if (status == SkillStatus.CoolDown) { if (timer > 0) { timer -= netData.deltaTime; } else { status = SkillStatus.CanUse; } } }
public override void sendFixedSeq(Fixed[] seq, Ice.Current current) { }
public virtual object Visit(Fixed fixedStatement) { return(null); }
public override Fixed[] echoFixedSeq(Fixed[] seq, Ice.Current current) { return seq; }
private static int run(Ice.Communicator communicator) { var throughput = ThroughputPrxHelper.checkedCast(communicator.propertyToProxy("Throughput.Proxy")); if (throughput == null) { Console.Error.WriteLine("invalid proxy"); return(1); } var throughputOneway = ThroughputPrxHelper.uncheckedCast(throughput.ice_oneway()); var byteSeq = new byte[ByteSeqSize.value]; var stringSeq = new string[StringSeqSize.value]; for (int i = 0; i < StringSeqSize.value; ++i) { stringSeq[i] = "hello"; } var structSeq = new StringDouble[StringDoubleSeqSize.value]; for (int i = 0; i < StringDoubleSeqSize.value; ++i) { structSeq[i] = new StringDouble(); structSeq[i].s = "hello"; structSeq[i].d = 3.14; } var fixedSeq = new Fixed[FixedSeqSize.value]; for (int i = 0; i < FixedSeqSize.value; ++i) { fixedSeq[i].i = 0; fixedSeq[i].j = 0; fixedSeq[i].d = 0; } // // A method needs to be invoked thousands of times before the // JIT compiler will convert it to native code. To ensure an // accurate throughput measurement, we need to "warm up" the // JIT compiler. // { var warmupBytes = new byte[1]; var warmupStrings = new string[1]; var warmupStructs = new StringDouble[1]; warmupStructs[0] = new StringDouble(); var warmupFixed = new Fixed[1]; throughput.startWarmup(); Console.Error.Write("warming up the client/server..."); Console.Error.Flush(); for (int i = 0; i < 10000; i++) { throughput.sendByteSeq(warmupBytes); throughput.sendStringSeq(warmupStrings); throughput.sendStructSeq(warmupStructs); throughput.sendFixedSeq(warmupFixed); throughput.recvByteSeq(); throughput.recvStringSeq(); throughput.recvStructSeq(); throughput.recvFixedSeq(); throughput.echoByteSeq(warmupBytes); throughput.echoStringSeq(warmupStrings); throughput.echoStructSeq(warmupStructs); throughput.echoFixedSeq(warmupFixed); } throughput.endWarmup(); Console.Error.WriteLine("ok"); } menu(); // // By default use byte sequence. // char currentType = '1'; int seqSize = ByteSeqSize.value; string line = null; do { try { Console.Write("==> "); Console.Out.Flush(); line = Console.In.ReadLine(); if (line == null) { break; } long tmsec = DateTime.Now.Ticks / 10000; int repetitions = 100; if (line.Equals("1") || line.Equals("2") || line.Equals("3") || line.Equals("4")) { currentType = line[0]; switch (currentType) { case '1': { Console.WriteLine("using byte sequences"); seqSize = ByteSeqSize.value; break; } case '2': { Console.WriteLine("using string sequences"); seqSize = StringSeqSize.value; break; } case '3': { Console.WriteLine("using variable-length struct sequences"); seqSize = StringDoubleSeqSize.value; break; } case '4': { Console.WriteLine("using fixed-length struct sequences"); seqSize = FixedSeqSize.value; break; } } } else if (line.Equals("t") || line.Equals("o") || line.Equals("r") || line.Equals("e")) { if (currentType == '1') { repetitions = 1000; // Use more iterations for byte sequences as it's a lot faster } char c = line[0]; switch (c) { case 't': { Console.Write("sending"); break; } case 'o': { Console.Write("sending"); break; } case 'r': { Console.Write("receiving"); break; } case 'e': { Console.Write("sending and receiving"); break; } } Console.Write(" " + repetitions); switch (currentType) { case '1': { Console.Write(" byte"); break; } case '2': { Console.Write(" string"); break; } case '3': { Console.Write(" variable-length struct"); break; } case '4': { Console.Write(" fixed-length struct"); break; } } Console.Write(" sequences of size " + seqSize); if (c == 'o') { Console.Write(" as oneway"); } Console.WriteLine("..."); for (int i = 0; i < repetitions; ++i) { switch (currentType) { case '1': { switch (c) { case 't': { throughput.sendByteSeq(byteSeq); break; } case 'o': { throughputOneway.sendByteSeq(byteSeq); break; } case 'r': { throughput.recvByteSeq(); break; } case 'e': { throughput.echoByteSeq(byteSeq); break; } } break; } case '2': { switch (c) { case 't': { throughput.sendStringSeq(stringSeq); break; } case 'o': { throughputOneway.sendStringSeq(stringSeq); break; } case 'r': { throughput.recvStringSeq(); break; } case 'e': { throughput.echoStringSeq(stringSeq); break; } } break; } case '3': { switch (c) { case 't': { throughput.sendStructSeq(structSeq); break; } case 'o': { throughputOneway.sendStructSeq(structSeq); break; } case 'r': { throughput.recvStructSeq(); break; } case 'e': { throughput.echoStructSeq(structSeq); break; } } break; } case '4': { switch (c) { case 't': { throughput.sendFixedSeq(fixedSeq); break; } case 'o': { throughputOneway.sendFixedSeq(fixedSeq); break; } case 'r': { throughput.recvFixedSeq(); break; } case 'e': { throughput.echoFixedSeq(fixedSeq); break; } } break; } } } double dmsec = DateTime.Now.Ticks / 10000 - tmsec; Console.WriteLine("time for " + repetitions + " sequences: " + dmsec.ToString("F") + "ms"); Console.WriteLine("time per sequence: " + ((double)(dmsec / repetitions)).ToString("F") + "ms"); int wireSize = 0; switch (currentType) { case '1': { wireSize = 1; break; } case '2': { wireSize = stringSeq[0].Length; break; } case '3': { wireSize = structSeq[0].s.Length; wireSize += 8; // Size of double on the wire. break; } case '4': { wireSize = 16; // Sizes of two ints and a double on the wire. break; } } double mbit = repetitions * seqSize * wireSize * 8.0 / dmsec / 1000.0; if (c == 'e') { mbit *= 2; } Console.WriteLine("throughput: " + mbit.ToString("#.##") + "Mbps"); } else if (line.Equals("s")) { throughput.shutdown(); } else if (line.Equals("x")) { // Nothing to do } else if (line.Equals("?")) { menu(); } else { Console.WriteLine("unknown command `" + line + "'"); menu(); } } catch (Exception ex) { Console.Error.WriteLine(ex); } }while(!line.Equals("x")); return(0); }
public virtual Differences VisitFixed(Fixed fixed1, Fixed fixed2){ Differences differences = new Differences(fixed1, fixed2); if (fixed1 == null || fixed2 == null){ if (fixed1 != fixed2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++; return differences; } Fixed changes = (Fixed)fixed2.Clone(); Fixed deletions = (Fixed)fixed2.Clone(); Fixed insertions = (Fixed)fixed2.Clone(); Differences diff = this.VisitBlock(fixed1.Body, fixed2.Body); if (diff == null){Debug.Assert(false); return differences;} changes.Body = diff.Changes as Block; deletions.Body = diff.Deletions as Block; insertions.Body = diff.Insertions as Block; Debug.Assert(diff.Changes == changes.Body && diff.Deletions == deletions.Body && diff.Insertions == insertions.Body); differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; diff = this.VisitStatement(fixed1.Declarators, fixed2.Declarators); if (diff == null){Debug.Assert(false); return differences;} changes.Declarators = diff.Changes as Statement; deletions.Declarators = diff.Deletions as Statement; insertions.Declarators = diff.Insertions as Statement; Debug.Assert(diff.Changes == changes.Declarators && diff.Deletions == deletions.Declarators && diff.Insertions == insertions.Declarators); differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; if (differences.NumberOfDifferences == 0){ differences.Changes = null; differences.Deletions = null; differences.Insertions = null; }else{ differences.Changes = changes; differences.Deletions = deletions; differences.Insertions = insertions; } return differences; }
public static void Main(string[] args) { File.Copy("template/Tables.docx", "WordTables.docx", true); var dt = new DataTable(); dt.Columns.Add("Col1"); dt.Columns.Add("Col2"); dt.Columns.Add("Col3"); for (int i = 0; i < 100; i++) { dt.Rows.Add("a" + i, "b" + i, "c" + i); } var dt4 = new DataTable(); dt4.Columns.Add("Name"); dt4.Columns.Add("Description"); //for (int i = 0; i < 10; i++) //dt4.Rows.Add("Name" + i, "Description" + i); var factory = Configuration.Builder .Include(Top10Rows) .Include <DataTable>(Limit10Table) .Include(CollapseNonEmpty) .Build(); var dynamicResize1 = new object[7, 3] { { "a", "b", "c" }, { "a", null, "c" }, { "a", "b", null }, { null, "b", "c" }, { "a", null, null }, { null, null, null }, { "a", "b", "c" }, }; var dynamicResize2 = new object[7, 3] { { "a", "b", "c" }, { null, null, "c" }, { null, null, null }, { null, "b", "c" }, { "a", null, null }, { null, "b", null }, { "a", "b", null }, }; var map = new Dictionary <string, object>[] { new Dictionary <string, object> { { "1", "a" }, { "2", "b" }, { "3", "c" } }, new Dictionary <string, object> { { "1", "a" }, { "2", null }, { "3", "c" } }, new Dictionary <string, object> { { "1", "a" }, { "2", "b" }, { "3", null } }, new Dictionary <string, object> { { "1", null }, { "2", "b" }, { "3", "c" } }, new Dictionary <string, object> { { "1", "a" }, { "2", null }, { "3", null } }, new Dictionary <string, object> { { "1", null }, { "2", null }, { "3", null } }, new Dictionary <string, object> { { "1", "a" }, { "2", "b" }, { "3", "c" } }, }; var combined = new Combined { Beers = new[] { new Beer { Name = "Heineken", Description = "Green and cold", Columns = new [, ] { { "Light", "International" } } }, new Beer { Name = "Leila", Description = "Blueish", Columns = new [, ] { { "Blue", "Domestic" } } } }, Headers = new[, ] { { "Bottle", "Where" } } }; var fixedItems = new Fixed[] { new Fixed { Name = "A", Quantity = 1, Price = 42 }, new Fixed { Name = "B", Quantity = 2, Price = 23 }, new Fixed { Name = "C", Quantity = 3, Price = 505 }, new Fixed { Name = "D", Quantity = 4, Price = 99 }, new Fixed { Name = "E", Quantity = 5, Price = 199 }, new Fixed { Name = "F", Quantity = 6, Price = 0 }, new Fixed { Name = "G", Quantity = 7, Price = 7 } }; using (var doc = factory.Open("WordTables.docx")) { doc.Process( new { Table1 = dt, Table2 = dt, DynamicResize = dynamicResize1, DynamicResizeAndMerge = dynamicResize2, Nulls = map, Table4 = dt4, Combined = combined, Fixed = fixedItems }); } Process.Start("WordTables.docx"); }
public virtual Statement VisitFixed(Fixed Fixed, Fixed changes, Fixed deletions, Fixed insertions){ this.UpdateSourceContext(Fixed, changes); if (Fixed == null) return changes; if (changes != null){ if (deletions == null || insertions == null) Debug.Assert(false); else{ } }else if (deletions != null) return null; return Fixed; }
public void CanGetValue() { Fixed f = new Fixed(0x35); Assert.Equal(0x35, f.Target); }