public ThingType(ushort id, ThingCategory category) { ID = id; Category = category; StackOrder = StackOrder.Commom; FrameGroups = new Dictionary <FrameGroupType, FrameGroup>(); }
public bool RemoveThing(ushort id, ThingCategory category) { if (this.Disposed) { throw new ObjectDisposedException(this.GetType().Name); } if (!this.Loaded || category == ThingCategory.Invalid) { return(false); } ThingType changedThing = this.InternalRemoveThing(id, category); if (changedThing != null) { this.Changed = true; if (this.StorageChanged != null) { this.StorageChanged(this, new ThingListChangedArgs(new ThingType[] { changedThing }, StorageChangeType.Remove)); } return(true); } return(false); }
private void LogFoods() { string log = ""; foreach (ESItem esi in aFoods) { if (esi.thingDef.defName != null) { string strTd = esi.thingDef.defName; log = string.Format("{0}Name: {1} ", log, strTd); } if (esi.thingDef.category != null) { ThingCategory tc = esi.thingDef.category; log = string.Format("{0}Category: {1} ", log, tc.ToString()); } if (esi.thingDef.thingCategories != null) { List <ThingCategoryDef> ltc = esi.thingDef.thingCategories; log = string.Format("{0}ThingCategoryDefs: ", log); foreach (ThingCategoryDef tcd in ltc) { log = string.Format("{0}{1}, ", log, tcd.defName); } } log = string.Format("{0}\n", log); } Log.Message(log); }
public ObjectData GetThingData(ushort id, ThingCategory category, bool singleFrameGroup) { ThingType thing = this.Things.GetThing(id, category); if (thing == null) { return(null); } if (singleFrameGroup) { thing = ThingType.ToSingleFrameGroup(thing); } SpriteGroup spriteGroups = new SpriteGroup(); Console.WriteLine(thing.FrameGroupCount); for (byte i = 0; i < thing.FrameGroupCount; i++) { FrameGroupType groupType = (FrameGroupType)i; FrameGroup frameGroup = thing.GetFrameGroup(groupType); int length = frameGroup.SpriteIDs.Length; Sprite[] sprites = new Sprite[length]; for (int s = 0; s < length; s++) { sprites[s] = this.Sprites.GetSprite(frameGroup.SpriteIDs[s]); } spriteGroups.Add(groupType, sprites); } return(new ObjectData(thing, spriteGroups)); }
public ThingType(ushort id, ThingCategory category) { this.ID = id; this.Category = category; this.StackOrder = StackOrder.Commom; this.frameGroups = new Dictionary<FrameGroupType, FrameGroup>(); }
public static FrameGroup Serialize(ThingCategory category, ref Net.InputMessage binaryReader) { FrameGroup frameGroup = new FrameGroup(); frameGroup.Width = binaryReader.GetU8(); frameGroup.Height = binaryReader.GetU8(); if (frameGroup.Width > 1 || frameGroup.Height > 1) { frameGroup.ExactSize = binaryReader.GetU8(); } else { frameGroup.ExactSize = 32; } frameGroup.Layers = binaryReader.GetU8(); frameGroup.PatternWidth = binaryReader.GetU8(); frameGroup.PatternHeight = binaryReader.GetU8(); frameGroup.PatternDepth = binaryReader.GetU8(); frameGroup.Phases = binaryReader.GetU8(); if (frameGroup.Phases > 1) { frameGroup.Animator = FrameGroupAnimator.Serialize(frameGroup.Phases, ref binaryReader); } int totalSprites = frameGroup.Width * frameGroup.Height * frameGroup.Layers * frameGroup.PatternWidth * frameGroup.PatternHeight * frameGroup.PatternDepth * frameGroup.Phases; for (int j = 0; j < totalSprites; j++) { frameGroup.Sprites.Add(binaryReader.GetU32()); } return(frameGroup); }
public PartialViewResult EditPV(long id) { ThingCategory thingCategory = uof_repos.repoThingCategorys.Find(id); ViewBag.IconID = new SelectList(uof_repos.repoMediaFiles.GetList(), "ID", "Title", thingCategory.IconID); return(PartialView("_Edit", thingCategory)); }
public SpriteSheet GetSpriteSheet(ushort id, ThingCategory category, FrameGroupType groupType) { ThingType thing = this.Things.GetThing(id, category); if (thing == null) { return(null); } FrameGroup group = thing.GetFrameGroup(groupType); int totalX = group.PatternZ * group.PatternX * group.Layers; int totalY = group.Frames * group.PatternY; int bitmapWidth = (totalX * group.Width) * Sprite.DefaultSize; int bitmapHeight = (totalY * group.Height) * Sprite.DefaultSize; int pixelsWidth = group.Width * Sprite.DefaultSize; int pixelsHeight = group.Height * Sprite.DefaultSize; Bitmap bitmap = new Bitmap(bitmapWidth, bitmapHeight, PixelFormat.Format32bppArgb); Dictionary <int, Rect> rectList = new Dictionary <int, Rect>(); BitmapLocker lockBitmap = new BitmapLocker(bitmap); lockBitmap.LockBits(); for (int f = 0; f < group.Frames; f++) { for (int z = 0; z < group.PatternZ; z++) { for (int y = 0; y < group.PatternY; y++) { for (int x = 0; x < group.PatternX; x++) { for (int l = 0; l < group.Layers; l++) { int index = group.GetTextureIndex(l, x, y, z, f); int fx = (index % totalX) * pixelsWidth; int fy = (int)(Math.Floor((decimal)(index / totalX)) * pixelsHeight); rectList.Add(index, new Rect(fx, fy, pixelsWidth, pixelsHeight)); for (int w = 0; w < group.Width; w++) { for (int h = 0; h < group.Height; h++) { index = group.GetSpriteIndex(w, h, l, x, y, z, f); int px = ((group.Width - w - 1) * Sprite.DefaultSize); int py = ((group.Height - h - 1) * Sprite.DefaultSize); uint spriteId = group.SpriteIDs[index]; lockBitmap.CopyPixels(this.Sprites.GetSpriteBitmap(spriteId), px + fx, py + fy); } } } } } } } lockBitmap.UnlockBits(); return(new SpriteSheet(bitmap, rectList)); }
public ThingType GetThingType(UInt16 id, ThingCategory category) { if (category >= ThingCategory.ThingLastCategory || id >= _mThingTypes[(int)category].Count) { return(_mNullThingType); } return(_mThingTypes[(int)category][id]); }
public static APIThingsCategory fromThingCategory(ThingCategory sourceThingCategory) { APIThingsCategory result = new APIThingsCategory(); result.ID = sourceThingCategory.ID; result.Title = sourceThingCategory.Title; return(result); }
public static bool BeautyRelevant(ThingCategory cat) { if (cat != ThingCategory.Building && cat != ThingCategory.Item && cat != ThingCategory.Plant) { return(cat == ThingCategory.Filth); } return(true); }
public Bitmap GetObjectImage(ushort id, ThingCategory category, FrameGroupType groupType) { ThingType thing = this.Things.GetThing(id, category); if (thing == null) { return(null); } Bitmap bitmap = this.spriteCache.GetPicture(id, category); if (bitmap != null) { return(bitmap); } FrameGroup group = thing.GetFrameGroup(groupType); int width = Sprite.DefaultSize * group.Width; int height = Sprite.DefaultSize * group.Height; bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); BitmapLocker lockBitmap = new BitmapLocker(bitmap); lockBitmap.LockBits(); byte layers = group.Layers; byte x = 0; if (category == ThingCategory.Outfit) { layers = 1; x = (byte)(2 % group.PatternX); } // draw sprite for (byte l = 0; l < layers; l++) { for (byte w = 0; w < group.Width; w++) { for (byte h = 0; h < group.Height; h++) { int index = group.GetSpriteIndex(w, h, l, x, 0, 0, 0); uint spriteId = group.SpriteIDs[index]; int px = (group.Width - w - 1) * Sprite.DefaultSize; int py = (group.Height - h - 1) * Sprite.DefaultSize; lockBitmap.CopyPixels(this.Sprites.GetSpriteBitmap(spriteId), px, py); } } } lockBitmap.UnlockBits(); lockBitmap.Dispose(); this.spriteCache.SetPicture(id, category, bitmap); return(bitmap); }
public ThingType GetThing(ushort id, ThingCategory category) { if (this.Disposed) { throw new ObjectDisposedException(this.GetType().Name); } if (!this.Loaded || id == 0 || category == ThingCategory.Invalid) { return(null); } switch (category) { case ThingCategory.Item: { if (this.Items.ContainsKey(id)) { return(this.Items[id]); } break; } case ThingCategory.Outfit: { if (this.Outfits.ContainsKey(id)) { return(this.Outfits[id]); } break; } case ThingCategory.Effect: { if (this.Effects.ContainsKey(id)) { return(this.Effects[id]); } break; } case ThingCategory.Missile: { if (this.Missiles.ContainsKey(id)) { return(this.Missiles[id]); } break; } } return(null); }
public Dictionary <int, ThingType> GetThingTypes(ThingCategory category) { List <ThingType> ret = new List <ThingType>(); if (category >= ThingCategory.ThingLastCategory) { throw new Exception(String.Format("invalid thing type category {0}", category)); } return(_mThingTypes[(int)category]); }
public ActionResult DeletePV([Bind(Include = "ID")] ThingCategory thingCategory) { ResultInfo.Result res = ResultInfo.GetResultByID(1); if (ModelState.IsValid) { res = uof_repos.repoThingCategorys.Delete(thingCategory.ID); return(Json(res)); } return(Json(res)); }
public ActionResult Details(long id) { if (ValidateUserPermissions(false, false) == false) { return(RedirectToAction("Login", "Account")); } ThingCategory ThingCat = uof_repos.repoThingCategorys.Find(id); return(View(ThingCat)); }
private static bool WorthMentioningInCrushLetter(Thing t) { if (!t.def.destroyable) { return(false); } ThingCategory category = t.def.category; return(category == ThingCategory.Building || category == ThingCategory.Pawn || (category == ThingCategory.Item && t.MarketValue > 0.01f)); }
public ActionResult EditPV([Bind(Include = "ID,Title")] ThingCategory thingCategory) { ResultInfo.Result res = ResultInfo.GetResultByID(1); if (ModelState.IsValid) { res = UnitOfWork_Repositories.repoThingCategorys.Edit(thingCategory.ID, thingCategory.Title); return(Json(res)); } return(Json(res)); }
public ActionResult AddPV([Bind(Include = "Title,IconID")] ThingCategory thingCategory) { ResultInfo.Result res = ResultInfo.GetResultByID(1); if (ModelState.IsValid) { res = uof_repos.repoThingCategorys.Add(thingCategory.Title, (long)thingCategory.IconID); return(Json(res)); } return(Json(res)); }
public PartialViewResult DeletePV(long id) { if (!User.IsInRole("Admin")) { ResultInfo.Result rm = Core.ResultInfo.GetResultByID(1); return(PartialView("_PVResult", rm)); } ThingCategory thingCategory = uof_repos.repoThingCategorys.Find(id); return(PartialView("_Delete", thingCategory)); }
public FrameGroup GetFrameGroup(ushort id, ThingCategory category, FrameGroupType groupType) { ThingType type = this.Things.GetThing(id, category); if (type != null) { return(type.GetFrameGroup(groupType)); } return(null); }
public List <ThingType> FindThingTypeByAttr(ThingAttr attr, ThingCategory category) { List <ThingType> ret = new List <ThingType>(); foreach (ThingType typename in _mThingTypes[(int)category].Values) { if (typename.HasAttr(attr)) { ret.Add(typename); } } return(ret); }
public ResultInfo.Result Edit(long ID, string Title) { try { ThingCategory cat = db.ThingCategorys.Find(ID); cat.Title = Title; db.SaveChanges(); return(ResultInfo.GenerateOKResult("Saved", cat.ID)); } catch { return(ResultInfo.GetResultByID(1)); } }
/// <summary> /// Find Endpoint Type by EndPoint Type ID /// </summary> /// <param name="id">EndPoint Type ID</param> /// <returns>Endpoint object</returns> public ThingCategory Find(long id) { ThingCategory epType = new ThingCategory(); List <ThingCategory> epTypes = db.ThingCategorys.Where(c => c.ID == id).OrderBy(c => c.Title).ToList(); if (epTypes.Count == 1) { epType = epTypes[0]; } else { throw new Exception("Not Found"); } return(epType); }
public ResultInfo.Result Edit(long ID, string Title, long IconID) { try { ThingCategory cat = db.ThingCategorys.Find(ID); cat.Title = Title; cat.IconID = IconID; db.SaveChanges(); return(Result.GenerateOKResult("Saved", cat.ID.ToString())); } catch { return(Result.GenerateFailedResult()); } }
private static bool WorthMentioningInCrushLetter(Thing t) { bool result; if (!t.def.destroyable) { result = false; } else { ThingCategory category = t.def.category; result = (category == ThingCategory.Building || category == ThingCategory.Pawn || (category == ThingCategory.Item && t.MarketValue > 0.01f)); } return(result); }
public ResultInfo.Result Add(string Title) { try { ThingCategory cat = new ThingCategory(); cat.Title = Title; db.ThingCategorys.Add(cat); db.SaveChanges(); return(ResultInfo.GenerateOKResult("Saved", cat.ID)); } catch { return(ResultInfo.GetResultByID(1)); } }
public ResultInfo.Result Add(string Title, long IconID) { try { ThingCategory cat = new ThingCategory(); cat.Title = Title; cat.IconID = IconID; db.ThingCategorys.Add(cat); db.SaveChanges(); return(Result.GenerateOKResult("Saved", cat.ID.ToString())); } catch { return(Result.GenerateFailedResult()); } }
public Thing ThingAt(IntVec3 c, ThingCategory cat) { if (!c.InBounds(this.map)) { return((Thing)null); } List <Thing> thingList = this.thingGrid[this.map.cellIndices.CellToIndex(c)]; for (int index = 0; index < thingList.Count; ++index) { if (thingList[index].def.category == cat) { return(thingList[index]); } } return((Thing)null); }
public static void injectComponents() { foreach (ThingDef def in DefDatabase <ThingDef> .AllDefs) { ThingCategory thingCategory = def.category; if (typeof(ThingWithComps).IsAssignableFrom(def.thingClass) && (thingCategory == ThingCategory.Pawn || thingCategory == ThingCategory.Building || thingCategory == ThingCategory.Item || thingCategory == ThingCategory.Filth || thingCategory == ThingCategory.Gas || def.IsBlueprint)) { addComponentAsFirst(def, CompMainComponent.COMP_DEF); } } }
public Thing ThingAt(IntVec3 c, ThingCategory cat) { if (!c.InBounds(this.map)) { return(null); } List <Thing> list = this.thingGrid[this.map.cellIndices.CellToIndex(c)]; for (int i = 0; i < list.Count; i++) { if (list[i].def.category == cat) { return(list[i]); } } return(null); }
public FrameDuration(ThingCategory category) { switch (category) { case ThingCategory.Item: this.SetTo(500, 500); break; case ThingCategory.Outfit: this.SetTo(300, 300); break; case ThingCategory.Effect: this.SetTo(100, 100); break; } this.SetTo(0, 0); }
public Bitmap GetPicture(ushort id, ThingCategory category) { if (category == ThingCategory.Item && this.items.ContainsKey(id)) { return this.items[id]; } else if (category == ThingCategory.Outfit && this.outfits.ContainsKey(id)) { return this.outfits[id]; } else if (category == ThingCategory.Effect && this.effects.ContainsKey(id)) { return this.effects[id]; } else if (category == ThingCategory.Missile && this.missiles.ContainsKey(id)) { return this.missiles[id]; } return null; }
public ThingData GetThingData(ushort id, ThingCategory category) { return this.GetThingData(id, category, false); }
public Bitmap GetObjectImage(ushort id, ThingCategory category, FrameGroupType groupType) { ThingType thing = this.Things.GetThing(id, category); if (thing == null) { return null; } Bitmap bitmap = this.spriteCache.GetPicture(id, category); if (bitmap != null) { return bitmap; } FrameGroup group = thing.GetFrameGroup(groupType); int width = Sprite.DefaultSize * group.Width; int height = Sprite.DefaultSize * group.Height; bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); BitmapLocker lockBitmap = new BitmapLocker(bitmap); lockBitmap.LockBits(); byte layers = group.Layers; byte x = 0; if (category == ThingCategory.Outfit) { layers = 1; x = (byte)(2 % group.PatternX); } // draw sprite for (byte l = 0; l < layers; l++) { for (byte w = 0; w < group.Width; w++) { for (byte h = 0; h < group.Height; h++) { int index = group.GetSpriteIndex(w, h, l, x, 0, 0, 0); uint spriteId = group.SpriteIDs[index]; int px = (group.Width - w - 1) * Sprite.DefaultSize; int py = (group.Height - h - 1) * Sprite.DefaultSize; lockBitmap.CopyPixels(this.Sprites.GetSpriteBitmap(spriteId), px, py); } } } lockBitmap.UnlockBits(); lockBitmap.Dispose(); this.spriteCache.SetPicture(id, category, bitmap); return bitmap; }
public Bitmap GetObjectImage(ushort id, ThingCategory category) { return this.GetObjectImage(id, category, FrameGroupType.Default); }
public void SetPicture(ushort id, ThingCategory category, Bitmap bitmap) { switch (category) { case ThingCategory.Item: this.items[id] = bitmap; break; case ThingCategory.Outfit: this.outfits[id] = bitmap; break; case ThingCategory.Effect: this.effects[id] = bitmap; break; case ThingCategory.Missile: this.missiles[id] = bitmap; break; } }
public SpriteSheet GetSpriteSheet(ushort id, ThingCategory category, FrameGroupType groupType) { ThingType thing = this.Things.GetThing(id, category); if (thing == null) { return null; } FrameGroup group = thing.GetFrameGroup(groupType); int totalX = group.PatternZ * group.PatternX * group.Layers; int totalY = group.Frames * group.PatternY; int bitmapWidth = (totalX * group.Width) * Sprite.DefaultSize; int bitmapHeight = (totalY * group.Height) * Sprite.DefaultSize; int pixelsWidth = group.Width * Sprite.DefaultSize; int pixelsHeight = group.Height * Sprite.DefaultSize; Bitmap bitmap = new Bitmap(bitmapWidth, bitmapHeight, PixelFormat.Format32bppArgb); Dictionary<int, Rect> rectList = new Dictionary<int, Rect>(); BitmapLocker lockBitmap = new BitmapLocker(bitmap); lockBitmap.LockBits(); for (int f = 0; f < group.Frames; f++) { for (int z = 0; z < group.PatternZ; z++) { for (int y = 0; y < group.PatternY; y++) { for (int x = 0; x < group.PatternX; x++) { for (int l = 0; l < group.Layers; l++) { int index = group.GetTextureIndex(l, x, y, z, f); int fx = (index % totalX) * pixelsWidth; int fy = (int)(Math.Floor((decimal)(index / totalX)) * pixelsHeight); rectList.Add(index, new Rect(fx, fy, pixelsWidth, pixelsHeight)); for (int w = 0; w < group.Width; w++) { for (int h = 0; h < group.Height; h++) { index = group.GetSpriteIndex(w, h, l, x, y, z, f); int px = ((group.Width - w - 1) * Sprite.DefaultSize); int py = ((group.Height - h - 1) * Sprite.DefaultSize); uint spriteId = group.SpriteIDs[index]; lockBitmap.CopyPixels(this.Sprites.GetSpriteBitmap(spriteId), px + fx, py + fy); } } } } } } } lockBitmap.UnlockBits(); return new SpriteSheet(bitmap, rectList); }
public bool HasThing(ushort id, ThingCategory category) { if (!this.Loaded || category == ThingCategory.Invalid) { return false; } switch (category) { case ThingCategory.Item: return this.Items.ContainsKey(id); case ThingCategory.Outfit: return this.Outfits.ContainsKey(id); case ThingCategory.Effect: return this.Effects.ContainsKey(id); case ThingCategory.Missile: return this.Missiles.ContainsKey(id); } return false; }
public SpriteSheet GetSpriteSheet(ushort id, ThingCategory category, FrameGroupType groupType, OutfitData outfitData) { ThingType thing = this.Things.GetThing(id, category); if (thing == null) { return null; } SpriteSheet rawSpriteSheet = this.GetSpriteSheet(id, category, groupType); FrameGroup group = thing.GetFrameGroup(groupType); if (group.Layers < 2) { return rawSpriteSheet; } outfitData = outfitData == null ? outfitDataHelper : outfitData; int totalX = group.PatternZ * group.PatternX * group.Layers; int totalY = group.Frames * group.PatternY; int bitmapWidth = (totalX * group.Width) * Sprite.DefaultSize; int bitmapHeight = (totalY * group.Height) * Sprite.DefaultSize; int pixelsWidth = group.Width * Sprite.DefaultSize; int pixelsHeight = group.Height * Sprite.DefaultSize; Bitmap grayBitmap = new Bitmap(bitmapWidth, bitmapHeight, PixelFormat.Format32bppArgb); Bitmap blendBitmap = new Bitmap(bitmapWidth, bitmapHeight, PixelFormat.Format32bppArgb); Bitmap bitmap = new Bitmap(bitmapWidth, bitmapHeight, PixelFormat.Format32bppArgb); Dictionary<int, Rect> rectList = new Dictionary<int, Rect>(); for (int f = 0; f < group.Frames; f++) { for (int z = 0; z < group.PatternZ; z++) { for (int x = 0; x < group.PatternX; x++) { int index = (((f % group.Frames * group.PatternZ + z) * group.PatternY) * group.PatternX + x) * group.Layers; rectList[index] = new Rect((z * group.PatternX + x) * pixelsWidth, f * pixelsHeight, pixelsWidth, pixelsHeight); } } } BitmapLocker grayLocker = new BitmapLocker(grayBitmap); BitmapLocker blendLocker = new BitmapLocker(blendBitmap); BitmapLocker bitmapLocker = new BitmapLocker(bitmap); grayLocker.LockBits(); blendLocker.LockBits(); bitmapLocker.LockBits(); for (int y = 0; y < group.PatternY; y++) { if (y == 0 || (outfitData.Addons & 1 << (y - 1)) != 0) { for (int f = 0; f < group.Frames; f++) { for (int z = 0; z < group.PatternZ; z++) { for (int x = 0; x < group.PatternX; x++) { // gets gray bitmap int i = (((f % group.Frames * group.PatternZ + z) * group.PatternY + y) * group.PatternX + x) * group.Layers; Rect rect = rawSpriteSheet.RectList[i]; int rx = rect.X; int ry = rect.Y; int rw = rect.Width; int rh = rect.Height; int index = (((f * group.PatternZ + z) * group.PatternY) * group.PatternX + x) * group.Layers; rect = rectList[index]; int px = rect.X; int py = rect.Y; grayLocker.CopyPixels(rawSpriteSheet.Bitmap, rx, ry, rw, rh, px, py); // gets blend bitmap i++; rect = rawSpriteSheet.RectList[i]; rx = rect.X; ry = rect.Y; rw = rect.Width; rh = rect.Height; blendLocker.CopyPixels(rawSpriteSheet.Bitmap, rx, ry, rw, rh, px, py); } } } bitmapLocker.ColorizePixels(grayLocker.Pixels, blendLocker.Pixels, outfitData.Head, outfitData.Body, outfitData.Legs, outfitData.Feet); } } grayLocker.UnlockBits(); grayLocker.Dispose(); blendLocker.UnlockBits(); blendLocker.Dispose(); bitmapLocker.UnlockBits(); bitmapLocker.Dispose(); grayBitmap.Dispose(); blendBitmap.Dispose(); return new SpriteSheet(bitmap, rectList); }
public ThingType GetThing(ushort id, ThingCategory category) { if (this.Disposed) { throw new ObjectDisposedException(this.GetType().Name); } if (!this.Loaded || id == 0 || category == ThingCategory.Invalid) { return null; } switch (category) { case ThingCategory.Item: { if (this.Items.ContainsKey(id)) { return this.Items[id]; } break; } case ThingCategory.Outfit: { if (this.Outfits.ContainsKey(id)) { return this.Outfits[id]; } break; } case ThingCategory.Effect: { if (this.Effects.ContainsKey(id)) { return this.Effects[id]; } break; } case ThingCategory.Missile: { if (this.Missiles.ContainsKey(id)) { return this.Missiles[id]; } break; } } return null; }
public FrameGroup GetFrameGroup(ushort id, ThingCategory category, FrameGroupType groupType) { ThingType type = this.Things.GetThing(id, category); if (type != null) { return type.GetFrameGroup(groupType); } return null; }
public static ThingType Create(ushort id, ThingCategory category) { if (category == ThingCategory.Invalid) { throw new ArgumentException("Invalid category."); } ThingType thing = new ThingType(id, category); if (category == ThingCategory.Outfit) { for (int i = 0; i < 2; i++) { FrameGroup group = FrameGroup.Create(); group.PatternX = 4; // directions group.Frames = 3; // animations group.IsAnimation = true; group.SpriteIDs = new uint[group.GetTotalSprites()]; group.FrameDurations = new FrameDuration[group.Frames]; for (int f = 0; f < group.Frames; f++) { group.FrameDurations[f] = new FrameDuration(category); } thing.SetFrameGroup((FrameGroupType)i, group); } } else { FrameGroup group = FrameGroup.Create(); if (category == ThingCategory.Missile) { group.PatternX = 3; group.PatternY = 3; group.SpriteIDs = new uint[group.GetTotalSprites()]; } thing.SetFrameGroup(FrameGroupType.Default, group); } return thing; }
public ThingType(ThingCategory category) : this(0, category) { //// }
private ThingType InternalRemoveThing(ushort id, ThingCategory category) { if (id == 0 || category == ThingCategory.Invalid || !this.HasThing(id, category)) { return null; } ThingType changedThing = null; if (category == ThingCategory.Item) { changedThing = this.Items[id]; if (id == this.ItemCount && id != 100) { this.ItemCount = (ushort)(this.ItemCount - 1); this.Items.Remove(id); } else { this.Items[id] = ThingType.Create(id, category); } } else if (category == ThingCategory.Outfit) { changedThing = this.Outfits[id]; if (id == this.OutfitCount && id != 1) { this.OutfitCount = (ushort)(this.OutfitCount - 1); this.Outfits.Remove(id); } else { this.Outfits[id] = ThingType.Create(id, category); } } else if (category == ThingCategory.Effect) { changedThing = this.Effects[id]; if (id == this.EffectCount && id != 1) { this.EffectCount = (ushort)(this.EffectCount - 1); this.Effects.Remove(id); } else { this.Effects[id] = ThingType.Create(id, category); } } else if (category == ThingCategory.Missile) { changedThing = this.Missiles[id]; if (id == this.MissileCount && id != 1) { this.MissileCount = (ushort)(this.MissileCount - 1); this.Missiles.Remove(id); } else { this.Missiles[id] = ThingType.Create(id, category); } } return changedThing; }
public ThingData GetThingData(ushort id, ThingCategory category, bool singleFrameGroup) { ThingType thing = this.Things.GetThing(id, category); if (thing == null) { return null; } if (singleFrameGroup) { thing = ThingType.ToSingleFrameGroup(thing); } SpriteGroup spriteGroups = new SpriteGroup(); Console.WriteLine(thing.FrameGroupCount); for (byte i = 0; i < thing.FrameGroupCount; i++) { FrameGroupType groupType = (FrameGroupType)i; FrameGroup frameGroup = thing.GetFrameGroup(groupType); int length = frameGroup.SpriteIDs.Length; Sprite[] sprites = new Sprite[length]; for (int s = 0; s < length; s++) { sprites[s] = this.Sprites.GetSprite(frameGroup.SpriteIDs[s]); } spriteGroups.Add(groupType, sprites); } return new ThingData(thing, spriteGroups); }
public bool RemoveThing(ushort id, ThingCategory category) { if (this.Disposed) { throw new ObjectDisposedException(this.GetType().Name); } if (!this.Loaded || category == ThingCategory.Invalid) { return false; } ThingType changedThing = this.InternalRemoveThing(id, category); if (changedThing != null) { this.Changed = true; if (this.StorageChanged != null) { this.StorageChanged(this, new ThingListChangedArgs(new ThingType[] { changedThing }, StorageChangeType.Remove)); } return true; } return false; }