From 5af8e025bdd8e86bd869de7adc3d9516ff00e1f0 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Thu, 25 Jul 2019 17:16:14 -0700 Subject: [PATCH] Added in arcade cabinet type. Added in seaside scramble. --- .../Arcade/SeasideScrambleArcade.png | Bin 0 -> 899 bytes .../Objects/Extras/ArcadeFactoryInfo.cs | 32 +++ .../SSCMenus/HUD/CharacterHUD.cs | 10 +- .../SeasideScrambleMinigame/SSCPlayer.cs | 97 +++++++- .../Objects/Extras/ArcadeCabinetOBJ.cs | 148 +++++++++++ .../Objects/Extras/ArcadeCabinetTile.cs | 230 ++++++++++++++++++ .../Furniture/ArcadeCabinetInformation.cs | 27 ++ .../Framework/Utilities/RotationUtilities.cs | 16 +- GeneralMods/Revitalize/ModCore.cs | 40 ++- GeneralMods/Revitalize/Revitalize.csproj | 11 +- 10 files changed, 591 insertions(+), 20 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Furniture/Arcade/SeasideScrambleArcade.png create mode 100644 GeneralMods/Revitalize/Framework/Factories/Objects/Extras/ArcadeFactoryInfo.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/ArcadeCabinetInformation.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Furniture/Arcade/SeasideScrambleArcade.png b/GeneralMods/Revitalize/Content/Graphics/Furniture/Arcade/SeasideScrambleArcade.png new file mode 100644 index 0000000000000000000000000000000000000000..4d37d3bd0699eb901b2aa36b1be9ffbfbba0991d GIT binary patch literal 899 zcmV-}1AP36P)$V2D`Iix2f;5rd&6^C2G# z24SQR3c3DZ|5k+f6jAvJpJ$L7B=h}8hUpSn5?)iOw|8{o9Kp{=*)&0Jp zelD)-=i<8V_XTxL>(y1Zh4L;L0$7}%=IFII{ApYU;9hAFXID4yysO~JjRRCxw*Zh# z-g3!~obnz4`))@7SPV^DGCaGwVOa}1deDWFLU@jz*oHfpI-==6zxb{Fpe;MF!`E`)c|<*kvC%8Ugfn@whkV}$9Qq%5Y11YXYD!V-LiqIGFhVK zV$PHkKJPQ2a##rO0k~XN?#My!=3EHx+FR<=wdiL@4w8`?01DyV@ diff --git a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs index 2e029175..d4698417 100644 --- a/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs +++ b/GeneralMods/Revitalize/Framework/Minigame/SeasideScrambleMinigame/SSCPlayer.cs @@ -78,7 +78,31 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame /// /// The current gun the player is holding. UPDATE THIS TO WEILD MULTIPLE GUNS!!! /// - public SSCGuns.SSCGun gun; + public SSCGuns.SSCGun activeGun + { + get + { + return this.guns[this.currentGunIndex]; + } + set + { + if (value == null) return; + this.guns.Add(value); + this.currentGunIndex = this.guns.Count - 1; + } + } + + public List guns; + public int currentGunIndex; + + /// + /// How long it takes for the player to swap guns. + /// + public int swapSpeed = 20; + /// + /// How many frames remain until the player is allowed to swap guns/ + /// + public int timeUntilPlayerCanSwapGun; /// /// The hitbox for the player. @@ -216,8 +240,15 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame } this.mouseSensitivity = new Vector2(3f, 3f); + + this.currentGunIndex = 0; + this.guns = new List(); + this.getNewGun(SeasideScramble.self.guns.getGun("Icicle")); //new SSCGuns.SSCGun(new StardustCore.Animations.AnimatedSprite("MyFirstGun", this.position, new AnimationManager(SeasideScramble.self.textureUtils.getExtendedTexture("Guns", "BasicGun"), new Animation(0, 0, 16, 16)), Color.White), SeasideScramble.self.entities.projectiles.getDefaultProjectile(this, this.position, Vector2.Zero, 4f, new Rectangle(0, 0, 16, 16), Color.White, 4f, 300), 10, 1000, 3000); - + this.getNewGun(SeasideScramble.self.guns.getGun("HeatWave")); + this.getNewGun(SeasideScramble.self.guns.getGun("Default")); + + this.timeUntilPlayerCanSwapGun = 0; this.hitBox = new Rectangle((int)this.position.X, (int)this.position.Y, 64, 64); @@ -282,7 +313,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame public void draw(SpriteBatch b, Vector2 position) { this.characterSpriteController.draw(b, SeasideScramble.GlobalToLocal(SeasideScramble.self.camera.viewport, position), this.playerColor, 4f, this.flipSprite == true ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (this.position.Y) / 10000f)); - this.gun.draw(b, SeasideScramble.GlobalToLocal(SeasideScramble.self.camera.viewport, position), 2f); + this.activeGun.draw(b, SeasideScramble.GlobalToLocal(SeasideScramble.self.camera.viewport, position), 2f); } public void drawMouse(SpriteBatch b) { @@ -310,8 +341,11 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame } if (this.currentHealth < 0) this.currentHealth = 0; - this.gun.update(Time); + this.activeGun.update(Time); this.updateGunPosition(); + this.timeUntilPlayerCanSwapGun--; + if (this.timeUntilPlayerCanSwapGun < 0) this.timeUntilPlayerCanSwapGun = 0; + this.HUD.update(Time); this.statusEffects.update(Time); @@ -416,6 +450,15 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame this.shoot(unit); //this.moveMouseCursor(state.ThumbSticks.Right); } + if (state.IsButtonDown(Buttons.RightShoulder)) + { + this.swapGun(1); + } + if (state.IsButtonDown(Buttons.LeftShoulder)) + { + this.swapGun(-1); + } + } else { @@ -478,7 +521,10 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame if (this.playerID == SSCEnums.PlayerID.One) { this.checkForMovementInput(k); + if (k == Keys.Q) this.swapGun(-1); + if(k== Keys.E) this.swapGun(1); } + } /// @@ -630,7 +676,7 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame //ModCore.log("Shoot: " + direction); //SeasideScramble.self.projectiles.spawnDefaultProjectile(this, this.position, direction, 1f, new Rectangle(0, 0, 16, 16), Color.White, 4f, 300); - this.gun.tryToShoot(this.position, direction); + this.activeGun.tryToShoot(this.position, direction); } @@ -700,16 +746,47 @@ namespace Revitalize.Framework.Minigame.SeasideScrambleMinigame public void getNewGun(SSCGuns.SSCGun gun) { - this.gun = gun; + this.activeGun = gun; //this.gun.Projectile.position = this.position; - this.gun.Position = this.position; - this.gun.Projectile.owner = this; + this.activeGun.Position = this.position; + this.activeGun.Projectile.owner = this; } public void updateGunPosition() { - this.gun.Projectile.position = this.position; - this.gun.Position = this.position; + this.activeGun.Projectile.position = this.position; + this.activeGun.Position = this.position; + } + + /// + /// Swaps the player's gun they are holding. + /// + /// + public void swapGun(int delta) + { + if (this.timeUntilPlayerCanSwapGun > 0) return; + if (delta < 0) + { + if (this.currentGunIndex <= 0) + { + this.currentGunIndex = this.guns.Count - 1; + Game1.soundBank.PlayCue("shwip"); + this.timeUntilPlayerCanSwapGun = this.swapSpeed; + } + else + { + this.currentGunIndex--; + Game1.soundBank.PlayCue("shwip"); + this.timeUntilPlayerCanSwapGun = this.swapSpeed; + } + } + else + { + this.currentGunIndex++; + if (this.currentGunIndex >= this.guns.Count) this.currentGunIndex = 0; + Game1.soundBank.PlayCue("shwip"); + this.timeUntilPlayerCanSwapGun = this.swapSpeed; + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs new file mode 100644 index 00000000..cd318be6 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetOBJ.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using PyTK.CustomElementHandler; +using StardewValley; + +namespace Revitalize.Framework.Objects.Extras +{ + public class ArcadeCabinetOBJ:MultiTiledObject + { + public ArcadeCabinetOBJ() : base() + { + + } + + public ArcadeCabinetOBJ(CustomObjectData PyTKData, BasicItemInformation Info) : base(PyTKData, Info) + { + + } + + public ArcadeCabinetOBJ(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TilePosition) : base(PyTKData, Info, TilePosition) + { + + } + + public ArcadeCabinetOBJ(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TilePosition, Dictionary Objects) : base(PyTKData, Info, TilePosition, Objects) + { + + + } + + public override void rotate() + { + base.rotate(); + } + + public override Item getOne() + { + Dictionary objs = new Dictionary(); + foreach (var pair in this.objects) + { + objs.Add(pair.Key, (MultiTiledComponent)pair.Value.getOne()); + } + + + return new ArcadeCabinetOBJ(this.data, this.info, this.TileLocation, objs); + } + + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + ArcadeCabinetOBJ obj = (ArcadeCabinetOBJ)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (obj == null) + { + return null; + } + + Dictionary guids = new Dictionary(); + + foreach (KeyValuePair pair in obj.childrenGuids) + { + guids.Add(pair.Key, pair.Value); + } + + foreach (KeyValuePair pair in guids) + { + obj.childrenGuids.Remove(pair.Key); + //Revitalize.ModCore.log("DESERIALIZE: " + pair.Value.ToString()); + ArcadeCabinetTile component = Revitalize.ModCore.Serializer.DeserializeGUID(pair.Value.ToString()); + component.InitNetFields(); + + obj.addComponent(pair.Key, component); + + + } + obj.InitNetFields(); + + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["GUID"])) + { + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["GUID"], obj); + return obj; + } + else + { + return Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]]; + } + + + } + + + public override bool canBePlacedHere(GameLocation l, Vector2 tile) + { + return base.canBePlacedHere(l, tile); + } + + public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) + { + foreach (KeyValuePair pair in this.objects) + { + if (!this.isPlaceable()) + return; + int x = Game1.getOldMouseX() + Game1.viewport.X + (int)((pair.Value as MultiTiledComponent).offsetKey.X * Game1.tileSize); + int y = Game1.getOldMouseY() + Game1.viewport.Y + (int)((pair.Value as MultiTiledComponent).offsetKey.Y * Game1.tileSize); + if ((double)Game1.mouseCursorTransparency == 0.0) + { + x = ((int)Game1.player.GetGrabTile().X + (int)((pair.Value as MultiTiledComponent).offsetKey.X)) * 64; + y = ((int)Game1.player.GetGrabTile().Y + (int)((pair.Value as MultiTiledComponent).offsetKey.Y)) * 64; + } + if (Game1.player.GetGrabTile().Equals(Game1.player.getTileLocation()) && (double)Game1.mouseCursorTransparency == 0.0) + { + Vector2 translatedVector2 = Utility.getTranslatedVector2(Game1.player.GetGrabTile(), Game1.player.FacingDirection, 1f); + translatedVector2 += (pair.Value as MultiTiledComponent).offsetKey; + x = (int)translatedVector2.X * 64; + y = (int)translatedVector2.Y * 64; + } + bool flag = (pair.Value as MultiTiledComponent).canBePlacedHere(location, new Vector2(x / Game1.tileSize, y / Game1.tileSize)); + spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)(x / 64 * 64 - Game1.viewport.X), (float)(y / 64 * 64 - Game1.viewport.Y)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(flag ? 194 : 210, 388, 16, 16)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.01f); + + + (pair.Value as MultiTiledComponent).draw(spriteBatch, x / Game1.tileSize, y / Game1.tileSize, 0.5f); + //break; + //this.draw(spriteBatch, x / 64, y / 64, 0.5f); + } + } + + public override void pickUp() + { + + bool canPickUp = this.removeAndAddToPlayersInventory(); + if (canPickUp) + { + foreach (KeyValuePair pair in this.objects) + { + (pair.Value as ArcadeCabinetTile).removeFromLocation((pair.Value as ArcadeCabinetTile).location, pair.Key); + } + this.location = null; + } + else + Game1.showRedMessage("NOOOOOOOO"); + + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs new file mode 100644 index 00000000..52250919 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Extras/ArcadeCabinetTile.cs @@ -0,0 +1,230 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Objects.Furniture; +using Revitalize.Framework.Objects.InformationFiles.Furniture; +using Revitalize.Framework.Utilities.Serialization; +using StardewValley; +using StardewValley.Minigames; + +namespace Revitalize.Framework.Objects.Extras +{ + public class ArcadeCabinetTile : FurnitureTileComponent + { + public ArcadeCabinetInformation arcadeInfo; + + public ArcadeCabinetTile() : base() + { + + } + + public ArcadeCabinetTile(CustomObjectData PyTKData, BasicItemInformation Info, ArcadeCabinetInformation ArcadeInfo) : base(PyTKData, Info) + { + this.arcadeInfo = ArcadeInfo; + } + + public ArcadeCabinetTile(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TileLocation, ArcadeCabinetInformation ArcadeInfo) : base(PyTKData, Info, TileLocation) + { + this.arcadeInfo = ArcadeInfo; + } + + + public override bool performObjectDropInAction(Item dropInItem, bool probe, Farmer who) + { + return false; //this.pickUpItem()==PickUpState.DoNothing; + //return base.performObjectDropInAction(dropInItem, probe, who); + } + + public override bool performDropDownAction(Farmer who) + { + return base.performDropDownAction(who); + } + + //Checks for any sort of interaction IF and only IF there is a held object on this tile. + public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) + { + MouseState mState = Mouse.GetState(); + KeyboardState keyboardState = Game1.GetKeyboardState(); + + if (mState.RightButton == ButtonState.Pressed && (!keyboardState.IsKeyDown(Keys.LeftShift) || !keyboardState.IsKeyDown(Keys.RightShift))) + { + return this.rightClicked(who); + } + + if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift))) + return this.shiftRightClicked(who); + + + //return base.checkForAction(who, justCheckingForActivity); + + if (justCheckingForActivity) + return true; + + return true; + + //return this.clicked(who); + //return false; + } + + public override bool performToolAction(Tool t, GameLocation location) + { + return base.performToolAction(t, location); + } + + public override bool performUseAction(GameLocation location) + { + return base.performUseAction(location); + } + + /// + /// Gets called when there is no actively held item on the tile. + /// + /// + /// + public override bool clicked(Farmer who) + { + return base.clicked(who); + } + + public override bool rightClicked(Farmer who) + { + if (Game1.menuUp || Game1.currentMinigame != null) return false; + if (this.arcadeInfo.minigame != null) + { + if (this.arcadeInfo.minigame is StardewValley.Minigames.IMinigame) + { + if (this.arcadeInfo.freezeState == false) + { + Game1.currentMinigame = (IMinigame)Activator.CreateInstance(this.arcadeInfo.minigame.GetType()); + return true; + } + else + { + Game1.currentMinigame = this.arcadeInfo.minigame; + return true; + } + } + } + return false; + } + + + public override bool shiftRightClicked(Farmer who) + { + return base.shiftRightClicked(who); + } + + + public override Item getOne() + { + ArcadeCabinetTile component = new ArcadeCabinetTile(this.data, this.info, this.arcadeInfo); + component.containerObject = this.containerObject; + component.offsetKey = this.offsetKey; + return component; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + //instead of using this.offsetkey.x use get additional save data function and store offset key there + + Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"])); + ArcadeCabinetTile self = Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["GUID"]); + if (self == null) + { + return null; + } + + if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"])) + { + //Get new container + ArcadeCabinetOBJ obj = (ArcadeCabinetOBJ)Revitalize.ModCore.Serializer.DeserializeGUID(additionalSaveData["ParentGUID"]); + self.containerObject = obj; + obj.addComponent(offsetKey, self); + //Revitalize.ModCore.log("ADD IN AN OBJECT!!!!"); + Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj); + } + else + { + self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]]; + Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self); + //Revitalize.ModCore.log("READD AN OBJECT!!!!"); + } + + return (ICustomObject)self; + } + + public override Dictionary getAdditionalSaveData() + { + Dictionary saveData = base.getAdditionalSaveData(); + Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this); + + return saveData; + + } + + /// What happens when the object is drawn at a tile location. + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + /* + if (this.info.ignoreBoundingBox == true) + { + x *= -1; + y *= -1; + } + */ + + if (this.info == null) + { + Revitalize.ModCore.log("info is null"); + if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC"); + } + if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); + if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); + + //The actual planter box being drawn. + if (this.animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + ModCore.ModMonitor.Log("Tex Extended is null???"); + + spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(y * Game1.tileSize) / 10000f)); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + float addedDepth = 0; + + + if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up) + { + addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y)); + if (this.info.ignoreBoundingBox) addedDepth += 1.5f; + } + else if (this.info.ignoreBoundingBox) + { + addedDepth += 1.0f; + } + this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)((y + addedDepth) * Game1.tileSize) / 10000f) + .00001f); + try + { + this.animationManager.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + if (this.heldObject.Value != null) SpriteBatchUtilities.Draw(spriteBatch, this, this.heldObject.Value, alpha, addedDepth); + } + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/ArcadeCabinetInformation.cs b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/ArcadeCabinetInformation.cs new file mode 100644 index 00000000..7ee57751 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/InformationFiles/Furniture/ArcadeCabinetInformation.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using StardewValley.Minigames; + +namespace Revitalize.Framework.Objects.InformationFiles.Furniture +{ + public class ArcadeCabinetInformation + { + + public IMinigame minigame; + public bool freezeState; + + public ArcadeCabinetInformation() + { + this.minigame = null; + this.freezeState = false; + } + public ArcadeCabinetInformation(IMinigame Minigame, bool FreezeState) + { + this.minigame = Minigame; + this.freezeState = FreezeState; + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Utilities/RotationUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/RotationUtilities.cs index fb6b60e0..8c31a603 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/RotationUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/RotationUtilities.cs @@ -64,6 +64,20 @@ namespace Revitalize.Framework.Utilities } + public static float getRadiansFromVector(Vector2 vec) + { + Vector2 zero = new Vector2(1, 0); + vec = vec.UnitVector(); + float dot = Vector2.Dot(zero, vec); + float len1 = vec.Length(); + float len2 = zero.Length(); + float lenTotal = len1 * len2; + float cosAngle = dot / lenTotal; + + float angle = (float)((Math.Acos(cosAngle))); + return angle; + } + /// /// Gets a rotation amount for xna based off the unit circle. /// @@ -71,7 +85,7 @@ namespace Revitalize.Framework.Utilities /// public static float getRotationFromVector(Vector2 vec) { - return getRotationFromDegrees((int)Math.Round(getAngleFromVector(vec))); + return getRadiansFromVector(vec); } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 500ca4ff..16bff745 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -19,6 +19,8 @@ using StardewValley.Objects; using StardustCore.UIUtilities; using StardustCore.Animations; using StardewValley.Menus; +using Revitalize.Framework.Objects.Extras; +using Revitalize.Framework.Minigame.SeasideScrambleMinigame; namespace Revitalize { @@ -164,7 +166,6 @@ namespace Revitalize TextureManager.GetTextureManager(Manifest,"Furniture").searchForTextures(ModHelper,this.ModManifest,Path.Combine("Content", "Graphics", "Furniture")); TextureManager.AddTextureManager(Manifest, "InventoryMenu"); TextureManager.GetTextureManager(Manifest, "InventoryMenu").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus","InventoryMenu")); - //TextureManager.addTexture("Furniture","Oak Chair", new Texture2DExtended(this.Helper, this.ModManifest, Path.Combine("Content","Graphics","Furniture", "Chairs", "Oak Chair.png"))); //Framework.Graphics.TextureManager.TextureManagers.Add("Furniture", new TextureManager(this.Helper.DirectoryPath, Path.Combine("Content", "Graphics", "Furniture"))); @@ -241,6 +242,37 @@ namespace Revitalize FurnitureFactory.LoadFurnitureFiles(); + + SeasideScramble sscGame = new SeasideScramble(); + ArcadeCabinetTile ssc1 = new ArcadeCabinetTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", TextureManager.GetTexture(Manifest, "Furniture", "SeasideScrambleArcade"), typeof(ArcadeCabinetTile), Color.White), new BasicItemInformation("Seaside Scramble Arcade Game", "Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", "A arcade to play Seaside Scramble!", "Arcades", Color.LimeGreen, -300, 0, false, 100, Vector2.Zero, true, true, TextureManager.GetTexture(Manifest, "Furniture", "SeasideScrambleArcade"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "SeasideScrambleArcade"), new Animation(new Rectangle(0, 0, 16, 16)), new Dictionary>() + { + {"Animated",new List() + { + new Animation(0,0,16,16,60), + new Animation(16,0,16,16,60) + } + } + + },"Animated"), Color.White, false, null, null),new Framework.Objects.InformationFiles.Furniture.ArcadeCabinetInformation(sscGame,false)); + ArcadeCabinetTile ssc2 = new ArcadeCabinetTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", TextureManager.GetTexture(Manifest, "Furniture", "SeasideScrambleArcade"), typeof(ArcadeCabinetTile), Color.White), new BasicItemInformation("Seaside Scramble Arcade Game", "Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", "A arcade to play Seaside Scramble!", "Arcades", Color.LimeGreen, -300, 0, false, 100, Vector2.Zero, true, true, TextureManager.GetTexture(Manifest, "Furniture", "SeasideScrambleArcade"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "SeasideScrambleArcade"), new Animation(new Rectangle(0, 16, 16, 16)), new Dictionary>() + { + {"Animated",new List() + { + new Animation(0,16,16,16,60), + new Animation(16,16,16,16,60) + } + } + + }, "Animated"), Color.White, false, null, null), new Framework.Objects.InformationFiles.Furniture.ArcadeCabinetInformation(sscGame, false)); + + ArcadeCabinetOBJ sscCabinet = new ArcadeCabinetOBJ(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", TextureManager.GetTexture(Manifest, "Furniture", "SeasideScrambleArcade"), typeof(ArcadeCabinetOBJ), Color.White, true), new BasicItemInformation("Seaside Scramble Arcade Game", "Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", "A arcade to play Seaside Scramble!", "Arcades", Color.LimeGreen, -300, 0, false, 500, Vector2.Zero, true, true, TextureManager.GetTexture(Manifest, "Furniture", "SeasideScrambleArcade"), new AnimationManager(), Color.White, true, null, null)); + sscCabinet.addComponent(new Vector2(0,0),ssc1); + sscCabinet.addComponent(new Vector2(0, 1), ssc2); + + + customObjects.Add("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", sscCabinet); + + ModCore.log("Added in SSC!"); } private void createDirectories() @@ -285,11 +317,13 @@ namespace Revitalize { throw new Exception("Can't run Revitalize in multiplayer due to lack of current support!"); } - Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest")); + // Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest")); //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Chairs.OakChair")); //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest")); - Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Tables.OakTable")); + //Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Tables.OakTable")); Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Lamps.OakLamp")); + + Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble")); /* StardewValley.Tools.Axe axe = new StardewValley.Tools.Axe(); Serializer.Serialize(Path.Combine(this.Helper.DirectoryPath, "AXE.json"), axe); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index dcdba1aa..94376b17 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -57,6 +57,7 @@ + @@ -101,6 +102,8 @@ + + @@ -114,6 +117,7 @@ + @@ -153,6 +157,9 @@ + + PreserveNewest + PreserveNewest @@ -277,6 +284,8 @@ Always - + + + \ No newline at end of file