コード例 #1
0
        public void OnComponentInstallation(Entity parentEntity, ComponentInstance componentInstance)
        {
            var instancesDB = parentEntity.GetDataBlob <ComponentInstancesDB>();

            if (!parentEntity.HasDataBlob <FireControlAbilityDB>())
            {
                var fcdb = new FireControlAbilityDB();
                parentEntity.SetDataBlob(fcdb);
            }

            if (!componentInstance.HasAblity <WeaponState>())
            {
                var wpnState = new WeaponState(componentInstance, this);
                wpnState.WeaponType     = "Beam";
                wpnState.WeaponStats    = new (string name, double value, ValueTypeStruct valueType)[3];
コード例 #2
0
ファイル: WeaponProcessor.cs プロジェクト: CoZarctan/Pulsar4x
        public static void FireBeamWeapons(ComponentInstance beamWeapon, DateTime atDate)
        {
            //TODO: all this needs to get re-written.
            WeaponState             stateInfo   = beamWeapon.GetAbilityState <WeaponState>();
            FireControlAbilityState fireControl = stateInfo.FireControl.GetAbilityState <FireControlAbilityState>();

            if (!fireControl.Target.IsValid)
            {
                fireControl.Target     = null;
                fireControl.IsEngaging = false;
                return;
            }

            //var myPos = beamWeapon.GetDataBlob<ComponentInstanceData>().ParentEntity.GetDataBlob<PositionDB>();
            var targetPos = fireControl.Target.GetDataBlob <PositionDB>();


            //TODO chance to hit
            //int damageAmount = 10;//TODO damageAmount calc
            var designAtb    = beamWeapon.Design.GetAttribute <SimpleBeamWeaponAtbDB>();
            int damageAmount = designAtb.DamageAmount; // TODO: Better damage calculation

            double range = 1000;                       // myPos.GetDistanceTo_AU(targetPos);

            // only fire if target is in range TODO: fire anyway, but miss. TODO: this will be wrong if we do movement last, this needs to be done after movement.
            if (range <= designAtb.MaxRange)//TODO: firecontrol shoudl have max range too?: Math.Min(designAtb.MaxRange, stateInfo.FireControl.GetDataBlob<BeamFireControlAtbDB>().Range))
            {
                /*
                 * DamageFragment damage = new DamageFragment()
                 * {
                 *  Density =
                 * };
                 *
                 * DamageTools.DealDamage(fireControl.Target, new DamageFragment())
                 * //DamageProcessor.OnTakingDamage(, damageAmount, atDate);
                 */
                int reloadRate = designAtb.ReloadRate;
                stateInfo.CoolDown    = atDate + TimeSpan.FromSeconds(reloadRate);
                stateInfo.ReadyToFire = false;
            }
        }
コード例 #3
0
 public WeaponState(WeaponState db)
 {
     CoolDown    = db.CoolDown;
     ReadyToFire = db.ReadyToFire;
     FireControl = db.FireControl;
 }