示例#1
0
 // Token: 0x06000097 RID: 151 RVA: 0x00007E60 File Offset: 0x00006060
 public static void SetProjectileSpriteRight(this Projectile proj, string name, int pixelWidth, int pixelHeight, bool lightened = true, tk2dBaseSprite.Anchor anchor = tk2dBaseSprite.Anchor.LowerLeft, int?overrideColliderPixelWidth = null, int?overrideColliderPixelHeight = null, int?overrideColliderOffsetX = null, int?overrideColliderOffsetY = null, Projectile overrideProjectileToCopyFrom = null)
 {
     try
     {
         ETGMod.GetAnySprite(proj).spriteId = ETGMod.Databases.Items.ProjectileCollection.inst.GetSpriteIdByName(name);
         tk2dSpriteDefinition tk2dSpriteDefinition = GunTools.SetupDefinitionForProjectileSprite(name, ETGMod.GetAnySprite(proj).spriteId, pixelWidth, pixelHeight, lightened, overrideColliderPixelWidth, overrideColliderPixelHeight, overrideColliderOffsetX, overrideColliderOffsetY, overrideProjectileToCopyFrom);
         tk2dSpriteDefinition.ConstructOffsetsFromAnchor(anchor, tk2dSpriteDefinition.position3);
     }
     catch (Exception ex)
     {
         ETGModConsole.Log("Ooops! Seems like something got very, Very, VERY wrong. Here's the exception:", false);
         ETGModConsole.Log(ex.ToString(), false);
     }
 }
示例#2
0
        // Token: 0x0600009A RID: 154 RVA: 0x000080AC File Offset: 0x000062AC
        public static tk2dSpriteDefinition SetupDefinitionForProjectileSprite(string name, int id, int pixelWidth, int pixelHeight, bool lightened = true, int?overrideColliderPixelWidth = null, int?overrideColliderPixelHeight = null, int?overrideColliderOffsetX = null, int?overrideColliderOffsetY = null, Projectile overrideProjectileToCopyFrom = null)
        {
            bool flag = overrideColliderPixelWidth == null;

            if (flag)
            {
                overrideColliderPixelWidth = new int?(pixelWidth);
            }
            bool flag2 = overrideColliderPixelHeight == null;

            if (flag2)
            {
                overrideColliderPixelHeight = new int?(pixelHeight);
            }
            bool flag3 = overrideColliderOffsetX == null;

            if (flag3)
            {
                overrideColliderOffsetX = new int?(0);
            }
            bool flag4 = overrideColliderOffsetY == null;

            if (flag4)
            {
                overrideColliderOffsetY = new int?(0);
            }
            float num  = 14f;
            float num2 = 16f;
            float num3 = (float)pixelWidth / num;
            float num4 = (float)pixelHeight / num;
            float x    = (float)overrideColliderPixelWidth.Value / num2;
            float y    = (float)overrideColliderPixelHeight.Value / num2;
            float x2   = (float)overrideColliderOffsetX.Value / num2;
            float y2   = (float)overrideColliderOffsetY.Value / num2;
            tk2dSpriteDefinition tk2dSpriteDefinition = ETGMod.Databases.Items.ProjectileCollection.inst.spriteDefinitions[ETGMod.GetAnySprite(overrideProjectileToCopyFrom ?? (PickupObjectDatabase.GetById(lightened ? 47 : 12) as Gun).DefaultModule.projectiles[0]).spriteId].CopyDefinitionFrom();

            tk2dSpriteDefinition.boundsDataCenter           = new Vector3(num3 / 2f, num4 / 2f, 0f);
            tk2dSpriteDefinition.boundsDataExtents          = new Vector3(num3, num4, 0f);
            tk2dSpriteDefinition.untrimmedBoundsDataCenter  = new Vector3(num3 / 2f, num4 / 2f, 0f);
            tk2dSpriteDefinition.untrimmedBoundsDataExtents = new Vector3(num3, num4, 0f);
            tk2dSpriteDefinition.texelSize             = new Vector2(0.0625f, 0.0625f);
            tk2dSpriteDefinition.position0             = new Vector3(0f, 0f, 0f);
            tk2dSpriteDefinition.position1             = new Vector3(0f + num3, 0f, 0f);
            tk2dSpriteDefinition.position2             = new Vector3(0f, 0f + num4, 0f);
            tk2dSpriteDefinition.position3             = new Vector3(0f + num3, 0f + num4, 0f);
            tk2dSpriteDefinition.colliderVertices[0].x = x2;
            tk2dSpriteDefinition.colliderVertices[0].y = y2;
            tk2dSpriteDefinition.colliderVertices[1].x = x;
            tk2dSpriteDefinition.colliderVertices[1].y = y;
            tk2dSpriteDefinition.name = name;
            ETGMod.Databases.Items.ProjectileCollection.inst.spriteDefinitions[id] = tk2dSpriteDefinition;
            return(tk2dSpriteDefinition);
        }