public static Color GetCurrentColor(Color colorOrig, int dashes, int index, PlayerHair self) { if (dashes >= MAX_DASH_COUNT) { return(colorOrig); } int speed = Instance.triggerManager.GetHairSpeed(dashes); int length = Instance.triggerManager.GetHairLength(dashes); float phaseShift = Math.Abs(((float)index / ((float)length)) - 0.01f); float phase = phaseShift + speed / 20.0f * Hyperline.Instance.time; phase -= (float)(Math.Floor(phase)); Color returnV = new Color(0, 0, 0); IHairType hair = Instance.triggerManager.GetHair(dashes); if (hair != null) { returnV = hair.GetColor(colorOrig, phase); if (returnV == null) { returnV = new Color(0, 0, 0); } } return(returnV); }
private static void RenderHairPlayerOutline(PlayerHair self) { PlayerSprite sprite = self.GetSprite(); if (!self.DrawPlayerSpriteOutline) { return; } Vector2 origin = sprite.Position; Color color = sprite.Color; sprite.Color = self.Border * self.Alpha; sprite.Position = origin + new Vector2(0f, -1f); sprite.Render(); sprite.Position = origin + new Vector2(0f, 1f); sprite.Render(); sprite.Position = origin + new Vector2(-1f, 0f); sprite.Render(); sprite.Position = origin + new Vector2(1f, 0f); sprite.Render(); sprite.Color = color; sprite.Position = origin; }
public static Color GetCurrentColor(int dashes, int index, PlayerHair self) { if (dashes >= Settings.HairTypeList.Length) { return(new Color(0, 0, 0)); } int type = (int)Settings.HairTypeList[dashes]; int speed = Settings.HairSpeedList[dashes]; int length = Settings.HairLengthList[dashes]; float phaseShift = Math.Abs(((float)index / ((float)length)) - 0.01f); float phase = phaseShift + speed / 20.0f * Hyperline.Instance.Time; phase -= (float)(Math.Floor(phase)); Color returnV = new Color(0, 0, 0); if (Settings.HairList[dashes, type] != null) { returnV = Settings.HairList[dashes, type].GetColor(phase); if (returnV == null) { returnV = new Color(0, 0, 0); } } return(returnV); }
public void RenderHair(On.Celeste.PlayerHair.orig_Render orig, PlayerHair self) { Player player = self.Entity as Player; if (player == null || self.GetSprite().Mode == PlayerSpriteMode.Badeline || Character == null) { orig(self); return; } if (Character.HasHair) { if (self.Sprite.HasHair) { Vector2 origin = new Vector2(5f, 5f); Color color = self.Border * self.Alpha; Vector2 offset = new Vector2(Character.HairOffset.X * (self.GetHairScale(0).X > 0 ? 1 : -1), Character.HairOffset.Y); if (self.DrawPlayerSpriteOutline) { Color color2 = self.Sprite.Color; Vector2 position = self.Sprite.Position; self.Sprite.Color = color; self.Sprite.Position = position + new Vector2(0f, -1f) + offset; self.Sprite.Render(); self.Sprite.Position = position + new Vector2(0f, 1f) + offset; self.Sprite.Render(); self.Sprite.Position = position + new Vector2(-1f, 0f) + offset; self.Sprite.Render(); self.Sprite.Position = position + new Vector2(1f, 0f) + offset; self.Sprite.Render(); self.Sprite.Color = color2; self.Sprite.Position = position; } self.Nodes[0] = self.Nodes[0].Floor(); if (color.A > 0) { for (int i = 0; i < self.Sprite.HairCount; i++) { MTexture hairTexture = self.GetHairTexture(i); Vector2 hairScale = self.GetHairScale(i); hairTexture.Draw(self.Nodes[i] + new Vector2(-1f, 0f) + offset, origin, color, hairScale); hairTexture.Draw(self.Nodes[i] + new Vector2(1f, 0f) + offset, origin, color, hairScale); hairTexture.Draw(self.Nodes[i] + new Vector2(0f, -1f) + offset, origin, color, hairScale); hairTexture.Draw(self.Nodes[i] + new Vector2(0f, 1f) + offset, origin, color, hairScale); } } for (int num = self.Sprite.HairCount - 1; num >= 0; num--) { self.GetHairTexture(num).Draw(self.Nodes[num] + offset, origin, self.GetHairColor(num), self.GetHairScale(num)); } if (Character.SpriteName.Contains("baldemonika")) { GFX.Game["characters/player/baldemonikaribbon"].Draw(self.Nodes[0] + offset - new Vector2(self.GetHairScale(0).X > 0 ? 1 : -1, 2), origin, Color.White, self.GetHairScale(0)); } } } }
/// <summary> /// Updates the hair, allowing for custom physics. /// </summary> /// <param name="orig">The default function for hair updating.</param> /// <param name="self">The player's hair.</param> /// <remarks> /// It is reccomended to look at the default hair after update before writing this. /// </remarks> public virtual void AfterUpdate(On.Celeste.PlayerHair.orig_AfterUpdate orig, PlayerHair self) { Player player = self.EntityAs <Player>(); if (!(!Hyperline.Settings.DoFeatherColor && player.StateMachine.State == 19)) { player.Hair.Color = Hyperline.GetCurrentColor(Hyperline.Instance.lastColor, player.Dashes, 0, player.Hair); } orig(self); }
void PlayerHair_Render(On.Celeste.PlayerHair.orig_Render orig, PlayerHair self) { //int oldNum = self.Sprite.HairCount; //int newNum = oldNum - 4 + Settings.HairLength; //Player player = self.Entity as Player; //if (Settings.Enabled && newNum <= countCache) //{ //self.Sprite.HairCount = newNum; //} orig(self); //self.Sprite.HairCount = oldNum; }
public Ghost(Player player, GhostData data) : base(player.Position) { Player = player; Data = data; Depth = 1; Sprite = new PlayerSprite(player.Sprite.Mode); Sprite.HairCount = player.Sprite.HairCount; Add(Hair = new PlayerHair(Sprite)); Add(Sprite); Hair.Color = Player.NormalHairColor; Name = new GhostName(this, Data?.Name ?? ""); }
void PlayerHair_Update(On.Celeste.PlayerHair.orig_Update orig, PlayerHair self) { if ((self.Entity as BadelineOldsite) == null && ((self.Entity as Player) != null && Settings.HairLength != HairCount)) { Player player = self.Entity as Player; player.Sprite.HairCount = Settings.HairLength; HairCount = Settings.HairLength; player.Remove(player.Hair); PlayerSpriteMode mode = self.Sprite.Mode; player.Remove(player.Sprite); player.Add(player.Hair = new PlayerHair(player.Sprite)); player.Add(player.Sprite); } if ((self.Entity as BadelineOldsite) == null && (self.Entity as Player) != null) { self.Sprite.HairCount = Settings.HairLength; } orig(self); }
public void RenderHair(On.Celeste.PlayerHair.orig_Render orig, PlayerHair self) { if (!(self.Entity is Player) || !Settings.Enabled || (self.Entity as Player).Dashes > MAX_DASH_COUNT) { orig(self); return; } Player player = self.Entity as Player; IHairType hair = Instance.triggerManager.GetHair(player.Dashes); if (hair != null) { hair.Render(orig, self); } else { orig(self); } }
public void UpdateHairLength(PlayerHair self) { if (Settings.Enabled && self.Entity is Player) { Player player = self.Entity as Player; if (player.StateMachine.State == 5) { player.Sprite.HairCount = 1; } else if (player.StateMachine.State != 19) { player.Sprite.HairCount = ((player.Dashes > 1) ? 5 : 4); player.Sprite.HairCount += lastHairLength - 4; } else if (player.StateMachine.State == 19) { player.Sprite.HairCount = 7; } } }
public CustomPlayerDeadBody(Player player, Vector2 direction, bool endLevel = false, bool muted = true) { base.Depth = -1000000; this.player = player; this.endLevel = endLevel; this.muted = muted; facing = player.Facing; Position = player.Position; Add(hair = player.Hair); Add(sprite = player.Sprite); Add(light = player.Light); sprite.Color = Color.White; initialHairColor = hair.Color; bounce = direction; Add(new Coroutine(DeathRoutine())); }
private void TrySwitchSprite(FinalBoss finalBoss) { if (patternIndex == 0) { PlayerSprite normalSprite = new PlayerSprite(PlayerSpriteMode.Badeline) { Scale = { X = -1f } }; normalSprite.Play("laugh"); PlayerHair normalHair = new PlayerHair(normalSprite) { Color = BadelineOldsite.HairColor, Border = Color.Black, Facing = Facings.Left }; finalBoss.NormalSprite = normalSprite; NormalHairFieldInfo.SetValue(finalBoss, normalHair); finalBoss.Add(normalHair); finalBoss.Add(normalSprite); if (finalBoss.Sprite != null) { normalSprite.Position = finalBoss.Sprite.Position; finalBoss.Remove(finalBoss.Sprite); if (finalBoss.Get <SpriteRemovedComponent>() == null) { finalBoss.Add(new SpriteRemovedComponent()); } // 许多方法需要 Sprite 所以暂时设置为 null,等到 OnPlayer 之时才设置为 null // finalBoss.Sprite = null; } } else if (finalBoss.NormalSprite != null) { CreateBossSpriteMethodInfo?.Invoke(finalBoss, null); } }
public Ghost(Player player, GhostData data) : base(player.Position) { Player = player; Data = data; Depth = 1; // Tag = Tags.PauseUpdate; PlayerSpriteMode playerSpriteMode = player.Sprite.Mode; if (GhostModule.ModuleSettings.ReversedPlayerSpriteMode) { if (playerSpriteMode == PlayerSpriteMode.MadelineAsBadeline) { if (player.Inventory.Backpack) { playerSpriteMode = PlayerSpriteMode.MadelineNoBackpack; } else { playerSpriteMode = PlayerSpriteMode.Madeline; } } else { playerSpriteMode = PlayerSpriteMode.MadelineAsBadeline; } } Sprite = new PlayerSprite(playerSpriteMode); Sprite.HairCount = player.Sprite.HairCount; Add(Hair = new PlayerHair(Sprite)); Add(Sprite); Hair.Color = Player.NormalHairColor; Name = new GhostName(this, Data?.Name ?? ""); }
public void Start() { //get spriterenderer components of each character part //(use these .sprite attributes to set sprites) SpriteRenderer BodySprite = PlayerBody.GetComponent <SpriteRenderer>(); SpriteRenderer EyesSprite = PlayerEyes.GetComponent <SpriteRenderer>(); SpriteRenderer MouthSprite = PlayerMouth.GetComponent <SpriteRenderer>(); SpriteRenderer HairSprite = PlayerHair.GetComponent <SpriteRenderer>(); SpriteRenderer ClothesSprite = PlayerClothes.GetComponent <SpriteRenderer>(); SpriteRenderer HatSprite = PlayerHat.GetComponent <SpriteRenderer>(); SpriteRenderer AnimalSprite = PlayerAnimal.GetComponent <SpriteRenderer>(); //check all parts //body switch (PlayerPrefs.GetInt("PlayerBody", 0)) { case (0): BodySprite.sprite = Body1; break; case (1): BodySprite.sprite = Body2; break; case (2): BodySprite.sprite = Body3; break; case (3): BodySprite.sprite = Body4; break; } //eyes switch (PlayerPrefs.GetInt("PlayerEyes", 0)) { case (0): EyesSprite.sprite = Eyes1; break; case (1): EyesSprite.sprite = Eyes2; break; case (2): EyesSprite.sprite = Eyes3; break; case (3): EyesSprite.sprite = Eyes4; break; } //mouth switch (PlayerPrefs.GetInt("PlayerMouth", 0)) { case (0): MouthSprite.sprite = Mouth1; break; case (1): MouthSprite.sprite = Mouth2; break; } //hair switch (PlayerPrefs.GetInt("PlayerHair", 0)) { case (0): HairSprite.sprite = Hair1; break; case (1): break; } //clothes switch (PlayerPrefs.GetInt("PlayerClothes", 0)) { case (0): ClothesSprite.sprite = Robe1Red; break; case (1): ClothesSprite.sprite = Robe1Blue; break; case (2): ClothesSprite.sprite = Robe1Green; break; case (3): ClothesSprite.sprite = Robe1Grey; break; case (4): ClothesSprite.sprite = Robe1Orange; break; case (5): ClothesSprite.sprite = Robe1Purple; break; case (6): ClothesSprite.sprite = Robe2Red; break; case (7): ClothesSprite.sprite = Robe2Blue; break; case (8): ClothesSprite.sprite = Robe2Green; break; case (9): ClothesSprite.sprite = Robe2Grey; break; case (10): ClothesSprite.sprite = Robe2Orange; break; case (11): ClothesSprite.sprite = Robe2Purple; break; case (12): ClothesSprite.sprite = Robe3Red; break; case (13): ClothesSprite.sprite = Robe3Blue; break; case (14): ClothesSprite.sprite = Robe3Green; break; case (15): ClothesSprite.sprite = Robe3Grey; break; case (16): ClothesSprite.sprite = Robe3Orange; break; case (17): ClothesSprite.sprite = Robe3Purple; break; case (18): ClothesSprite.sprite = Clothes1; break; } //hat switch (PlayerPrefs.GetInt("PlayerHat", 0)) { case (0): HatSprite.sprite = Hat1; break; case (1): break; } //animal switch (PlayerPrefs.GetInt("PlayerAnimal", 0)) { case (0): AnimalSprite.sprite = Bunny; break; case (1): AnimalSprite.sprite = Turtle; break; } }
public static PlayerSprite GetSprite(this PlayerHair self) => ((patch_PlayerHair)self).Sprite;
public static Color GetHairColor(this PlayerHair self, int index) => ((patch_PlayerHair)self).GetHairColor(index);
// Mods can't access patch_ classes directly. // We thus expose any new members through extensions. public static Vector2 GetHairScale(this PlayerHair self, int index) => ((patch_PlayerHair)self).PublicGetHairScale(index);
private MTexture PlayerHairGetHairTextureHook(On.Celeste.PlayerHair.orig_GetHairTexture orig, PlayerHair self, int index) { if (Settings.SelectedSkinMod != SkinModHelperConfig.DEFAULT_SKIN) { if (index == 0) { string newBangsPath = skinConfigs[Settings.SelectedSkinMod].GetUniquePath() + "characters/player/bangs"; if (GFX.Game.Has(newBangsPath + "00")) { return(GFX.Game.GetAtlasSubtextures(newBangsPath)[self.Sprite.HairFrame]); } } string newHairPath = skinConfigs[Settings.SelectedSkinMod].GetUniquePath() + "characters/player/hair00"; if (GFX.Game.Has(newHairPath)) { return(GFX.Game[newHairPath]); } } return(orig(self, index)); }
public extern void orig_Init(TrailManager manager, int index, Vector2 position, Image sprite, PlayerHair hair, Color color, float duration, int depth);
private void PlayerHair_AfterUpdate(On.Celeste.PlayerHair.orig_AfterUpdate orig, PlayerHair self) { if (!(self.Entity is Player) || !Settings.Enabled || (self.Entity as Player).Dashes > MAX_DASH_COUNT) { orig(self); return; } Player player = (Player)self.Entity; Instance.time += Engine.DeltaTime; maddyCrownSprite = null; Instance.UpdateHairLength(self); IHairType hair = Instance.triggerManager.GetHair(player.Dashes); if (hair != null) { hair.AfterUpdate(orig, self); } else { orig(self); //this really shouldn't happen, only happens when using the load command from the main menu, so we'll reload the trigger manager triggerManager.LoadFromSettings(); } }
public static Color GetHairColor(On.Celeste.PlayerHair.orig_GetHairColor orig, PlayerHair self, int index) { Color colorOrig = orig(self, index); if (!(self.Entity is Player) || !Settings.Enabled) { return(colorOrig); } Player player = self.Entity as Player; if (player.Dashes >= MAX_DASH_COUNT || player.Dashes < 0 || (!Settings.DoFeatherColor && player.StateMachine.State == 19)) { return(colorOrig); } Color ReturnC = GetCurrentColor(colorOrig, ((Player)self.Entity).Dashes, index, self); if (index == 0) { Instance.UpdateMaddyCrown(self.Entity as Player); Instance.lastColor = ReturnC; Instance.lastHairLength = Instance.triggerManager.GetHairLength(((Player)self.Entity).Dashes); } if (IHairType.IsFlash() && Settings.DoDashFlash) { return(Player.FlashHairColor); } return(ReturnC); }
public static Color GetHairColor(On.Celeste.PlayerHair.orig_GetHairColor orig, PlayerHair self, int index) { Color colorOrig = orig(self, index); Ghost ghost = self.Entity as Ghost; GhostNetClient client = GhostNetModule.Instance.Client; uint playerID; GhostNetFrame frame; ChunkUUpdate update; if (ghost == null || client == null || !client.GhostPlayerIDs.TryGetValue(ghost, out playerID) || !client.UpdateMap.TryGetValue(playerID, out frame) || (update = frame) == null) { return(colorOrig); } if (index < 0 || update.HairColors.Length <= index) { return(Color.Transparent); } return(update.HairColors[index]); }
public static MTexture GetHairTexture(On.Celeste.PlayerHair.orig_GetHairTexture orig, PlayerHair self, int index) { if (!(self.Entity is Player) || !Settings.Enabled) { return(orig(self, index)); } Player player = self.Entity as Player; if (player.Dashes >= MAX_DASH_COUNT || player.Dashes < 0) { return(orig(self, index)); } if (index == 0) //bangs { if (Settings.hairBangs[player.Dashes] == null || Settings.hairBangs[player.Dashes].Count == 0) { return(orig(self, index)); } return(Settings.hairBangs[player.Dashes][self.GetSprite().HairFrame % Settings.hairBangs[player.Dashes].Count]); } if (Settings.hairTextures[player.Dashes] == null || Settings.hairTextures[player.Dashes].Count == 0) { return(orig(self, index)); } return(Settings.hairTextures[player.Dashes][index % Settings.hairTextures[player.Dashes].Count]); }
public static MTexture GetHairTexture(On.Celeste.PlayerHair.orig_GetHairTexture orig, PlayerHair self, int index) { MTexture texOrig = orig(self, index); Ghost ghost = self.Entity as Ghost; GhostNetClient client = GhostNetModule.Instance.Client; uint playerID; GhostNetFrame frame; ChunkUUpdate update; if (ghost == null || client == null || !client.GhostPlayerIDs.TryGetValue(ghost, out playerID) || !client.UpdateMap.TryGetValue(playerID, out frame) || (update = frame) == null) { return(texOrig); } if (index < 0 || update.HairColors.Length <= index) { return(texOrig); } string texName = update.HairTextures[index]; if (!GFX.Game.Has(texName)) { return(texOrig); } return(GFX.Game[texName]); }
private void CreateMadelineSprite(bool badeline = false) { PlayerSpriteMode mode; if (badeline) { mode = PlayerSpriteMode.Badeline; } else { bool backpack = player.SceneAs <Level>()?.Session.Inventory.Backpack ?? true; mode = backpack ? PlayerSpriteMode.Madeline : PlayerSpriteMode.MadelineNoBackpack; } PlayerSprite origSprite = player.Sprite; if (playerSprite != null) { origSprite = playerSprite; } playerSprite = new PlayerSprite(mode) { Position = origSprite.Position, Rotation = origSprite.Rotation, HairCount = origSprite.HairCount, Scale = origSprite.Scale, Rate = origSprite.Rate, Justify = origSprite.Justify }; if (player.StateMachine.State == Player.StStarFly) { playerSprite.Color = StarFlyColor; } playerSprite.Scale.X = playerSprite.Scale.Abs().X *(int)facing; playerSprite.Active = false; try { if (!string.IsNullOrEmpty(origSprite.CurrentAnimationID)) { playerSprite.Play(origSprite.CurrentAnimationID); playerSprite.SetAnimationFrame(origSprite.CurrentAnimationFrame); } } // ReSharper disable once EmptyGeneralCatchClause catch (Exception) { } if (playerHair == null) { playerHair = new PlayerHair(playerSprite) { Alpha = player.Hair.Alpha, Facing = facing, Border = player.Hair.Border, DrawPlayerSpriteOutline = player.Hair.DrawPlayerSpriteOutline }; Vector2[] nodes = new Vector2[player.Hair.Nodes.Count]; player.Hair.Nodes.CopyTo(nodes); playerHair.Nodes = nodes.ToList(); playerHair.Active = false; } Color hairColor = Player.NormalHairColor; if (player.StateMachine.State != Player.StStarFly) { switch (player.Dashes) { case 0: hairColor = badeline ? Player.UsedBadelineHairColor : Player.UsedHairColor; break; case 1: hairColor = badeline ? Player.NormalBadelineHairColor : Player.NormalHairColor; break; case 2: hairColor = badeline ? Player.TwoDashesBadelineHairColor : Player.TwoDashesHairColor; break; } } else { hairColor = StarFlyColor; } playerHair.Color = hairColor; }
// Mods can't access patch_ classes directly. // We thus expose any new members through extensions. /// <summary> /// Get the current player hair texture for the given hair segment. /// </summary> public static MTexture GetHairTexture(this PlayerHair self, int index) => ((patch_PlayerHair)self).GetHairTexture(index);
public new void Init(TrailManager manager, int index, Vector2 position, Image sprite, PlayerHair hair, Color color, float duration, int depth) { orig_Init(manager, index, position, sprite, hair, color, duration, depth); // Fixed an issue with vanilla itself, player's body trail is always facing right if (!Everest.Flags.IsDisabled && sprite != null && hair != null) { SpriteScale.X = SpriteScale.Abs().X *(int)hair.Facing; } }
public static float GetWave(this PlayerHair self) => ((patch_PlayerHair)self).Wave;
public override void AfterUpdate(On.Celeste.PlayerHair.orig_AfterUpdate orig, PlayerHair self) { orig(self); }
private static void onPlayerHairRender(On.Celeste.PlayerHair.orig_Render orig, PlayerHair self) { // display hair only if it is enabled, or that it doesn't belong to a Player entity. if (HasHair || !(self.Entity is Player)) { orig(self); } }