Example #1
0
        public WithCargo(Actor self, WithCargoInfo info)
        {
            cargo     = self.Trait <Cargo>();
            facing    = self.TraitOrDefault <IFacing>();
            cargoInfo = info;

            body = self.Trait <IBodyOrientation>();

            if (info.LocalOffset.Length == 0)
            {
                throw new InvalidOperationException("LocalOffset must have at least one entry");
            }
        }
Example #2
0
        public WithCargo(Actor self, WithCargoInfo info)
        {
            cargo     = self.Trait <Cargo>();
            facing    = self.TraitOrDefault <IFacing>();
            cargoInfo = info;

            body = self.Trait <IBodyOrientation>();

            if (info.LocalOffset.Length % 3 != 0)
            {
                throw new InvalidOperationException("Invalid LocalOffset array length");
            }

            positions = new WVec[info.LocalOffset.Length / 3];
            for (var i = 0; i < info.LocalOffset.Length / 3; i++)
            {
                positions[i] = new WVec(info.LocalOffset[3 * i], info.LocalOffset[3 * i + 1], info.LocalOffset[3 * i + 2]);
            }
        }