// Token: 0x0600295E RID: 10590 RVA: 0x00139BAC File Offset: 0x00137FAC public override void CompTickRare() { float ambientTemperature = this.parent.AmbientTemperature; bool selected = Find.Selector.SelectedObjects.Contains(this.parent) && Prefs.DevMode; Thing thing = null; if (MyMap != null && MyPos.InBounds(MyMap)) { thing = GenClosest.ClosestThingReachable(MyPos, MyMap, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), Props.triggerRadius, x => XenomorphUtil.isInfectablePawn(((Pawn)x)), null, 0, -1, false, RegionType.Set_Passable, false); } int huggercount = thing != null?XenomorphUtil.TotalSpawnedFacehuggerPawnCount(MyMap, 10, (Pawn)thing) : 0; int hostcount = thing != null?XenomorphUtil.TotalSpawnedInfectablePawnCount(MyMap, 10, this.MyPos) : 0; bool shouldHatch = huggercount < hostcount; if (thing != null && ambientTemperature > -20f) { Pawn pawn = (Pawn)thing; bool flag = XenomorphUtil.isInfectablePawn(pawn); if (selected) { // Log.Message(string.Format("{0} isInfectable?: {1}", pawn.Label, flag)); } if (flag) { this.canHatch = true; } if (canHatch && shouldHatch && DistanceBetween(MyPos, pawn.Position) < 10f) { float thingdist = DistanceBetween(MyPos, pawn.Position); float thingsize = pawn.BodySize; float thingstealth = thing.GetStatValue(StatDefOf.HuntingStealth); float thingmovespeed = thing.GetStatValue(StatDefOf.MoveSpeed); if (selected) { // Log.Message(string.Format("distance between {1} @{3} and {2} @ {4}: {0}", DistanceBetween(MyPos, pawn.Position), this.parent.LabelShort, pawn.Label, MyPos, pawn.Position)); // Log.Message(string.Format("{0} thingsize: {1}, thingstealth: {2}, thingmovespeed: {3}", pawn.Label, thingsize, thingstealth, thingmovespeed)); } float hatchon = ((10 * thingdist) - (thingsize * 5)); float roll = thingstealth > 0 ? (Rand.RangeInclusive(0, 100) * thingstealth): (Rand.RangeInclusive(0, 100)); if (roll > hatchon) { this.willHatch = true; } if (selected) { Log.Message(string.Format("{0} hatchon: {1}, roll: {2}, willHatch: {3}", pawn.Label, hatchon, roll, willHatch)); } } } if (thing == null) { // if (selected) Log.Message(string.Format("{0} @ {1}, Cant hatch No suitable Host Found", this.parent.Label, MyPos, canHatch)); } }
// Update is called once per frame void Update() { if (pybullet != IntPtr.Zero) { IntPtr cmd = NativeMethods.b3InitStepSimulationCommand(pybullet); IntPtr status = NativeMethods.b3SubmitClientCommandAndWaitStatus(pybullet, cmd); } // Debug.Log(m_cubeUid); if (m_cubeUid >= 0) { IntPtr cmd_handle = NativeMethods.b3RequestActualStateCommandInit(pybullet, m_cubeUid); IntPtr status_handle = NativeMethods.b3SubmitClientCommandAndWaitStatus(pybullet, cmd_handle); EnumSharedMemoryServerStatus status_type = (EnumSharedMemoryServerStatus)NativeMethods.b3GetStatusType(status_handle); if (status_type == EnumSharedMemoryServerStatus.CMD_ACTUAL_STATE_UPDATE_COMPLETED) { IntPtr p = IntPtr.Zero; int objUid = 0; int numDofQ = 0; int numDofU = 0; IntPtr inertialFrame = IntPtr.Zero; IntPtr actualStateQ = IntPtr.Zero; IntPtr actualStateQdot = IntPtr.Zero; IntPtr joint_reaction_forces = IntPtr.Zero; NativeMethods.b3GetStatusActualState( status_handle, ref objUid, ref numDofQ, ref numDofU, ref inertialFrame, ref actualStateQ, ref actualStateQdot, ref joint_reaction_forces); Debug.Log("objUid=" + objUid.ToString()); Debug.Log("numDofQ=" + numDofQ.ToString()); Debug.Log("numDofU=" + numDofU.ToString()); MyPos mpos = (MyPos)Marshal.PtrToStructure(actualStateQ, typeof(MyPos)); //Debug.Log("pos=(" + mpos.x.ToString()+","+ mpos.y.ToString()+ "," + mpos.z.ToString()+")"); //Debug.Log("orn=(" + mpos.qx.ToString() + "," + mpos.qy.ToString() + "," + mpos.qz.ToString() + mpos.qw.ToString() + ")"); Vector3 pos = new Vector3((float)mpos.x, (float)mpos.y, (float)mpos.z); Quaternion orn = new Quaternion((float)mpos.qx, (float)mpos.qy, (float)mpos.qz, (float)mpos.qw); Vector3 dimensions = new Vector3(1, 1, 1); CjLib.DebugUtil.DrawBox(pos, orn, dimensions, Color.black); } } { CjLib.DebugUtil.DrawLine(new Vector3(-1, 0, 0), new Vector3(1, 0, 0), Color.red); CjLib.DebugUtil.DrawLine(new Vector3(0, -1, 0), new Vector3(0, 1, 0), Color.green); CjLib.DebugUtil.DrawLine(new Vector3(0, 0, -1), new Vector3(0, 0, 1), Color.blue); } }
public void SyncPoseBullet2Unity(GameObject body) { int bodyId = -1; b3IdMap.TryGetValue(body, out bodyId); if (bodyId >= 0) { IntPtr cmd_handle = NativeMethods.b3RequestActualStateCommandInit(pybullet, bodyId); IntPtr status_handle = NativeMethods.b3SubmitClientCommandAndWaitStatus(pybullet, cmd_handle); EnumSharedMemoryServerStatus status_type = (EnumSharedMemoryServerStatus)NativeMethods.b3GetStatusType(status_handle); if (status_type == EnumSharedMemoryServerStatus.CMD_ACTUAL_STATE_UPDATE_COMPLETED) { IntPtr p = IntPtr.Zero; int numDofQ = 0; int numDofU = 0; IntPtr inertialFrame = IntPtr.Zero; IntPtr actualStateQ = IntPtr.Zero; IntPtr actualStateQdot = IntPtr.Zero; IntPtr joint_reaction_forces = IntPtr.Zero; NativeMethods.b3GetStatusActualState( status_handle, ref bodyId, ref numDofQ, ref numDofU, ref inertialFrame, ref actualStateQ, ref actualStateQdot, ref joint_reaction_forces); MyPos mpos = (MyPos)Marshal.PtrToStructure(actualStateQ, typeof(MyPos)); Vector3 pos = new Vector3((float)mpos.x, (float)mpos.y, (float)mpos.z); Quaternion orn = new Quaternion((float)mpos.qx, (float)mpos.qy, (float)mpos.qz, (float)mpos.qw); pos = RosSharp.TransformExtensions.Ros2Unity(pos); orn = RosSharp.TransformExtensions.Ros2Unity(orn); var tf = body.transform.position; body.transform.SetPositionAndRotation(pos, orn); } } }