void IMyPlayerCollection.TryExtendControl(ModAPI.Interfaces.IMyControllableEntity entityWithControl, IMyEntity entityGettingControl) { var e1 = entityWithControl as Sandbox.Game.Entities.IMyControllableEntity; var e2 = entityGettingControl as MyEntity; if (e1 != null && e2 != null) TryExtendControl(e1, e2); }
// ******************************** // Device breaks // ******************************** protected virtual void Break(string damageType = "BrokenElectronicsSpark") { if (this.Health > 0.0f && this.Broken) { this.Health = 0.0f; } if (this.Broken) { return; } this.Activated = false; this.Broken = true; if (Array.Exists(ValidParticleEffects, element => element == damageType)) { ModAPI.CreateParticleEffect(damageType, this.transform.position); } else { ModAPI.CreateParticleEffect("BrokenElectronicsSpark", this.transform.position); } this.UpdateActivation(); }
void IMyPlayerCollection.ReduceControl(ModAPI.Interfaces.IMyControllableEntity entityWhichKeepsControl, IMyEntity entityWhichLoosesControl) { var e1 = entityWhichKeepsControl as Sandbox.Game.Entities.IMyControllableEntity; var e2 = entityWhichLoosesControl as MyEntity; if (e1 != null && e2 != null) ReduceControl(e1, e2); }
public static void Main() { // listen for the event that is fired when wires are created ModAPI.OnWireCreated += (sender, wire) => { // check if it is a spring cable if (wire is SpringCableBehaviour) { // make it red wire.SetColor(Color.red); // make it thinner wire.SetThickness(0.05f); } }; // listen for the event that is fired when something is killed ModAPI.OnDeath += (sender, being) => { //notify player of their action ModAPI.Notify("this is really immoral"); }; // listen for gunshot event ModAPI.OnGunShot += (sender, gun) => { //notify player what round the gun uses ModAPI.Notify(gun.Cartridge.name); }; }
//treat it like any other component void Update() { if (Input.GetKey(KeyCode.P)) { ModAPI.Notify("gamer is holding the P key"); } }
private void Awake() { // TODO: Find an even earlier entry point that isn't UnityEngine.ClassLibraryInitializer::Init ModAPI.EntryPoint(); orig_Awake(); }
void ModAPI.IMyMotorBase.Attach(ModAPI.IMyMotorRotor rotor) { if (rotor != null) { MatrixD masterToSlave = rotor.CubeGrid.WorldMatrix * MatrixD.Invert(WorldMatrix); m_connectionState.Value = new State() { TopBlockId = rotor.EntityId, MasterToSlave = masterToSlave }; } }
bool IMyPlayerCollection.TryReduceControl(ModAPI.Interfaces.IMyControllableEntity entityWhichKeepsControl, ModAPI.IMyEntity entityWhichLoosesControl) { var e1 = entityWhichKeepsControl as Sandbox.Game.Entities.IMyControllableEntity; var e2 = entityWhichLoosesControl as MyEntity; if (e1 != null && e2 != null) return TryReduceControl(e1, e2); return false; }
bool IMyPlayerCollection.HasExtendedControl(ModAPI.Interfaces.IMyControllableEntity firstEntity, IMyEntity secondEntity) { var e1 = firstEntity as Sandbox.Game.Entities.IMyControllableEntity; var e2 = secondEntity as MyEntity; if (e1 != null && e2 != null) return HasExtendedControl(e1, e2); return false; }
// Start is called before the first frame update void Start() { sentryBehaviour = gameObject.AddComponent <SentryTurretBehaviour>(); gun = new GameObject(); gun.AddComponent <SpriteRenderer>().sprite = ModAPI.LoadSprite("Sprites/Gun.png"); gun.AddComponent <LaserModBehaviour>(); gun.AddComponent <FirearmBehaviour>(); gun.GetComponent <FirearmBehaviour>().Automatic = true; limbs = FindObjectsOfType <LimbBehaviour>(); }
public void SuiciderDroneDebris() { debrisSprites = new Sprite[] { ModAPI.LoadSprite("Sprites/SuiciderDebris1.png", 1), ModAPI.LoadSprite("Sprites/SuiciderDebris2.png", 1), ModAPI.LoadSprite("Sprites/SuiciderDebris3.png", 1), ModAPI.LoadSprite("Sprites/SuiciderDebris4.png", 1), }; }
public void DefaultDroneDebris() { debrisSprites = new Sprite[] { ModAPI.LoadSprite("Sprites/Debris1Spr.png", 1), ModAPI.LoadSprite("Sprites/Debris2Spr.png", 1), ModAPI.LoadSprite("Sprites/Debris3Spr.png", 1), ModAPI.LoadSprite("Sprites/Debris4Spr.png", 1), }; }
public void setBigBlade(Transform parent, Vector3 rotation, Vector2 position) { GameObject bigBlade = new GameObject(); bigBlade.transform.eulerAngles = rotation; bigBlade.transform.position = position; bigBlade.transform.SetParent(parent); bigBlade.AddComponent<PhysicalBehaviour>(); bigBlade.AddComponent<RotateComponent>(); bigBlade.AddComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("Sprites/Rotor2.png"); }
void Start() { audioSource = gameObject.GetComponent <AudioSource>(); flying = ModAPI.LoadSound("Sfx/DroneFlying.wav"); goingUp = ModAPI.LoadSound("Sfx/DroneBeginFlight.wav"); goingDown = ModAPI.LoadSound("Sfx/DroneStopFlying.wav"); CreateAudioSource(); UpdateActivation(); //StartCoroutine(BEEPBEEPBEEPBEEP(1f)); }
ModAPI.IMyPlayer IMyPlayerCollection.GetPlayerControllingEntity(ModAPI.IMyEntity entity) { var e = entity as MyEntity; if (e != null) { var controller = GetEntityController(e); if (controller != null) { return controller.Player; } } return null; }
private void Awake() { this.Seed = 0; this.mask = (LayerMask)LayerMask.GetMask("Objects", "Bounds"); if (Mathf.Approximately((float)this.gameObject.transform.position.x, (float)170.9647)) { glitched = true; } else { ModAPI.Notify("nice"); } }
// Start is called before the first frame update void Start() { bomberArms = new GameObject(); bomberArms.transform.SetParent(transform); bomberArms.AddComponent <PhysicalBehaviour>(); bomberArms.AddComponent <SpriteRenderer>().sprite = ModAPI.LoadSprite("Sprites/BomberArms.png"); bomberArms.GetComponent <SpriteRenderer>().sortingOrder = 2; bombPreview = new GameObject(); bombPreview.transform.position = new Vector2(bomberArms.transform.position.x, bomberArms.transform.position.y - .1f); bombPreview.transform.SetParent(bomberArms.transform); bombPreview.AddComponent <SpriteRenderer>().sprite = ModAPI.LoadSprite("Sprites/Bomb.png"); bomberArms.GetComponent <SpriteRenderer>().sortingOrder = 1; GetComponent <SpriteRenderer>().sortingOrder = 3; }
// Update is called once per frame void Update() { Collider2D aliveObjectInRadius = Physics2D.OverlapCircle(transform.position, 5f, LayerMask.GetMask("Objects")); //gun.GetComponent<FirearmBehaviour>().barrelPosition = transform.position; //gun.GetComponent<FirearmBehaviour>().barrelDirection = -transform.up; if (aliveObjectInRadius) { /*canFire = true; * if (canFire) * { * firearmBehaviour.Shoot(); * ModAPI.Notify("OPEN FIRE OPEN FIRE"); * }*/ if (Input.anyKeyDown) { buttonPressed = true; } if (buttonPressed) { limbs = FindObjectsOfType <LimbBehaviour>(); ModAPI.Notify("Pressed"); buttonPressed = false; } foreach (LimbBehaviour limb in limbs) { float Threshold = 1e-3f; Vector2 dir = gun.transform.InverseTransformPoint(limbs[13].transform.position); float angle = Vector2.Angle(Vector2.right, dir); angle = dir.y < 0 ? -angle : angle; if (Mathf.Abs(angle) > Threshold) { gun.transform.Rotate(0, 0, (angle + 90) * 10 * Time.deltaTime); } //gun.GetComponent<FirearmBehaviour>().ShootContinuous(); } } }
void Update() { //status if (this.droneHealth < 0 || this.selfDestruct) { while (debrisAmount < maxDebris) { for (debrisAmount = 0; debrisAmount < maxDebris; debrisAmount++) { debri[debrisAmount] = ModAPI.CreatePhysicalObject("Debris", debrisComp.debrisSprites[UnityEngine.Random.Range(0, debrisComp.debrisSprites.Length)]); debri[debrisAmount].transform.position = transform.position; randomDirection = UnityEngine.Random.Range(-5, 5); debri[debrisAmount].GetComponent <PhysicalBehaviour>().rigidbody.AddForce(new Vector2(randomDirection, randomDirection) * debrisForce); } } ModAPI.CreateParticleEffect("Explosion", transform.position); Destroy(gameObject); selfDestruct = false; } }
void Start() { string modPath = Application.dataPath + "/../" + ModAPI.Metadata.MetaLocation; Debug.Log("Path is " + modPath); if (File.Exists(Path.Combine(modPath, "JFramework.dll"))) { string path = Path.Combine(modPath, "JFramework.dll"); Debug.Log("Main DLL found at " + path); ModAPI.Notify("Main DLL found at " + path); Assembly mainAssembly = Assembly.LoadFile(path); mainAssembly.GetType("JFramework.Main").GetField("modPath", BindingFlags.Static | BindingFlags.Public).SetValue(null, modPath); mainAssembly.GetType("JFramework.Main").GetMethod("Entry").Invoke(null, new object[0]); } else { Debug.LogError("Main DLL could not be found in mod folder, please try to reinstall the mod"); ModAPI.Notify("Main DLL could not be found in mod folder, please try to reinstall the mod"); } }
// ******************************** // Awake // ******************************** protected override void Awake() { base.Awake(); // On button sprite OnButton = new GameObject("On Button Sprite"); OnButton.transform.SetParent(this.transform); OnButton.transform.localPosition = OnButtonPosition; OnButton.transform.localScale = ButtonScale; OnButtonSprite = OnButton.AddComponent <SpriteRenderer>(); OnButtonSprite.sprite = GlowSprite; OnButtonSprite.sharedMaterial = ModAPI.FindMaterial("VeryBright"); OnButtonSprite.color = OnButtonColour; OnButtonSprite.enabled = false; // On button light OnButtonLight = ModAPI.CreateLight(transform, Color.red); OnButtonLight.Color = OnButtonColour; OnButtonLight.Brightness = 10.0f; OnButtonLight.Radius = 0.01f; OnButtonLight.transform.localPosition = OnButtonPosition; OnButtonLight.SpriteRenderer.enabled = false; }
public MyDebrisVoxelPhysics(ModAPI.IMyEntity Entity1, RigidBodyFlag rigidBodyFlag) : base(Entity1, rigidBodyFlag) { }
protected void ShowLoginUser(ModAPI.Utils.WebService.User user) { Dispatcher.Invoke(delegate() { LoginButton.Visibility = System.Windows.Visibility.Collapsed; LoginLoader.Visibility = System.Windows.Visibility.Collapsed; LoggedIn.Visibility = System.Windows.Visibility.Visible; UserAvatarLoader.Visibility = System.Windows.Visibility.Visible; System.Console.WriteLine(user.Usergroup); Usergroup.SetResourceReference(TextBlock.TextProperty, "Lang.UserGroup." + user.Usergroup); Username.Text = user.Username; user.OnAvatarChange = AvatarChange; user.LoadAvatar(); }); }
// Update is called once per frame void Update() { armExtractPos = new Vector2(transform.position.x, transform.position.y - .2f); armRetractPos = new Vector2(transform.position.x, transform.position.y); if (readyToDropBomb) { bombPreview.SetActive(true); bomberArms.transform.position = armExtractPos; timeTillDrop += Time.deltaTime; if (timeTillDrop > 2) { GameObject bomb = ModAPI.CreatePhysicalObject("BOMB", ModAPI.LoadSprite("Sprites/Bomb.png")); bomb.transform.position = bombPreview.transform.position; if (!bomb.GetComponent <BombComponent>()) { bomb.AddComponent <BombComponent>(); } cooldown = true; cooldownTime = 5; readyToDropBomb = false; bombPreview.SetActive(false); } else { if (timeTillDrop > 1.9) { GetComponent <DroneModBehaviour>().overwriteHover = true; } } } else { bomberArms.transform.position = armRetractPos; timeTillDrop = 0; } if (cooldown) { cooldownTime -= Time.deltaTime; } if (cooldownTime <= 0) { cooldown = false; } Collider2D aliveObjectInRadius = Physics2D.OverlapCircle(transform.position, 10f, LayerMask.GetMask("Objects")); if (aliveObjectInRadius.gameObject.GetComponent <LimbBehaviour>()) { targetObjLoc = aliveObjectInRadius.transform.position - transform.position; if (!cooldown) { readyToDropBomb = true; targetObjLoc.Normalize(); GetComponent <PhysicalBehaviour>().rigidbody.velocity = new Vector2(targetObjLoc.x * movSpeed, GetComponent <PhysicalBehaviour>().rigidbody.velocity.y); } else { GetComponent <PhysicalBehaviour>().rigidbody.velocity = new Vector2(-targetObjLoc.x * movSpeed / 2, GetComponent <PhysicalBehaviour>().rigidbody.velocity.y); } } else { if (cooldown) { if (GetComponent <PhysicalBehaviour>().rigidbody.velocity.magnitude > .3) { GetComponent <PhysicalBehaviour>().rigidbody.velocity = new Vector2(GetComponent <PhysicalBehaviour>().rigidbody.velocity.x / cooldownTime, GetComponent <PhysicalBehaviour>().rigidbody.velocity.y); } } readyToDropBomb = false; } }
public void Initialize(ModAPI api) { this.modAPI = api; this.modAPI.AddScene("_Mods", this); }
public static void setAPI(ModAPI modAPI) { api = modAPI; }
public static void Main() { //tell the game that a component of this type should be created in the background ModAPI.Register <CoolBackgroundScriptTime>(); }
public void Initialize(ModAPI api) { this.modAPI = api; this.modAPI.AddScene ("_Mods", this); }
public virtual void Initialize(ModAPI api) { }
public override sealed void Initialize(ModAPI api) { this.modAPI = api; }
public static void Main() { //Normal Drone ModAPI.Register( new Modification() { OriginalItem = ModAPI.FindSpawnable("Brick"), // Searches the ingame catalog and returns with the inputted string if possible. NameOverride = "Flying Drone -DM", // Name. NameToOrderByOverride = "Android 2", // How the item is ordered (I didn't want it in the 'G' section, so I renamed it to Brick 2, so it shows up next to the brick.) DescriptionOverride = "It flies.\n\nDesign by BombErik#6969. \nCreated by _Kassjak_#4463",// Description CategoryOverride = ModAPI.FindCategory("Entities"), //Category ThumbnailOverride = ModAPI.LoadSprite("Sprites/DroneView.png", 5f), //Thumbnail AfterSpawn = (Instance) => { Instance.AddComponent<DroneModBehaviour>(); //Base script of the drone Instance.AddComponent<SoundSystem>(); //Everyone loves sound Instance.AddComponent<DebrisComponent>().DefaultDroneDebris(); //Set debris for explosion Instance.AddComponent<BladeBehaviour>().setSmallBlade(Instance.transform, Instance.transform.eulerAngles, new Vector2(Instance.transform.position.x - .3f,Instance.transform.position.y + .35f)); //Set blade type, parent, rotation and position Instance.AddComponent<BladeBehaviour>().setSmallBlade(Instance.transform, Instance.transform.eulerAngles, new Vector2(Instance.transform.position.x + .3f,Instance.transform.position.y + .35f)); //Set blade type, parent, rotation and position Instance.GetComponent<PhysicalBehaviour>().Properties = ModAPI.FindPhysicalProperties("Metal"); Instance.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("Sprites/DroneBody.png"); Instance.GetComponent<PhysicalBehaviour>().rigidbody.drag = 0.5f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.angularDrag = 0f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.gravityScale = 1f; Instance.FixColliders(); } } ); //Suicide Drone ModAPI.Register( new Modification() { OriginalItem = ModAPI.FindSpawnable("Brick"), // Searches the ingame catalog and returns with the inputted string if possible. NameOverride = "Suicide Drone -DM", // Name. NameToOrderByOverride = "Android 2", // How the item is ordered (I didn't want it in the 'G' section, so I renamed it to Brick 2, so it shows up next to the brick.) DescriptionOverride = "Hoams towards any living object and explodes.\n\nDesign by BombErik#6969. \nCreated by _Kassjak_#4463",// Description CategoryOverride = ModAPI.FindCategory("Entities"),//Category ThumbnailOverride = ModAPI.LoadSprite("Sprites/DroneView.png", 5f),//Thumbnail AfterSpawn = (Instance) => { Instance.AddComponent<DebrisComponent>().SuiciderDroneDebris(); Instance.AddComponent<SuiciderBehaviour>(); Instance.AddComponent<BladeBehaviour>().setBigBlade(Instance.transform, Instance.transform.eulerAngles, new Vector2(Instance.transform.position.x,Instance.transform.position.y + .2f)); Instance.GetComponent<PhysicalBehaviour>().Properties = ModAPI.FindPhysicalProperties("Metal"); Instance.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("Sprites/SuiciderBody.png"); Instance.GetComponent<PhysicalBehaviour>().rigidbody.drag = 0.5f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.angularDrag = 0f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.gravityScale = 1f; Instance.AddComponent<DroneModBehaviour>(); Instance.FixColliders(); Instance.AddComponent<SoundSystem>(); } } ); //Turret Drone ModAPI.Register( new Modification() { OriginalItem = ModAPI.FindSpawnable("Brick"), // Searches the ingame catalog and returns with the inputted string if possible. NameOverride = "Turret Drone -DM", // Name. NameToOrderByOverride = "Brick 2", // How the item is ordered (I didn't want it in the 'G' section, so I renamed it to Brick 2, so it shows up next to the brick.) DescriptionOverride = "It flies and shoots.\n\nDesign by BombErik#6969. \nCreated by _Kassjak_#4463",// Description CategoryOverride = ModAPI.FindCategory("Entities"),//Category ThumbnailOverride = ModAPI.LoadSprite("Sprites/TurretView.png", 5f),//Thumbnail AfterSpawn = (Instance) => { Instance.GetComponent<PhysicalBehaviour>().Properties = ModAPI.FindPhysicalProperties("Metal"); Instance.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("Sprites/DroneBody.png"); Instance.GetComponent<PhysicalBehaviour>().rigidbody.drag = 0.5f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.angularDrag = 0f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.gravityScale = 1f; Instance.AddComponent<GunBehaviour>(); Instance.AddComponent<DroneModBehaviour>(); Instance.FixColliders(); } } ); //Bomber Drone ModAPI.Register( new Modification() { OriginalItem = ModAPI.FindSpawnable("Brick"), // Searches the ingame catalog and returns with the inputted string if possible. NameOverride = "Bomber Drone -DM", // Name. NameToOrderByOverride = "Brick 2", // How the item is ordered (I didn't want it in the 'G' section, so I renamed it to Brick 2, so it shows up next to the brick.) DescriptionOverride = "It flies and bombs.\n\nDesign by BombErik#6969. \nCreated by _Kassjak_#4463",// Description CategoryOverride = ModAPI.FindCategory("Entities"),//Category ThumbnailOverride = ModAPI.LoadSprite("Sprites/BomberView.png", 5f),//Thumbnail AfterSpawn = (Instance) => { Instance.AddComponent<BladeBehaviour>().setBigBlade(Instance.transform, Instance.transform.eulerAngles, new Vector2(Instance.transform.position.x,Instance.transform.position.y + .2f)); Instance.GetComponent<PhysicalBehaviour>().Properties = ModAPI.FindPhysicalProperties("Metal"); Instance.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("Sprites/BomberBody.png"); Instance.GetComponent<PhysicalBehaviour>().rigidbody.drag = 0.5f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.angularDrag = 0f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.gravityScale = 1f; Instance.AddComponent<DroneModBehaviour>(); Instance.FixColliders(); Instance.AddComponent<BomberBehaviour>(); } } ); //Speaker Drone ModAPI.Register( new Modification() { OriginalItem = ModAPI.FindSpawnable("Brick"), // Searches the ingame catalog and returns with the inputted string if possible. NameOverride = "Speaker Drone -DM", // Name. NameToOrderByOverride = "Brick 2", // How the item is ordered (I didn't want it in the 'G' section, so I renamed it to Brick 2, so it shows up next to the brick.) DescriptionOverride = "It flies and speaks",// Description CategoryOverride = ModAPI.FindCategory("Entities"),//Category ThumbnailOverride = ModAPI.LoadSprite("Sprites/SpeakerView.png", 5f),//Thumbnail AfterSpawn = (Instance) => { Instance.GetComponent<PhysicalBehaviour>().Properties = ModAPI.FindPhysicalProperties("Metal"); Instance.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("Sprites/TransportDroneBody.png"); Instance.GetComponent<PhysicalBehaviour>().rigidbody.drag = 0.5f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.angularDrag = 0f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.gravityScale = 1f; Instance.FixColliders(); Instance.AddComponent<DebrisComponent>().SuiciderDroneDebris(); Instance.GetComponent<PhysicalBehaviour>().rigidbody.drag = 0.5f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.angularDrag = 0f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.gravityScale = 1f; Instance.AddComponent<DroneModBehaviour>(); Instance.FixColliders(); Instance.AddComponent<SoundSystem>(); } } ); //Speakersss Drone ModAPI.Register( new Modification() { OriginalItem = ModAPI.FindSpawnable("Brick"), // Searches the ingame catalog and returns with the inputted string if possible. NameOverride = "Speaker Drone -DM", // Name. NameToOrderByOverride = "Brick 2", // How the item is ordered (I didn't want it in the 'G' section, so I renamed it to Brick 2, so it shows up next to the brick.) DescriptionOverride = "It flies and speaks",// Description CategoryOverride = ModAPI.FindCategory("Entities"),//Category ThumbnailOverride = ModAPI.LoadSprite("Sprites/SpeakerView.png", 5f),//Thumbnail AfterSpawn = (Instance) => { Instance.GetComponent<PhysicalBehaviour>().Properties = ModAPI.FindPhysicalProperties("Metal"); Instance.GetComponent<SpriteRenderer>().sprite = ModAPI.LoadSprite("Sprites/MagnetDroneBody.png"); Instance.GetComponent<PhysicalBehaviour>().rigidbody.drag = 0.5f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.angularDrag = 0f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.gravityScale = 1f; Instance.FixColliders(); Instance.AddComponent<DebrisComponent>().SuiciderDroneDebris(); Instance.GetComponent<PhysicalBehaviour>().rigidbody.drag = 0.5f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.angularDrag = 0f; Instance.GetComponent<PhysicalBehaviour>().rigidbody.gravityScale = 1f; Instance.AddComponent<DroneModBehaviour>(); Instance.FixColliders(); Instance.AddComponent<SoundSystem>(); } } ); }
void IMyPlayerCollection.RemoveControlledEntity(ModAPI.IMyEntity entity) { var e = entity as MyEntity; if (e != null) RemoveControlledEntity(e); }
void ModAPI.Ingame.IMyConveyorSorter.RemoveItem(ModAPI.Ingame.MyInventoryItemFilter item) { if (item.AllSubTypes) { byte id; if (!CandidateTypesToId.TryGetValue(item.ItemId.TypeId, out id)) { Debug.Assert(false, "type not in dictionary"); return; } ChangeListType(id, true); return; } ChangeListId(item.ItemId, true); }
public static void Main() { ModAPI.Register <FrameworkInit>(); }
void ModAPI.IMyPistonBase.Attach(ModAPI.IMyPistonTop top) { if (top != null) m_connectionState.Value = new State() { TopBlockId = top.EntityId }; }
public static void Main() { ModAPI.Register( new Modification() { OriginalItem = ModAPI.FindSpawnable("Shotgun"), NameOverride = "Doom Shotgun", NameToOrderByOverride = "Doom Shotgun", DescriptionOverride = "This is my boomstick", CategoryOverride = ModAPI.FindCategory("Firearms"), ThumbnailOverride = ModAPI.LoadSprite("ShotgunIcon.png", 5f), AfterSpawn = (Instance) => { var firearm = Instance.GetComponent <FirearmBehaviour>(); firearm.BulletsPerShot = 7; firearm.ShotSounds = new AudioClip[] { ModAPI.LoadSound("DSSHOTGN.wav") }; Instance.GetComponent <SpriteRenderer>().sprite = ModAPI.LoadSprite("SHOTA0.png", 1.5f); BoxCollider2D[] colliders = Instance.GetComponents <BoxCollider2D>(); for (int i = 0; i < colliders.Length; i++) { UnityEngine.GameObject.Destroy(colliders[i]); } var barrel = Instance.AddComponent <BoxCollider2D>(); barrel.offset = new Vector2(0.2967865f, 0.08143535f); barrel.size = new Vector2(1.206427f, 0.1799865f); var handle = Instance.AddComponent <BoxCollider2D>(); handle.offset = new Vector2(-0.6044311f, -0.03619349f); handle.size = new Vector2(0.5911378f, 0.2921863f); } } ); ModAPI.Register( new Modification() { OriginalItem = ModAPI.FindSpawnable("Shotgun"), NameOverride = "Doom Super Shotgun", NameToOrderByOverride = "Doom Super Shotgun", DescriptionOverride = "This is my boomstick", CategoryOverride = ModAPI.FindCategory("Firearms"), ThumbnailOverride = ModAPI.LoadSprite("SuperShotgunIcon.png", 5f), AfterSpawn = (Instance) => { var firearm = Instance.GetComponent <FirearmBehaviour>(); firearm.InitialInaccuracy = 0.2f; firearm.BulletsPerShot = 20; firearm.ShotSounds = new AudioClip[] { ModAPI.LoadSound("SSG.wav") }; BoxCollider2D[] colliders = Instance.GetComponents <BoxCollider2D>(); for (int i = 0; i < colliders.Length; i++) { UnityEngine.GameObject.Destroy(colliders[i]); } Instance.GetComponent <SpriteRenderer>().sprite = ModAPI.LoadSprite("SGN2A0.png", 1f); var barrel = Instance.AddComponent <BoxCollider2D>(); barrel.offset = new Vector2(0.3513924f, 0.1270209f); barrel.size = new Vector2(0.8375123f, 0.139269f); var handle = Instance.AddComponent <BoxCollider2D>(); handle.offset = new Vector2(-0.5533118f, -0.02573015f); handle.size = new Vector2(0.4336729f, 0.3489566f); var middleHandle = Instance.AddComponent <BoxCollider2D>(); middleHandle.offset = new Vector2(-0.2005489f, 0.05699047f); middleHandle.size = new Vector2(0.2645392f, 0.1792521f); } } ); ModAPI.Register( new Modification() { OriginalItem = ModAPI.FindSpawnable("Red Barrel"), NameOverride = "Doom Explosive Barrel", NameToOrderByOverride = "Doom Explosive Barrel", DescriptionOverride = "haha barrel go boom", CategoryOverride = ModAPI.FindCategory("Explosives"), ThumbnailOverride = ModAPI.LoadSprite("BarrelIcon.png", 5f), AfterSpawn = (Instance) => { /*todo: figure out explosion sounds*/ Instance.GetComponent <SpriteRenderer>().sprite = ModAPI.LoadSprite("BAR1A0.png", 1f); Instance.FixColliders(); } } ); ModAPI.Register( new Modification() { OriginalItem = ModAPI.FindSpawnable("Light Machine Gun"), NameOverride = "Doom Chaingun", NameToOrderByOverride = "Doom Chaingun", DescriptionOverride = "makes the pistol useless", CategoryOverride = ModAPI.FindCategory("Firearms"), ThumbnailOverride = ModAPI.LoadSprite("ChaingunIcon.png", 5f), AfterSpawn = (Instance) => { var firearm = Instance.GetComponent <FirearmBehaviour>(); firearm.ShotSounds = new AudioClip[] { ModAPI.LoadSound("DSPISTOL.wav") }; Instance.GetComponent <SpriteRenderer>().sprite = ModAPI.LoadSprite("MGUNA0.png", 1f); Instance.FixColliders(); } } ); ModAPI.Register( new Modification() { OriginalItem = ModAPI.FindSpawnable("Machine Blaster"), NameOverride = "Doom Plasma Rifle", NameToOrderByOverride = "Doom Plasma Rifle", DescriptionOverride = "it's not a Plasma Gun it's a Plasma RIFLE", CategoryOverride = ModAPI.FindCategory("Firearms"), ThumbnailOverride = ModAPI.LoadSprite("PlasmaIcon.png", 5f), AfterSpawn = (Instance) => { /**/ //get rid of yellow light thingys UnityEngine.Object.Destroy(Instance.transform.GetChild(0).gameObject); UnityEngine.Object.Destroy(Instance.transform.GetChild(1).gameObject); UnityEngine.Object.Destroy(Instance.transform.GetChild(2).gameObject); var firearm = Instance.GetComponent <BlasterBehaviour>(); var Bolt = firearm.Bolt; Color c1 = new Color(0, 0, 1, 1); Color c2 = new Color(0, 0, 1, 1); Bolt.GetComponent <BlasterboltBehaviour>().lineRenderer.SetColors(c1, c2); firearm.Clips = new AudioClip[] { ModAPI.LoadSound("DSPLASMA.wav") }; Instance.GetComponent <SpriteRenderer>().sprite = ModAPI.LoadSprite("PLASA0.png", 1f); Instance.FixColliders(); } } ); ModAPI.Register( new Modification() { OriginalItem = ModAPI.FindSpawnable("Rocket Launcher"), NameOverride = "Doom Rocket Launcher", NameToOrderByOverride = "Doom Rocket Launcher", DescriptionOverride = "makes badguys go boom", CategoryOverride = ModAPI.FindCategory("Firearms"), ThumbnailOverride = ModAPI.LoadSprite("RocketLauncherIcon.png", 5f), AfterSpawn = (Instance) => { var firearm = Instance.GetComponent <RocketLauncherBehaviour>(); //have to do this to prevent it from being replaced by BFG ball // UnityEngine.GameObject.Destroy(Projectile.GetComponent<BFGProjectile>()); // Projectile.AddComponent<LaunchedRocketBehaviour>(); firearm.AudioSource.clip = ModAPI.LoadSound("DSRLAUNC.wav"); Instance.GetComponent <SpriteRenderer>().sprite = ModAPI.LoadSprite("LAUNA0.png", 1f); Instance.FixColliders(); } } ); ModAPI.Register( new Modification() { OriginalItem = ModAPI.FindSpawnable("Rocket Launcher"), NameOverride = "Doom BFG 9000", NameToOrderByOverride = "Doom BFG 9000", DescriptionOverride = "Big F*****g Gun 9000", CategoryOverride = ModAPI.FindCategory("Firearms"), ThumbnailOverride = ModAPI.LoadSprite("BFGIcon.png", 5f), AfterSpawn = (Instance) => { // UnityEngine.GameObject.Destroy(Instance.GetComponent<RocketLauncherBehaviour>()); //Instance.AddComponent<BFG9000Behaviour>(); var firearm = Instance.GetComponent <RocketLauncherBehaviour>(); GameObject bfgball = UnityEngine.GameObject.Instantiate(firearm.Projectile); //Resources.Load("Assets/PrefabInstance/LaunchedRocket.prefab") as GameObject; //UnityEngine.GameObject.Instantiate(firearm.Projectile); firearm.Projectile = bfgball; bfgball.AddComponent <BFGProjectile>(); firearm.AudioSource.clip = ModAPI.LoadSound("DSBFG.wav"); Instance.GetComponent <SpriteRenderer>().sprite = ModAPI.LoadSprite("BFUGA0.png", 1f); Instance.FixColliders(); UnityEngine.GameObject.Destroy(bfgball.GetComponent <LaunchedRocketBehaviour>()); } } ); }
// ******************************** // Device hit by EMP // ******************************** protected virtual void OnEMPHit() { ModAPI.CreateParticleEffect("BigZap", this.transform.position); this.Break("FuseBlown"); }
public void OnClosedTextBox(ModAPI.ResultEnum result) { if (m_textBox.Description.Text.Length > MAX_NUMBER_CHARACTERS) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( styleEnum: MyMessageBoxStyleEnum.Info, callback: OnClosedMessageBox, buttonType: MyMessageBoxButtonsType.YES_NO, messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextTooLongText))); } else { CloseWindow(m_isEditingPublic); } }
public static void Initialize(ModAPI api) { BaseMod.modAPI = api; ScrollsExtension.setAPI (api); }
void ModAPI.Interfaces.IMyControllableEntity.DrawHud(ModAPI.Interfaces.IMyCameraController camera, long playerId) { if (camera is IMyCameraController) DrawHud(camera as IMyCameraController, playerId); }
void IMyPlayerCollection.SetControlledEntity(ulong steamUserId, ModAPI.IMyEntity entity) { var e = entity as MyEntity; if (e != null) SetControlledEntity(steamUserId, e); }
/// <summary> /// This method parses custom attributes offered by the ModAPI to offer /// certain abilities like launching a mod ingame or inmenu. /// </summary> /// <remarks> /// This method adds new elements to the XDocument provided to it. /// This is because you cant scan efficently for all methods with a certain /// attribute. While in-game the ModAPI can use this information to determine /// which methods to call when. /// </remarks> /// <param name="mod">The mod currently parsed.</param> /// <param name="configuration">The configuration file where the attributes are saved for quicker lookup while in-game.</param> /// <param name="method">The method to parse</param> /// <param name="ConfigurationAttributes">A dictionary filled with the attributes to look for.</param> public static void ParseCustomAttributes(ModAPI.Data.Mod mod, XDocument configuration, MethodDefinition method, Dictionary<string, TypeDefinition> ConfigurationAttributes) { for (int k = 0; k < method.CustomAttributes.Count; k++) { CustomAttribute attribute = method.CustomAttributes[k]; string attrKey = attribute.AttributeType.FullName; if (ConfigurationAttributes.ContainsKey(attrKey)) { TypeDefinition attributeType = ConfigurationAttributes[attrKey]; bool valid = true; foreach (TypeReference interfc in attributeType.Interfaces) { if (interfc.Name == "IStaticAttribute" && !method.IsStatic) { Debug.Log("Modloader: "+mod.Game.GameConfiguration.ID, "Method \"" + method.FullName + "\" is using attribute \"" + method.CustomAttributes[k].AttributeType.FullName + "\" which is only suitable for static methods but isn't marked as static.", Debug.Type.WARNING); valid = false; } if (interfc.Name == "INoParametersAttribute" && method.Parameters.Count > 0) { Debug.Log("Modloader: " + mod.Game.GameConfiguration.ID, "Method \"" + method.FullName + "\" is using attribute \"" + method.CustomAttributes[k].AttributeType.FullName + "\" which is only suitable for methods without parameters but has parameters.", Debug.Type.WARNING); valid = false; } } if (!valid) continue; List<string> Names = new List<string>(); if (attribute.ConstructorArguments.Count > 0) { foreach (MethodDefinition m in attributeType.Methods) { if (m.IsConstructor) { foreach (ParameterDefinition p in m.Parameters) { Names.Add(p.Name); } break; } } } XElement newElement = new XElement(attributeType.Name); for (int i = 0; i < attribute.ConstructorArguments.Count; i++) { CustomAttributeArgument arg = attribute.ConstructorArguments[i]; newElement.SetAttributeValue(Names[i], arg.Value); } newElement.Value = method.FullName; newElement.SetAttributeValue("ModID", mod.ID); configuration.Root.Add(newElement); method.CustomAttributes.RemoveAt(k); k--; } } }
void DoSetupFilter(ModAPI.Ingame.MyConveyorSorterMode mode, List<ModAPI.Ingame.MyInventoryItemFilter> items) { IsWhitelist = mode == ModAPI.Ingame.MyConveyorSorterMode.Whitelist; m_inventoryConstraint.Clear(); if (items != null) { m_allowCurrentListUpdate = false; try { foreach (var item in items) { if (item.AllSubTypes) m_inventoryConstraint.AddObjectBuilderType(item.ItemId.TypeId); else m_inventoryConstraint.Add(item.ItemId); } } finally { m_allowCurrentListUpdate = true; } } // Recompute because of new sorter settings CubeGrid.GridSystems.ConveyorSystem.FlagForRecomputation(); currentList.UpdateVisual(); }
public static void Initialize(ModAPI api) { BaseMod.modAPI = api; ScrollsExtension.setAPI(api); }
void ModAPI.Ingame.IMyConveyorSorter.SetFilter(ModAPI.Ingame.MyConveyorSorterMode mode, List<ModAPI.Ingame.MyInventoryItemFilter> items) { // Update everyone else - except self MyMultiplayer.RaiseEvent(this, x => x.DoSetupFilter, mode, items); }