SimulationChamber
Adds utilities for firing guns that are not bound to a player.
About this mod Author’s original text
Simulation Chamber
A mod to make it easy to fire a gun anywhere you need it on the map.
Change log
v 0.0.2
- Mod ID changed to correct format.
- Small Fixes, example made better.
v 0.0.2
- Fixed issues with multiplayer.
v0.0.0
- Initial Release
Simulated Gun
SimulatedAttack()
bool SimulatedAttack(int playerID, Vector3 spawnPos, Vector3 shootAngle, float charge, float damageM, Transform followTransform = null, bool useTransformForward = false)
Description
Fires the SimulatedGun.
Parameters
- int playerID the playerID of the player that is attacking.
- Vector3 spawnPos the spawnPosition of the attack.
- Vector3 shootAngle the angle of the attack.
- float charge the charge of the attack. Only matters if Gun::useCharge is true and GunChargePatch is installed.
- float damageM the damage multiplier of the attack.
- Transform followTransform an optional transform to use for the attacks. Useful if the gun has bursts and you want it to move with an object while firing.
- bool useTransformForward requires followTransform to be set. Optional parameter to use the followTransform's forward vector for the firing angle.
Example Usage
xGun.SimulatedAttack(this.player.playerID, new Vector3(obj.transform.position.x -1f, obj.transform.position.y, 0), new Vector3(player.data.input.aimDirection.x -1f, player.data.input.aimDirection.y, 0), 1f, 1);
CopyGunStatsExceptActions()
void CopyGunStatsExceptActions(Gun copyFromGun)
Description
Copies the stats from a gun onto the simulated gun with the exception of actions.
Parameters
- Gun copyFromGun
Example Usage
yGun.CopyGunStatsExceptActions(this.gun);
CopyShootProjectileAction()
void CopyShootProjectileAction(Gun copyFromGun)
Description
Copies the shootPojectileAction from a gun onto the simulated gun as a distinct stack of its delegates.
Parameters
- Gun copyFromGun
Example Usage
yGun.CopyShootProjectileAction(this.gun);
CopyAttackAction()
void CopyAttackAction(Gun copyFromGun)
Description
Copies the attack action from a gun onto the simulated gun as a distinct stack of its delegates.
Parameters
- Gun copyFromGun
Example Usage
xGun.CopyAttackAction(this.gun);
Example Mono
A mono included in the library for the purposes of doing this.
///
/// A mono for the purposes of explaining how the mod works.
///
public class MirrorSimulation: MonoBehaviour
{
Player player;
Gun gun;
// A list of guns created for this mono saved here.
// Ideally you'll make a pool of guns for your mod to use.
public SimulatedGun savedGuns = new SimulatedGun[2];
public static GameObject _stopRecursionObj = null;
public static GameObject StopRecursionObj
{
get
{
if (_stopRecursionObj == null)
{
_stopRecursionObj = new GameObject("A_StopRecursion", typeof(StopRecursion));
DontDestroyOnLoad(_stopRecursionObj);
}
return _stopRecursionObj;
}
}
public static ObjectsToSpawn StopRecursionSpawn
{
get
{
return new ObjectsToSpawn { new ObjectsToSpawn() { AddToProjectile = StopRecursionObj } };
}
}
public void Start()
{
// Get Player
this.player = this.GetComponentInParent();
// Get Gun
this.gun = this.player.data.weaponHandler.gun;
// Hook up our action.
this.gun.ShootPojectileAction += this.OnShootProjectileAction;
// Checks to see if we have a saved gun already, if not, we make one.
if (savedGuns[0] == null)
{
// We spawn a new object since this allows us manipulate the gun object's position without messing with the player's gameobjest.
savedGuns[0] = new GameObject("X-Gun").AddComponent();
}
// Checks to see if we have a second saved gun already, if not, we make one.
if (savedGuns[1] == null)
{
savedGuns[1] = new GameObject("Y-Gun").AddComponent();
}
}
public void OnShootProjectileAction(GameObject obj)
{
// If the bullet has the StopRecursion component in it somewhere, we don't want to trigger.
if (obj.GetComponentsInChildren().Length > 0)
{
return;
}
/***********************************************************************
- Here's where we s
Install & use Install: BepInEx plugin
- The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
- Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
- Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
- Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.
Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.
Install these first, or the mod will not work: