private IPlatonicSolid GetBaseSolid(SphereType type) { switch (type) { case SphereType.tetrasphere: return(new Tetrahedron()); case SphereType.cubesphere: return(new Cube()); case SphereType.octasphere: return(new Octahedron()); case SphereType.dodecasphere: return(new Dodecahedron()); case SphereType.icosphere: return(new Icosahedron()); case SphereType.uvsphere: return(new UvPolyhedron()); default: return(new Icosahedron()); } }
public static BitmapBits DrawLayout(SphereType[,] layout, int gridsize) { int width = layout.GetLength(0); int height = layout.GetLength(1); int off = (gridsize - 24) / 2; BitmapBits layoutbmp = new BitmapBits(width * gridsize, height * gridsize); for (int y = -gridsize / 2; y < layoutbmp.Height; y += gridsize * 2) { bool row = false; for (int x = -gridsize / 2; x < layoutbmp.Width; x += gridsize) { layoutbmp.FillRectangle(1, x, row ? y : y + gridsize, gridsize, gridsize); row = !row; } } for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { SphereType sp = layout[x, y]; if (sp != SphereType.Empty) { layoutbmp.DrawBitmapComposited(SphereBmps[sp], x * gridsize + off, y * gridsize + off); } } } return(layoutbmp); }
public static BitmapBits DrawLayout(SphereType[,] layout, int gridsize, Rectangle?bounds = null) { int stX = bounds?.X ?? 0; int stY = bounds?.Y ?? 0; int width = bounds?.Width ?? layout.GetLength(0); int height = bounds?.Height ?? layout.GetLength(1); int off = (gridsize - 24) / 2; BitmapBits layoutbmp = new BitmapBits(width * gridsize, height * gridsize); for (int y = -gridsize / 2; y < layoutbmp.Height; y += gridsize * 2) { bool row = ((stX & 1) == 1) ^ ((stY & 1) == 1); for (int x = -gridsize / 2; x < layoutbmp.Width; x += gridsize) { layoutbmp.FillRectangle(1, x, row ? y : y + gridsize, gridsize, gridsize); row = !row; } } for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { SphereType sp = layout[x + stX, y + stY]; if ((sp & ~SphereType.RingFlag) != SphereType.Empty) { layoutbmp.DrawBitmapComposited(SphereBmps[sp], x * gridsize + off, y * gridsize + off); } } } return(layoutbmp); }
public override void Reset () { gameObject = new ConcreteGameObjectVar(this.self); center = Vector3.zero; radius = 1f; color = Color.white * .5f; sphereType = SphereType.Wired; }
SphereType DecodeOscMessage_UpdateSphereType(OscMessage message) { // TODO: clean up and separate int id = message.GetInt(0); float scale = message.GetFloat(1); float bounciness = message.GetFloat(2); float mass = message.GetFloat(3); // reading audio file string from OscMessage string audioFile = GetStringFromBinary(4, message); SphereType sphereType; try { sphereType = new SphereType(id, scale, bounciness, audioFile, mass); } catch { // return default sphere app.Notify(Notification.LogError, "Sphere type not updated."); sphereType = new SphereType(); } return(sphereType); }
public static WoWObject FindClosestSphere(SphereType typ, float range) { range *= range; return(ObjectManager.ObjectList .Where(o => o.Type == WoWObjectType.AiGroup && o.Entry == (uint)typ && o.DistanceSqr < range && !Blacklist.Contains(o.Guid)) .OrderBy(o => o.DistanceSqr) .FirstOrDefault()); }
public override void Reset() { gameObject = new ConcreteGameObjectVar(this.self); center = Vector3.zero; radius = 1f; color = Color.white * .5f; sphereType = SphereType.Wired; }
public InsertTextDialog(int maxsize, SphereType fgsphere, SphereType bgsphere) { InitializeComponent(); font = Font; this.maxsize = maxsize; this.fgsphere = fgsphere; this.bgsphere = bgsphere; }
public void Init(SphereType sphereType) { sphereTypeId = sphereType.id; UpdateScale(sphereType.scale); UpdateBounciness(sphereType.bounciness); UpdateMass(sphereType.mass); UpdateAudioFile(sphereType.audio_file); }
GameObject GenerateSphere() { SphereType recentSphereType = GetRecentSphereType(); GameObject newSphere = InstantiateNewSphere(recentSphereType); spheresManager.spheres.Add(newSphere); return(newSphere); }
public void UpdateState(SphereType st, SizeType sit) { CurrentSpheres[st] = sit; if (CurrentSpheres.Where(r => r.Value == SizeType.Large).ToList().Count == 4) { Invoke("reloadScene", 3); } }
public InsertTextDialog(int maxwidth, int maxheight, SphereType fgsphere, SphereType bgsphere) { InitializeComponent(); font = Font; this.maxwidth = maxwidth; this.maxheight = maxheight; this.fgsphere = fgsphere; this.bgsphere = bgsphere; }
public void LiveUpdateSpheres(Dictionary <int, SphereType> sphereTypes) { foreach (var sphereObject in spheres) { Sphere sphere = sphereObject.GetComponent <Sphere>(); SphereType newSphereType = sphereTypes[sphere.sphereTypeId]; sphere.Init(newSphereType); } }
public static IEnumerable <WoWObject> FindSpheres(SphereType typ, float range) { range *= range; return(ObjectManager.ObjectList .Where( o => o.Type == WoWObjectType.AreaTrigger && o.Entry == (uint)typ && o.DistanceSqr < range && !Blacklist.Contains(o.Guid, BlacklistFlags.Combat)) .OrderBy(o => o.DistanceSqr)); }
public void UpdateSphereTypeOsc(OscMessage message) { SphereType sphereType = DecodeOscMessage_UpdateSphereType(message); sphereTypesManager.UpdateSphereType(sphereType); if (sphereTypeLiveUpdate) { spheresManager.LiveUpdateSpheres(sphereTypesManager.GetSphereTypes()); } }
public override SphereType[,] ToArray() { SphereType[,] result = new SphereType[32, 32]; for (int y = 0; y < 32; y++) { for (int x = 0; x < 32; x++) { result[x, y] = this[x, y]; } } return(result); }
GameObject InstantiateNewSphere(SphereType sphereType) { // get camera/player position Vector3 position = playerController.player.gameObject.transform.position; // instantiate sphere game object at camera position GameObject sphereObject = (GameObject)Instantiate(spheresManager.spherePrefab, position, gameObject.transform.rotation); // initialize sphere script sphereObject.GetComponent <Sphere>().Init(sphereType); return(sphereObject); }
SphereType GetRecentSphereType() { SphereType sphereType; if (recentSphereTypeId == -1) { sphereType = new SphereType(); sphereTypesManager.UpdateSphereType(sphereType); SetRecentSphereTypeId(sphereType.id); } else { sphereType = sphereTypesManager.GetSphereType(recentSphereTypeId); } return(sphereType); }
public static bool AnySpheres(SphereType typ, float range) { return(FindSpheres(typ, range).Any()); }
public static bool AnySpheres(SphereType typ, float range) { WoWObject sphere = FindClosestSphere(typ, range); return(sphere != null && sphere.Distance < 20); }
public static bool AnySpheres(SphereType typ, float range) { WoWObject sphere = FindClosestSphere(typ, range); return sphere != null && sphere.Distance < 20; }
public static WoWPoint FindSphereLocation(SphereType typ, float range) { WoWObject sphere = FindClosestSphere(typ, range); return sphere != null ? sphere.Location : WoWPoint.Empty; }
public static WoWObject FindClosestSphere(SphereType typ, float range) { range *= range; return ObjectManager.ObjectList .Where(o => o.Type == WoWObjectType.AiGroup && o.Entry == (uint)typ && o.DistanceSqr < range && !Blacklist.Contains(o.Guid, BlacklistFlags.Combat)) .OrderBy( o => o.DistanceSqr ) .FirstOrDefault(); }
public static Composite CreateMoveToSphereBehavior(SphereType typ, float range) { return new Decorator( ret => MonkSettings.MoveToSpheres && MovementManager.IsClassMovementAllowed, new PrioritySelector( // check we haven't gotten out of range due to fall / pushback / port / etc new Decorator( ret => guidSphere != 0 && Me.Location.Distance(locSphere) > range, new Action(ret => { guidSphere = 0; locSphere = WoWPoint.Empty; }) ), // validate the sphere we are moving to new Action(ret => { WoWObject sph = FindClosestSphere(typ, range); if (sph == null) { guidSphere = 0; locSphere = WoWPoint.Empty; return RunStatus.Failure; } if (sph.Guid == guidSphere) return RunStatus.Failure; guidSphere = sph.Guid; locSphere = sph.Location; timeAbortSphere = DateTime.Now + TimeSpan.FromSeconds(5); Logger.WriteDebug("MoveToSphere: Moving {0:F1} yds to {1} Sphere {2} @ {3}", sph.Distance, typ, guidSphere, locSphere); return RunStatus.Failure; }), new Decorator( ret => DateTime.Now > timeAbortSphere, new Action( ret => { Logger.WriteDebug("MoveToSphere: blacklisting timed out {0} sphere {1} at {2}", typ, guidSphere, locSphere); Blacklist.Add(guidSphere, BlacklistFlags.Combat, TimeSpan.FromMinutes(5)); }) ), // move to the sphere if out of range new Decorator( ret => guidSphere != 0 && Me.Location.Distance(locSphere) > 1, Movement.CreateMoveToLocationBehavior(ret => locSphere, true, ret => 0f) ), // pause briefly until its consumed new Wait( 1, ret => { WoWObject sph = FindClosestSphere(typ, range); return sph == null || sph.Guid != guidSphere ; }, new Action( r => { return RunStatus.Failure; } ) ), // still exist? black list it then new Decorator( ret => { WoWObject sph = FindClosestSphere(typ, range); return sph != null && sph.Guid == guidSphere ; }, new Action( ret => { Logger.WriteDebug("MoveToSphere: blacklisting unconsumed {0} sphere {1} at {2}", typ, guidSphere, locSphere); Blacklist.Add(guidSphere, BlacklistFlags.Combat, TimeSpan.FromMinutes(5)); }) ) ) ); }
public static WoWPoint FindSphereLocation(SphereType typ, float range) { WoWObject sphere = FindClosestSphere(typ, range); return(sphere != null ? sphere.Location : WoWPoint.Empty); }
public static int SphereCount(SphereType typ, float range) { return(FindSpheres(typ, range).Count()); }
public static WoWObject FindSphere(SphereType typ, float range = 20f) { range *= range; return ObjectManager.ObjectList .Where(o => o.Type == WoWObjectType.AiGroup && o.Entry == (uint)typ && o.DistanceSqr < range) .OrderBy( o => o.DistanceSqr ) .FirstOrDefault(); }
public static Composite CreateMoveToSphereBehavior(SphereType typ) { return new Sequence( new Action(ret => { WoWObject sph = FindSphere(typ); if (sph != null && sph.Guid != lastSphere) { lastSphere = sph.Guid; Logger.WriteDebug("CreateMonkRest: Moving {0:F1} yds to {1} Sphere {2}", sph.Distance, typ.ToString(), lastSphere ); } }), Movement.CreateMoveToLocationBehavior(ret => FindSphereLocation(SphereType.Life), true, ret => 0f), new ActionAlwaysSucceed() ); }
public static Composite CreateMoveToSphereBehavior(SphereType typ, float range) { return(new Decorator( ret => MonkSettings.MoveToSpheres && !SingularSettings.Instance.DisableAllMovement, new PrioritySelector( // check we haven't gotten out of range due to fall / pushback / port / etc new Decorator( ret => guidSphere != 0 && Me.Location.Distance(locSphere) > range, new Action(ret => { guidSphere = 0; locSphere = WoWPoint.Empty; }) ), // validate the sphere we are moving to new Action(ret => { WoWObject sph = FindClosestSphere(typ, range); if (sph == null) { guidSphere = 0; locSphere = WoWPoint.Empty; return RunStatus.Failure; } if (sph.Guid == guidSphere) { return RunStatus.Failure; } guidSphere = sph.Guid; locSphere = sph.Location; timeAbortSphere = DateTime.Now + TimeSpan.FromSeconds(5); Logger.WriteDebug("MoveToSphere: Moving {0:F1} yds to {1} Sphere {2} @ {3}", sph.Distance, typ, guidSphere, locSphere); return RunStatus.Failure; }), new Decorator( ret => DateTime.Now > timeAbortSphere, new Action(ret => { Logger.WriteDebug("MoveToSphere: blacklisting timed out {0} sphere {1} at {2}", typ, guidSphere, locSphere); Blacklist.Add(guidSphere, TimeSpan.FromMinutes(5)); }) ), // move to the sphere if out of range new Decorator( ret => guidSphere != 0 && Me.Location.Distance(locSphere) > 1, Movement.CreateMoveToLocationBehavior(ret => locSphere, true, ret => 0f) ), // pause briefly until its consumed new Wait( 1, ret => { WoWObject sph = FindClosestSphere(typ, range); return sph == null || sph.Guid != guidSphere; }, new ActionAlwaysFail() ), // still exist? black list it then new Decorator( ret => { WoWObject sph = FindClosestSphere(typ, range); return sph != null && sph.Guid == guidSphere; }, new Action(ret => { Logger.WriteDebug("MoveToSphere: blacklisting unconsumed {0} sphere {1} at {2}", typ, guidSphere, locSphere); Blacklist.Add(guidSphere, TimeSpan.FromMinutes(5)); }) ) ) )); }
public void UpdateSphereType(SphereType sphereType) { sphereTypes[sphereType.id] = sphereType; }
public static WoWObject FindClosestSphere(SphereType typ, float range) { return(FindSpheres(typ, range).FirstOrDefault()); }
////private static readonly List<uint> ReducibleItemIds = new List<uint> { //// 12968, // Granular Clay //// 12969, // Peat Moss //// 12970, // Black Soil //// 12971, // Highland Oregano //// 12972, // Furymint //// 12973, // Clary Sage //// 5218, // Lightning Moraine //// 12967, // Bright Lightning Rock //// 5224, // Radiant Lightning Moraine //// 5214, // Fire Moraine //// 12966, // Bright Fire Rock //// 5220, // Radiant Fire Moraine //// 12802, //Caiman //// 12821, //Pteranodon //// 12831, //Thaliak Caiman //// 12833, //Tupuxuara //// 12761, //Dravanian Bass //// 12784 //Manasail //// }; public static Vector3 AddRandomDirection(this Vector3 vector, float range = 2.0f, SphereType sphereType = SphereType.Full) { var side = range / Math.Sqrt(3); var minY = sphereType.HasFlag(SphereType.BottomHalf) ? -side : 0; var maxY = sphereType.HasFlag(SphereType.TopHalf) ? side : 0; var random = new Vector3( vector.X + (float)MathEx.Random(-side, side), vector.Y + (float)MathEx.Random(minY, maxY), vector.Z + (float)MathEx.Random(-side, side)); Vector3 hit; var ticks = 0; while (WorldManager.Raycast(vector, random, out hit) && ticks++ < 200) { random = new Vector3( vector.X + (float)MathEx.Random(-side, side), vector.Y + (float)MathEx.Random(minY, maxY), vector.Z + (float)MathEx.Random(-side, side)); } if (ticks > 200) { Logger.Instance.Error("Attempted to add Random Direction from {0} but failed", vector); return(vector); } Logger.Instance.Info("Adding Random Direction. from {0} to {1}", vector, random); return(random); }
private void Init() { SceneLayer layer = scene.Layers.Single(a => a.Name == "Playfield\0"); Width = layer.Width; Height = layer.Height; Layout = new SphereType[Width, Height]; for (ushort y = 0; y < Height; y++) { for (ushort x = 0; x < Width; x++) { SphereType sp = (SphereType)(layer.Tiles[y][x] & 0x3FF); switch (sp) { case SphereType.StartN: case SphereType.StartW: case SphereType.StartS: case SphereType.StartE: Angle = (byte)(sp - SphereType.StartN); StartX = x; StartY = y; break; case (SphereType)0x3FF: break; default: Layout[x, y] = sp; break; } } } SceneLayer rings = scene.Layers.Single(a => a.Name == "Ring Count\0"); for (int y = 0; y < Math.Min(rings.Height, Height); y++) { for (int x = 0; x < Math.Min(rings.Width, Width); x++) { if ((SphereType)(rings.Tiles[y][x] & 0x3FF) == SphereType.Ring) { Layout[x, y] |= SphereType.RingFlag; } } } SceneEntity palent = scene.Objects.SingleOrDefault(a => a.Name.Name == "BSS_Palette")?.Entities[0]; if (palent != null) { HasPal = true; PaletteID = palent.GetAttribute("paletteID").ValueVar; SkyAlpha = palent.GetAttribute("skyAlpha").ValueUInt8; GlobeAlpha = palent.GetAttribute("globeAlpha").ValueUInt8; RSDKColor tmp = palent.GetAttribute("playfieldA").ValueColor; PlayfieldA = DrawingColor.FromArgb(tmp.R, tmp.G, tmp.B); tmp = palent.GetAttribute("playfieldB").ValueColor; PlayfieldB = DrawingColor.FromArgb(tmp.R, tmp.G, tmp.B); tmp = palent.GetAttribute("bgColor1").ValueColor; BGColor1 = DrawingColor.FromArgb(tmp.R, tmp.G, tmp.B); tmp = palent.GetAttribute("bgColor2").ValueColor; BGColor2 = DrawingColor.FromArgb(tmp.R, tmp.G, tmp.B); tmp = palent.GetAttribute("bgColor3").ValueColor; BGColor3 = DrawingColor.FromArgb(tmp.R, tmp.G, tmp.B); } }