Advertisement
Guest User

BlockMod Example

a guest
Feb 20th, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using spaar.ModLoader;
  4. using TheGuysYouDespise;
  5. using UnityEngine;
  6.  
  7. namespace Blocks
  8. {
  9.     public class LoadExampleBlock : BlockMod
  10.     {
  11.         /// ModLoader stuff
  12.         /// Set name, author and so on for the blockloader to know what you made.
  13.         public override string Name { get { return "hornBlock"; } }
  14.         public override string DisplayName { get { return "War Horn Block"; } }
  15.         public override string Author { get { return "TheGuysYouDespise"; } }
  16.         public override Version Version { get { return new Version("0.1"); } }
  17.  
  18.         /// <Block-loading-info>
  19.         /// Place .obj file in Mods/Blocks/Obj
  20.         /// Place texture in Mods/Blocks/Textures
  21.         /// Place any additional resources in Mods/Blocks/Resources
  22.         /// </Block-loading-info>
  23.  
  24.         protected Block example = new Block()
  25.             ///ID of the Block
  26.             .ID(300)
  27.  
  28.             ///Name of the Block
  29.             .BlockName("War Horn")
  30.  
  31.             ///Load the 3d model information
  32.             .Obj(new List<Obj> { new Obj("warHorn.obj", //Mesh name with extension (only works for .obj files)
  33.                                          "warHorn.png", //Texture name with extension
  34.                                          new VisualOffset(new Vector3(1f, 1f, 1f), //Scale
  35.                                                           new Vector3(0f, 0f, 0f), //Position
  36.                                                           new Vector3(0f, 0f, 0f)))//Rotation
  37.             })
  38.  
  39.             ///For the button that we will create setup the visual offset needed
  40.             .IconOffset(new Icon(new Vector3( 1.30f,   1.30f,  1.30f),  //Scale
  41.                                  new Vector3(-0.11f,  -0.13f,  0.00f),  //Position
  42.                                  new Vector3(  85f,      90f,   270f))) //Rotation
  43.  
  44.             ///Script, Components, etc. you want to be on your block.
  45.             .Components(new Type[] {
  46.                                     typeof(HornBlock),
  47.             })
  48.  
  49.             ///Properties such as keywords for searching and setting up how how this block behaves to other elements.
  50.             .Properties(new BlockProperties().SearchKeywords(new string[] {
  51.                                                              "Music",
  52.                                                              "Horn",
  53.                                                              "War",
  54.                                                              "War Horn",
  55.                                                              "Trumpet",
  56.                                                              "Sound",
  57.                                              })
  58.                                              //.Burnable(3f)
  59.                                              //.CanBeDamaged(3)
  60.             )
  61.  
  62.             ///Mass of the block 0.5 being equal to a double wooden block
  63.             .Mass(0.3f)
  64.  
  65.             ///Display the collider while working on the block if you wish, then replace "true" with "false" when done looking at the colliders.
  66.             .ShowCollider(false)
  67.  
  68.             ///Setup the collier of the block, which can consist of several different colliders.
  69.             ///Therefore we have this CompoundCollider,
  70.             .CompoundCollider(new List<ColliderComposite> {
  71.                                 ColliderComposite.Sphere(0.49f,                                //radius
  72.                                                          new Vector3(-0.10f, -0.05f, 0.27f),   //Position
  73.                                                          new Vector3(0f, 0f, 0f))              //Rotation
  74.                                                          .IgnoreForGhost(),                    //Do not use this collider on the ghost
  75.  
  76.                                 ColliderComposite.Capsule(0.33f,                               //radius
  77.                                                           1.33f,                               //length
  78.                                                           Direction.Y,                         //direction
  79.                                                           new Vector3(-0.52f, 0.38f, 0.30f),   //position
  80.                                                           new Vector3(5f, 0f, -5f)),           //rotation
  81.                                
  82.                                 ColliderComposite.Capsule(0.20f,                               //radius
  83.                                                           0.90f,                               //length
  84.                                                           Direction.X,                         //direction
  85.                                                           new Vector3(-0.1f, -0.36f, 0.40f),   //position
  86.                                                           new Vector3(0f, 0f, 0f)),            //rotation
  87.                                
  88.                                 ColliderComposite.Box(new Vector3(0.65f, 0.65f, 0.25f),        //scale
  89.                                                       new Vector3(0f, 0f, 0.25f),              //position
  90.                                                       new Vector3(0f, 0f, 0f)),                //rotation
  91.  
  92.                                 ColliderComposite.Box(new Vector3(0.5f, 0.5f, 0.10f),          //scale
  93.                                                       new Vector3(-0.38f, 1.05f, 0.34f),       //position
  94.                                                       new Vector3(312f, 25f, 337.5f)),         //rotation
  95.                                
  96.                                 ColliderComposite.Box(new Vector3(0.5f, 0.5f, 0.10f),          //scale
  97.                                                       new Vector3(-0.38f, 1.05f, 0.34f),       //position
  98.                                                       new Vector3(312f, 35f, 10f)),            //rotation
  99.                                
  100.                                 ColliderComposite.Sphere(0.5f,                                  //radius
  101.                                                          new Vector3(-0.10f, -0.05f, 0.35f),    //Position
  102.                                                          new Vector3(0f, 0f, 0f))               //Rotation
  103.                                                          .Trigger().Layer(2)
  104.                                                          .IgnoreForGhost(),                     //Do not use this collider on the ghost
  105.                               //ColliderComposite.Box(new Vector3(0.35f, 0.35f, 0.15f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f)).Trigger().Layer(2).IgnoreForGhost(),   <---Example: Box Trigger on specific Layer
  106.             })
  107.  
  108.             ///Make sure a block being placed on another block can intersect with it.
  109.             .IgnoreIntersectionForBase()
  110.  
  111.             ///Load resources that will be needed for the block.
  112.             .NeededResources(new List<NeededResource> {
  113.                                 new NeededResource(ResourceType.Audio, //Type of resource - types available are Audio, Texture, Mesh, and AssetBundle
  114.                                                    "warHorn.ogg")
  115.             })
  116.  
  117.             ///Setup where on your block you can add other blocks.
  118.             .AddingPoints(new List<AddingPoint> {
  119.                                (AddingPoint)new BasePoint(false, true)         //The base point is unique compared to the other adding points, the two booleans represent whether you can add to the base, and whether it sticks automatically.
  120.                                                 .Motionable(false,false,false) //Set each of these booleans to "true" to Let the block rotate around X, Y, Z accordingly
  121.                                                 .SetStickyRadius(0.5f),        //Set the radius of which the base point will connect to others
  122.                               //new AddingPoint(new Vector3(0f, 0f, 0.5f), new Vector3(-90f, 0f, 0f),true).SetStickyRadius(0.3f), <---Example: Top sticky adding point
  123.             });
  124.  
  125.         public override void OnLoad()
  126.         {
  127.             LoadBlock(example);
  128.         }
  129.  
  130.         public override void OnUnload() { }
  131.     }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement