コード例 #1
0
        public override void CreateRadiation(RadiationInfo fullInfo, int ticks)
        {
            foreach (CompIrradiator comp in GetIrradiators().InRandomOrder())
            {
                RadiationInfo info = new RadiationInfo();
                info.CopyFrom(fullInfo);
                comp.Irradiate(parent as Building, info, ticks);
                if (info.Empty())
                {
                    continue;
                }

                moteProps = comp.MoteProps;

                fullInfo.Add(info);
            }
        }
コード例 #2
0
        public void SpawnRadiationMote()
        {
            if (linked == null)
            {
                return;
            }


            CompPropertiesIrradiator moteProps = MoteProps;

            if (moteProps?.motes == null || !moteProps.motes.Any())
            {
                return;
            }

            var def = moteProps.motes.RandomElement();

            if (def.skip)
            {
                return;
            }

            if (def.speed.max < 0.5f)
            {
                if (Rand.RangeInclusive(0, 5) > linked.Position.DistanceTo(parent.Position))
                {
                    return;
                }
            }

            MoteRadiation moteThrown = ThingMaker.MakeThing(def.mote, null) as MoteRadiation;

            if (moteThrown == null)
            {
                return;
            }

            Vector3 origin      = parent.ExactPosition();
            Vector3 destination = linked.ExactPosition();

            origin.y = destination.y;
            Vector3 sideways = (destination - origin).normalized.RotatedBy(90);

            origin      += sideways * Rand.Range(-def.initialSpread, def.initialSpread);
            destination += sideways * Rand.Range(-def.spread, def.spread);

            float positionPercent = Mathf.Sqrt(Rand.Range(0f, 1f));
            float position        = def.offset.LerpThroughRange(positionPercent);
            float scale           = def.scaleRange.RandomInRange;

            Vector3 dir         = destination - origin;
            Vector3 startOffset = dir * position;
            float   angle       = startOffset.AngleFlat();

            moteThrown.exactPosition = origin + startOffset;
            moteThrown.exactRotation = angle;
            moteThrown.reflectAt     = motesReflectAt;
            moteThrown.reflectChance = def.reflectChance;

            Rot4 rot = Rotation();

            if (rot.IsHorizontal)
            {
                moteThrown.deathLocation      = linked.ExactPosition().x;
                moteThrown.isHorizontal       = true;
                moteThrown.reflectIndex       = rot == Rot4.West ? 0 : motesReflectAt.Count() - 1;
                moteThrown.reflectIndexChange = rot == Rot4.West ? 1 : -1;
            }
            else
            {
                moteThrown.deathLocation      = linked.ExactPosition().z;
                moteThrown.isHorizontal       = false;
                moteThrown.reflectIndex       = rot == Rot4.North ? 0 : motesReflectAt.Count() - 1;
                moteThrown.reflectIndexChange = rot == Rot4.North ? 1 : -1;
            }


            moteThrown.exactScale = new Vector3(scale, scale, scale);
            moteThrown.SetVelocity(angle, def.speed.RandomInRange);
            GenSpawn.Spawn(moteThrown, parent.Position, parent.Map, WipeMode.Vanish);
        }