public void ReceivePortal(Portal portal, Portal other, int clipIndex, ShootState state, Vector3 impact, Vector3 pos, Vector3 normal) { MuzzlePlarticle(portal); switch (state) { case ShootState.Place: ImpactParticle(impact, normal, portal, portal.layer); portal.Place(this, pos, Quaternion.LookRotation(normal, GetPseudoPortalUp(portal.transform, normal)), Vector3.one * size.Value); SetEmission(portal.color); VidyaMod.PlayAudio(audioSource, clips[clipIndex], 1f, 0.9f, 1.05f); break; case ShootState.Impact: ImpactParticle(impact, normal, portal, other.layer); other.StartAnimation(PortalAnim.Disturb); VidyaMod.PlayAudio(audioSource, clips[2], 0.9f); break; case ShootState.Miss: VidyaMod.PlayAudio(audioSource, clips[2], 0.9f); break; case ShootState.Unable: VidyaMod.PlayAudio(audioSource, clips[2], 0.3f); portal.StartAnimation(PortalAnim.Disturb); other.StartAnimation(PortalAnim.Disturb); break; } }
public virtual void SetVisual(EntityAI ai) { MeshFilter filter = ai.my.killingHandler.my.Poser.meshFilter; MeshRenderer render = filter.GetComponent <MeshRenderer>(); Transform vis = filter.transform; Transform visPivot = vis.parent; ai.health = Chicken.AI.health; filter.mesh = Chicken.mesh; render.sharedMaterial = Chicken.mat; if (visPivot.parent != ai.transform) { visPivot.parent.localScale = Vector3.one; } VidyaMod.MatchTransform(visPivot, Chicken.visPivot); VidyaMod.MatchTransform(vis, Chicken.vis); Transform remove = visPivot.FindChild("ArmCollider"); if (remove) { remove.gameObject.SetActive(false); } remove = visPivot.FindChild("AttackCollider"); if (remove) { remove.gameObject.SetActive(false); } }
public void ShootPortal(Portal portal, Portal other, AudioClip clip) { RaycastHit target = RaycastPortal(portal.transform, other.transform); Vector3 org = target.point; target = CheckPortal(target, portal, other); if (target.distance >= 0f) { if (target.distance > 0f) { ImpactParticle(org, target.normal, portal, portal.layer); portal.Place(this, target.point, Quaternion.LookRotation(target.normal, GetPseudoPortalUp(portal.transform, target.normal)), Vector3.one * size.Value); SetEmission(portal.color); SendPortalPlacement(portal, ShootState.Place, org, target.point, target.normal); return; } else { ImpactParticle(org, target.normal, portal, other.layer); other.StartAnimation(PortalAnim.Disturb); SendPortalPlacement(portal, ShootState.Impact, org, target.point, target.normal); return; } } SendPortalPlacement(portal, ShootState.Miss, org, target.point, target.normal); VidyaMod.PlayAudio(audioSource, clips[2], 0.9f); }
protected virtual RaycastHit RaycastPortal(Transform portal, Transform otherPortal) { Vector3 fwd = -transform.up; Vector3 up = transform.forward; Vector3 pos = transform.position + up * 0.25f + fwd * 0.5f; LayerMask mask = AddPiece.CreateLayerMask(new int[] { 0, 2, 6, 7, 11, 24, 28, 29 }); RaycastHit[] hits = Physics.SphereCastAll(pos, 0.2f, fwd, 300f, mask); RaycastHit hit = new RaycastHit(); hit.distance = -1f; hit.point = pos; float min = float.MaxValue; for (int i = 0; i < hits.Length; i++) { if (hits[i].distance < min) { RaycastHit h = hits[i]; if (h.collider.transform.root == portal.transform || h.collider.isTrigger || VidyaMod.IsVirtualTrigger(h.collider.transform)) { continue; } if (!h.collider.transform.root.GetComponent <WinCondition>()) { if (h.collider.gameObject.layer == 2) { if (h.collider.transform.root == otherPortal.transform) { min = h.distance; h.distance = 0f; hit = h; } continue; } if (h.collider.attachedRigidbody) { if (h.collider.attachedRigidbody == Rigidbody) { continue; } } min = h.distance; h.distance = -1f; hit = h; continue; } min = h.distance; h.point = h.point + h.normal * (h.collider.name == "FloorBig" ? 0.02f : 0.2f); hit = h; } } return(hit); }
protected virtual RaycastHit Raycast(Vector3 pos, Vector3 dir, float dist, Portal portal, Portal other, float overlap = 0f) { LayerMask mask = AddPiece.CreateLayerMask(new int[] { 0, 2, 6, 7, 11, 24, 28, 29 }); RaycastHit[] hits = Physics.RaycastAll(pos, dir, dist, mask); RaycastHit hit = new RaycastHit(); hit.distance = dist; hit.point = pos + dir * dist; float min = float.MaxValue; for (int i = 0; i < hits.Length; i++) { if (hits[i].distance < min) { RaycastHit h = hits[i]; if (h.collider.transform.root == portal.transform) { continue; } if (h.collider.transform.root == BlockBehaviour.ParentMachine.transform.root) { continue; } float d = h.distance; if (h.collider.gameObject.layer == 2) { if (h.collider.transform.root != other.transform) { continue; } } else if (overlap > 0f) { if (!VidyaMod.IsVirtualTrigger(h.collider.transform)) { float diff = dist - h.distance; float o = diff > overlap ? overlap : diff; h.distance = h.distance + o; } } min = d; hit = h; } } /* * float r = dir.x * 0.5f + 0.75f; * float g = dir.y * 0.5f + 0.75f; * float b = dir.z * 0.5f + 0.75f; * Debug.DrawRay(pos, dir * dist, new Color(r, g, b, 0.2f)); * Debug.DrawRay(pos, dir * hit.distance, new Color(r, g, b, 1f));*/ return(hit); }
protected void SendPortalPlacement(Portal portal, ShootState state, Vector3 impact, Vector3 pos, Vector3 normal) { MuzzlePlarticle(portal); VidyaMod.PlayAudio(audioSource, state == ShootState.Place ? clips[portal.index] : clips[2], 0.9f); if (!StatMaster.isLocalSim) { Message targetMessage = portalShotMessageType.CreateMessage(Block.From(this), portal.index, (int)state, impact, pos, normal); ModNetworking.SendToAll(targetMessage); } }
public virtual void ChangeFireControl(EntityAI ai) { FireController fireControl = ai.my.killingHandler.my.fireControl; VidyaMod.MatchTransform(fireControl.transform, Chicken.fireControl.transform); SphereCollider fireCollider = fireControl.myCollider as SphereCollider; FireController chickenFireControl = Chicken.fireControl; SphereCollider chickenFireCollider = chickenFireControl.myCollider as SphereCollider; fireCollider.center = chickenFireCollider.center; fireCollider.radius = chickenFireCollider.radius; fireControl.destroyTimer = chickenFireControl.destroyTimer; fireControl.randomAmount = chickenFireControl.randomAmount; fireControl.onFireDuration = chickenFireControl.onFireDuration; fireControl.fullFireDuration = fireControl.destroyTimer + fireControl.onFireDuration; }
public GameObject ReplaceWithChicken(MonoBehaviour m) { if (m.name.Contains("Chicken")) { return(m.gameObject); } GameObject g = m.gameObject; m.gameObject.name = "Polymorphed Chicken"; //Debug.Log(Chicken + ", " + m); GameObject featherBurst = Instantiate(Chicken.dustCorpse, m.transform.position, Quaternion.identity, m.transform.parent) as GameObject; VidyaMod.PlayAudio(audioSource, clip, 1f, 0.95f, 1.1f); if (m is EntityAI) { EntityAI ai = m as EntityAI; SetVisual(ai); ChangePosing(ai); ChangeDeathController(ai); ChangeBobbing(ai); ChangeFaction(ai); ChangeBehaviour(ai); ChangeSounds(ai); if (StatMaster.isHosting || StatMaster.isLocalSim) { ChangeFireControl(ai); ToChickenColliderAnimator collideranim = ai.gameObject.AddComponent <ToChickenColliderAnimator>(); collideranim.Setup(ai, Chicken.AI.my.Collider as SphereCollider); } } else if (m is SimpleBirdAI) { g = Spawn(Chicken.prefab, m.gameObject); Destroy(m.gameObject); } else { g = Spawn(Chicken.prefab, m as EnemyAISimple); Destroy(m.gameObject); } return(g); }
public static void SetupPortals() { if (setupPortals) { return; } setupPortals = true; Transform fogSphere = Camera.main.transform.FindChild("FOG SPHERE"); if (fogSphere) { fogSphere.name = "FOG SPHERE 1"; fogSphere.localScale = Vector3.one * 1090f; } fogSphere = GameObject.Find("FOG SPHERE")?.transform; if (fogSphere) { fogSphere.name = "FOG SPHERE 2"; fogSphere.localScale = Vector3.one * 1090f; } Camera.main.cullingMask = VidyaMod.RemoveFromLayerMask(Camera.main.cullingMask, 1); Camera.main.cullingMask = VidyaMod.RemoveFromLayerMask(Camera.main.cullingMask, 3); Camera.main.cullingMask = VidyaMod.RemoveFromLayerMask(Camera.main.cullingMask, 30); Camera.main.cullingMask = VidyaMod.RemoveFromLayerMask(Camera.main.cullingMask, 31); Camera.main.gameObject.AddComponent <MainCamTracker>(); CreatePortal("Portal A", ref PortalA); CreatePortal("Portal B", ref PortalB); int portalAlayer = 6; int portalBlayer = 7; int portalAinsidePortalLayer = 1; int portalBinsidePortalLayer = 3; PortalA.Setup(0, portalAlayer, portalBlayer, portalAinsidePortalLayer, portalBinsidePortalLayer, 30, PortalB, 0f, 1f, 1f); PortalB.Setup(1, portalBlayer, portalAlayer, portalBinsidePortalLayer, portalAinsidePortalLayer, 31, PortalA, 0.5f, 1f, 0.7f); ResetPortal(); }
public void Setup(Camera source, Portal portal, Portal otherPortal, int[] remove, int[] add, PortalCameraControl par = null, float nearclipoffset = 0f, bool ignoreFog = false) { if (par) { hasParent = true; parentCamera = par; } setUp = true; this.source = source; this.portal = portal; this.otherPortal = otherPortal; this.nearClipOffset = nearclipoffset; if (portalDummy == null) { portalDummy = new GameObject(portal.name + " Dummy").transform; portalDummy.parent = portal.transform; } if (otherDummy == null) { otherDummy = new GameObject(otherPortal.name + " Dummy").transform; otherDummy.parent = otherPortal.transform; } camera = gameObject.AddComponent <Camera>(); camera.CopyFrom(Camera.main); int i; for (i = 0; i < remove.Length; i++) { camera.cullingMask = VidyaMod.RemoveFromLayerMask(camera.cullingMask, remove[i]); //camera.cullingMask = camera.cullingMask & ~(1 << remove[i]);//remove layer } for (i = 0; i < add.Length; i++) { camera.cullingMask = VidyaMod.AddToLayerMask(camera.cullingMask, add[i]); //camera.cullingMask = camera.cullingMask | (1 << add[i]);//add } camera.depth = -2; sourceBloom = Camera.main.GetComponent <BloomAndLensFlares>(); sourceSsao = Camera.main.GetComponent <SSAOPro>(); sourceAa = Camera.main.GetComponent <AntialiasingAsPostEffect>(); sourceFog = Camera.main.GetComponent <ColorfulFog>(); bloom = ModUtility.CopyComponent <BloomAndLensFlares>(sourceBloom, gameObject); ssao = ModUtility.CopyComponent <SSAOPro>(sourceSsao, gameObject); aa = ModUtility.CopyComponent <AntialiasingAsPostEffect>(sourceAa, gameObject); fog = ModUtility.CopyComponent <ColorfulFog>(sourceFog, gameObject); bloom.enabled = false; ssao.enabled = sourceSsao.enabled; aa.enabled = sourceAa.enabled; fog.enabled = sourceFog.enabled; layer = add[0]; ignored = ignoreFog; ProcessFog(); UpdateFOV(); ReferenceMaster.onFOVChanged += UpdateFOV; }